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 add variable array dimension.



details:   https://anonhg.NetBSD.org/src/rev/a798ea8fcd63
branches:  trunk
changeset: 538552:a798ea8fcd63
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Oct 22 13:48:50 2002 +0000

description:
add variable array dimension.

diffstat:

 usr.bin/xlint/lint1/cgram.y    |  32 ++++++++++++++++----------------
 usr.bin/xlint/lint1/err.c      |   5 +++--
 usr.bin/xlint/lint1/externs1.h |   4 ++--
 usr.bin/xlint/lint1/func.c     |   6 +++---
 usr.bin/xlint/lint1/tree.c     |  11 +++++++----
 5 files changed, 31 insertions(+), 27 deletions(-)

diffs (245 lines):

diff -r e30511744c60 -r a798ea8fcd63 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Tue Oct 22 13:48:30 2002 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Tue Oct 22 13:48:50 2002 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.26 2002/10/21 21:14:51 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.27 2002/10/22 13:48:51 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.26 2002/10/21 21:14:51 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.27 2002/10/22 13:48:51 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -64,7 +64,7 @@
  */
 static int onowarn = -1;
 
-static int     toicon(tnode_t *);
+static int     toicon(tnode_t *, int);
 static void    idecl(sym_t *, int, sbuf_t *);
 static void    ignuptorp(void);
 
@@ -681,12 +681,12 @@
                $$ = $1;
          }
        | notype_decl T_COLON constant {
-               $$ = bitfield($1, toicon($3));
+               $$ = bitfield($1, toicon($3, 1));
          }
        | {
                symtyp = FVFT;
          } T_COLON constant {
-               $$ = bitfield(NULL, toicon($3));
+               $$ = bitfield(NULL, toicon($3, 1));
          }
        ;
 
@@ -695,12 +695,12 @@
                $$ = $1;
          }
        | type_decl T_COLON constant {
-               $$ = bitfield($1, toicon($3));
+               $$ = bitfield($1, toicon($3, 1));
          }
        | {
                symtyp = FVFT;
          } T_COLON constant {
-               $$ = bitfield(NULL, toicon($3));
+               $$ = bitfield(NULL, toicon($3, 1));
          }
        ;
 
@@ -783,7 +783,7 @@
                $$ = ename($1, enumval, 1);
          }
        | ename T_ASSIGN constant {
-               $$ = ename($1, toicon($3), 0);
+               $$ = ename($1, toicon($3, 1), 0);
          }
        ;
 
