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 support for ({}) gcc shit.



details:   https://anonhg.NetBSD.org/src/rev/6d5770dc8946
branches:  trunk
changeset: 538572:6d5770dc8946
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Oct 22 22:50:11 2002 +0000

description:
add support for ({}) gcc shit.

diffstat:

 usr.bin/xlint/lint1/cgram.y    |  52 ++++++++++++++++++++++++++++++++++++-----
 usr.bin/xlint/lint1/err.c      |   5 ++-
 usr.bin/xlint/lint1/externs1.h |   4 +-
 usr.bin/xlint/lint1/scan.l     |   6 +++-
 usr.bin/xlint/lint1/tree.c     |   9 ++++---
 5 files changed, 59 insertions(+), 17 deletions(-)

diffs (220 lines):

diff -r 4007bdac55d5 -r 6d5770dc8946 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Tue Oct 22 21:58:33 2002 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Tue Oct 22 22:50:11 2002 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.28 2002/10/22 18:15:00 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.29 2002/10/22 22:50:11 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.28 2002/10/22 18:15:00 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.29 2002/10/22 22:50:11 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -242,6 +242,8 @@
 %type  <y_sym>         parameter_type_list
 %type  <y_sym>         parameter_declaration
 %type  <y_tnode>       expr
+%type  <y_tnode>       expr_stmnt_val
+%type  <y_tnode>       expr_stmnt_list
 %type  <y_tnode>       term
 %type  <y_tnode>       func_arg_list
 %type  <y_op>          point_or_arrow
@@ -1252,11 +1254,11 @@
        ;
 
 comp_stmnt:
-         compstmnt_lbrace declaration_list opt_stmnt_list compstmnt_rbrace
-       | compstmnt_lbrace opt_stmnt_list compstmnt_rbrace
+         comp_stmnt_lbrace declaration_list opt_stmnt_list comp_stmnt_rbrace
+       | comp_stmnt_lbrace opt_stmnt_list comp_stmnt_rbrace
        ;
 
-compstmnt_lbrace:
+comp_stmnt_lbrace:
          T_LBRACE {
                blklev++;
                mblklev++;
@@ -1264,7 +1266,7 @@
          }
        ;
 
-compstmnt_rbrace:
+comp_stmnt_rbrace:
          T_RBRACE {
                popdecl();
                freeblk();
@@ -1289,7 +1291,7 @@
 
 expr_stmnt:
          expr T_SEMI {
-               expr($1, 0, 0);
+               expr($1, 0, 0, 1);
                ftflg = 0;
          }
        | T_SEMI {
@@ -1297,6 +1299,22 @@
          }
        ;
 
+expr_stmnt_val:
+         expr T_SEMI {
+               /* XXX: We should really do that only on the last name */
+               if ($1->tn_op == NAME)
+                       $1->tn_sym->s_used = 1;
+               $$ = $1;
+               expr($1, 0, 0, 0);
+               ftflg = 0;
+         }
+       ;
+
+expr_stmnt_list:
+       expr_stmnt_val
+       | expr_stmnt_list expr_stmnt_val
+       ;
+
 selection_stmnt:
          if_without_else {
                SAVE();
@@ -1538,6 +1556,26 @@
                        $2->tn_parn = 1;
                $$ = $2;
          }
+       | T_LPARN comp_stmnt_lbrace declaration_list expr_stmnt_list {
+               blklev--;
+               mblklev--;
+               initsym = mktempsym($4->tn_type);
+               mblklev++;
+               blklev++;
+               gnuism(320);
+       } comp_stmnt_rbrace T_RPARN {
+               $$ = getnnode(initsym, 0);
+       }
+       | T_LPARN comp_stmnt_lbrace expr_stmnt_list {
+               blklev--;
+               mblklev--;
+               initsym = mktempsym($3->tn_type);
+               mblklev++;
+               blklev++;
+               gnuism(320);
+       } comp_stmnt_rbrace T_RPARN {
+               $$ = getnnode(initsym, 0);
+       }
        | term T_INCDEC {
                $$ = build($2 == INC ? INCAFT : DECAFT, $1, NULL);
          }
diff -r 4007bdac55d5 -r 6d5770dc8946 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Tue Oct 22 21:58:33 2002 +0000
+++ b/usr.bin/xlint/lint1/err.c Tue Oct 22 22:50:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.23 2002/10/22 18:15:00 christos Exp $        */
+/*     $NetBSD: err.c,v 1.24 2002/10/22 22:50:11 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.23 2002/10/22 18:15:00 christos Exp $");
+__RCSID("$NetBSD: err.c,v 1.24 2002/10/22 22:50:11 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -375,6 +375,7 @@
        "__func__ is a C9X feature",                                  /* 317 */
        "variable array dimension is a GCC extension",                /* 318 */
        "compound literals are a C9X/GCC extension",                  /* 319 */
+       "({ }) is a GCC extension",                                   /* 320 */
 };
 
 /*
diff -r 4007bdac55d5 -r 6d5770dc8946 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Tue Oct 22 21:58:33 2002 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Tue Oct 22 22:50:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.18 2002/10/22 18:15:00 christos Exp $   */
+/*     $NetBSD: externs1.h,v 1.19 2002/10/22 22:50:11 christos Exp $   */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -203,7 +203,7 @@
 extern tnode_t *funcarg(tnode_t *, tnode_t *);
 extern tnode_t *funccall(tnode_t *, tnode_t *);
 extern val_t   *constant(tnode_t *, int);
-extern void    expr(tnode_t *, int, int);
+extern void    expr(tnode_t *, int, int, int);
 extern void    chkmisc(tnode_t *, int, int, int, int, int, int);
 extern int     conaddr(tnode_t *, sym_t **, ptrdiff_t *);
 extern strg_t  *catstrg(strg_t *, strg_t *);
diff -r 4007bdac55d5 -r 6d5770dc8946 usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Tue Oct 22 21:58:33 2002 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Tue Oct 22 22:50:11 2002 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.30 2002/10/22 21:09:34 christos Exp $ */
+/* $NetBSD: scan.l,v 1.31 2002/10/22 22:50:11 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: scan.l,v 1.30 2002/10/22 21:09:34 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.31 2002/10/22 22:50:11 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -1350,6 +1350,8 @@
        sym->s_blklev = blklev;
        sym->s_scl = AUTO;
        sym->s_kind = FVFT;
+       sym->s_used = 1;
+       sym->s_set = 1;
 
        if ((sym->s_link = symtab[h]) != NULL)
                symtab[h]->s_rlink = &sym->s_link;
diff -r 4007bdac55d5 -r 6d5770dc8946 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Tue Oct 22 21:58:33 2002 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Tue Oct 22 22:50:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.33 2002/10/22 21:09:35 christos Exp $       */
+/*     $NetBSD: tree.c,v 1.34 2002/10/22 22:50:11 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.33 2002/10/22 21:09:35 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.34 2002/10/22 22:50:11 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -3346,7 +3346,7 @@
  * for the expression.
  */
 void
-expr(tnode_t *tn, int vctx, int tctx)
+expr(tnode_t *tn, int vctx, int tctx, int freeblk)
 {
 
        if (tn == NULL && nerr == 0)
@@ -3383,7 +3383,8 @@
                displexpr(tn, 0);
 
        /* free the tree memory */
-       tfreeblk();
+       if (freeblk)
+               tfreeblk();
 }
 
 static void



Home | Main Index | Thread Index | Old Index