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 __extension__ and typeof



details:   https://anonhg.NetBSD.org/src/rev/20fa46e0f09b
branches:  trunk
changeset: 326806:20fa46e0f09b
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Feb 18 22:01:36 2014 +0000

description:
add __extension__ and typeof

diffstat:

 usr.bin/xlint/lint1/cgram.y |  12 ++++++++++--
 usr.bin/xlint/lint1/err.c   |   6 +++---
 usr.bin/xlint/lint1/scan.l  |   8 ++++++--
 usr.bin/xlint/lint1/tree.c  |   7 ++++---
 4 files changed, 23 insertions(+), 10 deletions(-)

diffs (141 lines):

diff -r 94de6786d9f7 -r 20fa46e0f09b usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Tue Feb 18 20:54:34 2014 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Tue Feb 18 22:01:36 2014 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.57 2014/02/04 08:08:59 njoly Exp $ */
+/* $NetBSD: cgram.y,v 1.58 2014/02/18 22:01:36 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.57 2014/02/04 08:08:59 njoly Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.58 2014/02/18 22:01:36 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -130,6 +130,8 @@
 %token <y_op>          T_UNOP
 %token <y_op>          T_INCDEC
 %token                 T_SIZEOF
+%token                 T_TYPEOF
+%token                 T_EXTENSION
 %token                 T_ALIGNOF
 %token <y_op>          T_MULT
 %token <y_op>          T_DIVOP
@@ -553,6 +555,9 @@
          T_TYPE {
                $$ = gettyp($1);
          }
+       | T_TYPEOF T_LPARN term T_RPARN {
+               $$ = $3->tn_type;
+         }
        | struct_spec {
                popdecl();
                $$ = $1;
@@ -1732,6 +1737,9 @@
        | T_IMAG T_LPARN term T_RPARN {
                $$ = build(IMAG, $3, NULL);
          }
+       | T_EXTENSION T_LPARN term T_RPARN {
+               $$ = $3;
+         }
        | T_SIZEOF term                                 %prec T_SIZEOF {
                if (($$ = $2 == NULL ? NULL : bldszof($2->tn_type)) != NULL)
                        chkmisc($2, 0, 0, 0, 0, 0, 1);
diff -r 94de6786d9f7 -r 20fa46e0f09b usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Tue Feb 18 20:54:34 2014 +0000
+++ b/usr.bin/xlint/lint1/err.c Tue Feb 18 22:01:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.46 2013/04/19 17:43:05 christos Exp $        */
+/*     $NetBSD: err.c,v 1.47 2014/02/18 22:01:36 christos Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.46 2013/04/19 17:43:05 christos Exp $");
+__RCSID("$NetBSD: err.c,v 1.47 2014/02/18 22:01:36 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -208,7 +208,7 @@
        "cannot take size/alignment of void",                         /* 146 */
        "invalid cast expression",                                    /* 147 */
        "improper cast of void expression",                           /* 148 */
-       "illegal function",                                           /* 149 */
+       "illegal function (type %s)",                                 /* 149 */
        "argument mismatch: %d arg%s passed, %d expected",            /* 150 */
        "void expressions may not be arguments, arg #%d",             /* 151 */
        "argument cannot have unknown size, arg #%d",                 /* 152 */
diff -r 94de6786d9f7 -r 20fa46e0f09b usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Tue Feb 18 20:54:34 2014 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Tue Feb 18 22:01:36 2014 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.53 2013/10/18 20:46:09 christos Exp $ */
+/* $NetBSD: scan.l,v 1.54 2014/02/18 22:01:36 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.53 2013/10/18 20:46:09 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.54 2014/02/18 22:01:36 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -230,6 +230,7 @@
        { "double",     T_TYPE,         0,      DOUBLE, 0,        0, 0, 0 },
        { "else",       T_ELSE,         0,      0,      0,        0, 0, 0 },
        { "enum",       T_ENUM,         0,      0,      0,        0, 0, 0 },
+       { "__extension__", T_EXTENSION, 0,      0,      0,        0, 0, 1 },
        { "extern",     T_SCLASS,       EXTERN, 0,      0,        0, 0, 0 },
        { "float",      T_TYPE,         0,      FLOAT,  0,        0, 0, 0 },
        { "for",        T_FOR,          0,      0,      0,        0, 0, 0 },
@@ -256,6 +257,9 @@
        { "struct",     T_SOU,          0,      STRUCT, 0,        0, 0, 0 },
        { "switch",     T_SWITCH,       0,      0,      0,        0, 0, 0 },
        { "typedef",    T_SCLASS,       TYPEDEF, 0,     0,        0, 0, 0 },
+       { "typeof",     T_TYPEOF,       0,      0,      0,        0, 0, 1 },
+       { "__typeof",   T_TYPEOF,       0,      0,      0,        0, 0, 1 },
+       { "__typeof__", T_TYPEOF,       0,      0,      0,        0, 0, 1 },
        { "union",      T_SOU,          0,      UNION,  0,        0, 0, 0 },
        { "unsigned",   T_TYPE,         0,      UNSIGN, 0,        0, 0, 0 },
        { "void",       T_TYPE,         0,      VOID,   0,        0, 0, 0 },
diff -r 94de6786d9f7 -r 20fa46e0f09b usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Tue Feb 18 20:54:34 2014 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Tue Feb 18 22:01:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.74 2014/02/18 20:43:36 christos Exp $       */
+/*     $NetBSD: tree.c,v 1.75 2014/02/18 22:01:36 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.74 2014/02/18 20:43:36 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.75 2014/02/18 22:01:36 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -3171,8 +3171,9 @@
 
        if (func->tn_type->t_tspec != PTR ||
            func->tn_type->t_subt->t_tspec != FUNC) {
+               char buf[256];
                /* illegal function */
-               error(149);
+               error(149, tyname(buf, sizeof(buf), func->tn_type));
                return (NULL);
        }
 



Home | Main Index | Thread Index | Old Index