@@ -848,7 +848,7 @@
                $$ = addarray($1, 0, 0);
          }
        | notype_direct_decl T_LBRACK constant T_RBRACK {
-               $$ = addarray($1, 1, toicon($3));
+               $$ = addarray($1, 1, toicon($3, 0));
          }
        | notype_direct_decl param_list {
                $$ = addfunc($1, $2);
@@ -877,7 +877,7 @@
                $$ = addarray($1, 0, 0);
          }
        | type_direct_decl T_LBRACK constant T_RBRACK {
-               $$ = addarray($1, 1, toicon($3));
+               $$ = addarray($1, 1, toicon($3, 0));
          }
        | type_direct_decl param_list {
                $$ = addfunc($1, $2);
@@ -913,7 +913,7 @@
                $$ = addarray($1, 0, 0);
          }
        | direct_param_decl T_LBRACK constant T_RBRACK {
-               $$ = addarray($1, 1, toicon($3));
+               $$ = addarray($1, 1, toicon($3, 0));
          }
        | direct_param_decl param_list {
                $$ = addfunc($1, $2);
@@ -942,7 +942,7 @@
                $$ = addarray($1, 0, 0);
          }
        | direct_notype_param_decl T_LBRACK constant T_RBRACK {
-               $$ = addarray($1, 1, toicon($3));
+               $$ = addarray($1, 1, toicon($3, 0));
          }
        | direct_notype_param_decl param_list {
                $$ = addfunc($1, $2);
@@ -1200,13 +1200,13 @@
                $$ = addarray(aname(), 0, 0);
          }
        | T_LBRACK constant T_RBRACK {
-               $$ = addarray(aname(), 1, toicon($2));
+               $$ = addarray(aname(), 1, toicon($2, 0));
          }
        | direct_abs_decl T_LBRACK T_RBRACK {
                $$ = addarray($1, 0, 0);
          }
        | direct_abs_decl T_LBRACK constant T_RBRACK {
-               $$ = addarray($1, 1, toicon($3));
+               $$ = addarray($1, 1, toicon($3, 0));
          }
        | abs_decl_param_list {
                $$ = addfunc(aname(), $1);
@@ -1691,13 +1691,13 @@
  * expressions, it frees the memory used for the expression.
  */
 static int
-toicon(tnode_t *tn)
+toicon(tnode_t *tn, int required)
 {
        int     i;
        tspec_t t;
        val_t   *v;
 
-       v = constant(tn);
+       v = constant(tn, required);
 
        /*
         * Abstract declarations are used inside expression. To free
diff -r e30511744c60 -r a798ea8fcd63 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Tue Oct 22 13:48:30 2002 +0000
+++ b/usr.bin/xlint/lint1/err.c Tue Oct 22 13:48:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.21 2002/10/22 13:31:34 christos Exp $        */
+/*     $NetBSD: err.c,v 1.22 2002/10/22 13:48:50 christos Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.21 2002/10/22 13:31:34 christos Exp $");
+__RCSID("$NetBSD: err.c,v 1.22 2002/10/22 13:48:50 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -373,6 +373,7 @@
        "GCC style struct or union member name in initializer",       /* 315 */
        "__FUNCTION__ is a GCC extension",                            /* 316 */
        "__func__ is a C9X feature",                                  /* 317 */
+       "variable array dimension is a GCC extension",                /* 318 */
 };
 
 /*
diff -r e30511744c60 -r a798ea8fcd63 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Tue Oct 22 13:48:30 2002 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Tue Oct 22 13:48:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.16 2002/10/21 21:14:52 christos Exp $   */
+/*     $NetBSD: externs1.h,v 1.17 2002/10/22 13:48:52 christos Exp $   */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -200,7 +200,7 @@
 extern tnode_t *cast(tnode_t *, type_t *);
 extern tnode_t *funcarg(tnode_t *, tnode_t *);
 extern tnode_t *funccall(tnode_t *, tnode_t *);
-extern val_t   *constant(tnode_t *);
+extern val_t   *constant(tnode_t *, int);
 extern void    expr(tnode_t *, int, int);
 extern void    chkmisc(tnode_t *, int, int, int, int, int, int);
 extern int     conaddr(tnode_t *, sym_t **, ptrdiff_t *);
diff -r e30511744c60 -r a798ea8fcd63 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Tue Oct 22 13:48:30 2002 +0000
+++ b/usr.bin/xlint/lint1/func.c        Tue Oct 22 13:48:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.18 2002/09/13 14:59:24 christos Exp $       */
+/*     $NetBSD: func.c,v 1.19 2002/10/22 13:48:50 christos Exp $       */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.18 2002/09/13 14:59:24 christos Exp $");
+__RCSID("$NetBSD: func.c,v 1.19 2002/10/22 13:48:50 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -464,7 +464,7 @@
                         * get the value of the expression and convert it
                         * to the type of the switch expression
                         */
-                       v = constant(tn);
+                       v = constant(tn, 1);
                        (void) memset(&nv, 0, sizeof nv);
                        cvtcon(CASE, 0, ci->c_swtype, &nv, v);
                        free(v);
diff -r e30511744c60 -r a798ea8fcd63 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Tue Oct 22 13:48:30 2002 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Tue Oct 22 13:48:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.30 2002/10/22 13:31:34 christos Exp $       */
+/*     $NetBSD: tree.c,v 1.31 2002/10/22 13:48:51 christos Exp $       */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.30 2002/10/22 13:31:34 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.31 2002/10/22 13:48:51 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -3278,7 +3278,7 @@
  * type, an error message is printed.
  */
 val_t *
-constant(tnode_t *tn)
+constant(tnode_t *tn, int required)
 {
        val_t   *v;
 
@@ -3313,7 +3313,10 @@
        }
 
        /* integral constant expression expected */
-       error(55);
+       if (required)
+               error(55);
+       else
+               gnuism(318);
 
        if (!isityp(v->v_tspec))
                v->v_tspec = INT;



Home | Main Index | Thread Index | Old Index