Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 allow c99 flexible arrays for packed str...



details:   https://anonhg.NetBSD.org/src/rev/9335930d684f
branches:  trunk
changeset: 804031:9335930d684f
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 20 21:17:18 2014 +0000

description:
allow c99 flexible arrays for packed structures.

diffstat:

 usr.bin/xlint/lint1/tree.c |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (44 lines):

diff -r c21e28ff1bae -r 9335930d684f usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Thu Nov 20 20:52:15 2014 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Thu Nov 20 21:17:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.76 2014/04/17 18:23:18 christos Exp $       */
+/*     $NetBSD: tree.c,v 1.77 2014/11/20 21:17:18 christos Exp $       */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.76 2014/04/17 18:23:18 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.77 2014/11/20 21:17:18 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -2998,17 +2998,21 @@
 int64_t
 tsize(type_t *tp)
 {
-       int     elem, elsz;
+       int     elem, elsz, flex;
 
        elem = 1;
+       flex = 0;
        while (tp->t_tspec == ARRAY) {
+               flex = 1;       /* allow c99 flex arrays [] [0] */
                elem *= tp->t_dim;
                tp = tp->t_subt;
        }
        if (elem == 0) {
-               /* cannot take size of incomplete type */
-               error(143);
-               elem = 1;
+               if (!flex) {
+                       /* cannot take size of incomplete type */
+                       error(143);
+                       elem = 1;
+               }
        }
        switch (tp->t_tspec) {
        case FUNC:



Home | Main Index | Thread Index | Old Index