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 1) // is only for c99 or gcc



details:   https://anonhg.NetBSD.org/src/rev/28cdf48b345d
branches:  trunk
changeset: 538878:28cdf48b345d
user:      perry <perry%NetBSD.org@localhost>
date:      Sat Nov 02 01:42:22 2002 +0000

description:
1) // is only for c99 or gcc
2) inline is acceptable in c99 -- create a new c99 keyword class.

XXX The handling of sflag and Sflag is utterly bogus throughout this
pass. I think I have to make some adjustments.

diffstat:

 usr.bin/xlint/lint1/scan.l |  107 +++++++++++++++++++++++---------------------
 1 files changed, 55 insertions(+), 52 deletions(-)

diffs (144 lines):

diff -r f3acac75d604 -r 28cdf48b345d usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Fri Nov 01 22:58:44 2002 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Sat Nov 02 01:42:22 2002 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.31 2002/10/22 22:50:11 christos Exp $ */
+/* $NetBSD: scan.l,v 1.32 2002/11/02 01:42:22 perry 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.31 2002/10/22 22:50:11 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.32 2002/11/02 01:42:22 perry Exp $");
 #endif
 
 #include <stdlib.h>
@@ -188,55 +188,56 @@
        scl_t   kw_scl;         /* storage class if kw_token T_SCLASS */
        tspec_t kw_tspec;       /* type spec. if kw_token T_TYPE or T_SOU */
        tqual_t kw_tqual;       /* type qual. fi kw_token T_QUAL */
-       u_int   kw_stdc : 1;    /* STDC keyword */
-       u_int   kw_gcc : 1;     /* GCC keyword */
+       u_int   kw_c89;         /* c89 keyword */
+       u_int   kw_c99;         /* c99 keyword */
+       u_int   kw_gcc;         /* GCC keyword */
 } kwtab[] = {
-       { "asm",        T_ASM,          0,      0,      0,        0, 1 },
-       { "__asm",      T_ASM,          0,      0,      0,        0, 0 },
-       { "__asm__",    T_ASM,          0,      0,      0,        0, 0 },
-       { "auto",       T_SCLASS,       AUTO,   0,      0,        0, 0 },
-       { "break",      T_BREAK,        0,      0,      0,        0, 0 },
-       { "case",       T_CASE,         0,      0,      0,        0, 0 },
-       { "char",       T_TYPE,         0,      CHAR,   0,        0, 0 },
-       { "const",      T_QUAL,         0,      0,      CONST,    1, 0 },
-       { "__const__",  T_QUAL,         0,      0,      CONST,    0, 0 },
-       { "__const",    T_QUAL,         0,      0,      CONST,    0, 0 },
-       { "continue",   T_CONTINUE,     0,      0,      0,        0, 0 },
-       { "default",    T_DEFAULT,      0,      0,      0,        0, 0 },
-       { "do",         T_DO,           0,      0,      0,        0, 0 },
-       { "double",     T_TYPE,         0,      DOUBLE, 0,        0, 0 },
-       { "else",       T_ELSE,         0,      0,      0,        0, 0 },
-       { "enum",       T_ENUM,         0,      0,      0,        0, 0 },
-       { "extern",     T_SCLASS,       EXTERN, 0,      0,        0, 0 },
-       { "float",      T_TYPE,         0,      FLOAT,  0,        0, 0 },
-       { "for",        T_FOR,          0,      0,      0,        0, 0 },
-       { "goto",       T_GOTO,         0,      0,      0,        0, 0 },
-       { "if",         T_IF,           0,      0,      0,        0, 0 },
-       { "inline",     T_SCLASS,       INLINE, 0,      0,        0, 1 },
-       { "__inline__", T_SCLASS,       INLINE, 0,      0,        0, 0 },
-       { "__inline",   T_SCLASS,       INLINE, 0,      0,        0, 0 },
-       { "int",        T_TYPE,         0,      INT,    0,        0, 0 },
-       { "__symbolrename", T_SYMBOLRENAME, 0,  0,      0,        0, 0 },
-       { "long",       T_TYPE,         0,      LONG,   0,        0, 0 },
-       { "register",   T_SCLASS,       REG,    0,      0,        0, 0 },
-       { "return",     T_RETURN,       0,      0,      0,        0, 0 },
-       { "short",      T_TYPE,         0,      SHORT,  0,        0, 0 },
-       { "signed",     T_TYPE,         0,      SIGNED, 0,        1, 0 },
-       { "__signed__", T_TYPE,         0,      SIGNED, 0,        0, 0 },
-       { "__signed",   T_TYPE,         0,      SIGNED, 0,        0, 0 },
-       { "sizeof",     T_SIZEOF,       0,      0,      0,        0, 0 },
-       { "static",     T_SCLASS,       STATIC, 0,      0,        0, 0 },
-       { "struct",     T_SOU,          0,      STRUCT, 0,        0, 0 },
-       { "switch",     T_SWITCH,       0,      0,      0,        0, 0 },
-       { "typedef",    T_SCLASS,       TYPEDEF, 0,     0,        0, 0 },
-       { "union",      T_SOU,          0,      UNION,  0,        0, 0 },
-       { "unsigned",   T_TYPE,         0,      UNSIGN, 0,        0, 0 },
-       { "void",       T_TYPE,         0,      VOID,   0,        0, 0 },
-       { "volatile",   T_QUAL,         0,      0,      VOLATILE, 1, 0 },
-       { "__volatile__", T_QUAL,       0,      0,      VOLATILE, 0, 0 },
-       { "__volatile", T_QUAL,         0,      0,      VOLATILE, 0, 0 },
-       { "while",      T_WHILE,        0,      0,      0,        0, 0 },
-       { NULL,         0,              0,      0,      0,        0, 0 }
+       { "asm",        T_ASM,          0,      0,      0,        0, 0, 1 },
+       { "__asm",      T_ASM,          0,      0,      0,        0, 0, 0 },
+       { "__asm__",    T_ASM,          0,      0,      0,        0, 0, 0 },
+       { "auto",       T_SCLASS,       AUTO,   0,      0,        0, 0, 0 },
+       { "break",      T_BREAK,        0,      0,      0,        0, 0, 0 },
+       { "case",       T_CASE,         0,      0,      0,        0, 0, 0 },
+       { "char",       T_TYPE,         0,      CHAR,   0,        0, 0, 0 },
+       { "const",      T_QUAL,         0,      0,      CONST,    1, 0, 0 },
+       { "__const__",  T_QUAL,         0,      0,      CONST,    0, 0, 0 },
+       { "__const",    T_QUAL,         0,      0,      CONST,    0, 0, 0 },
+       { "continue",   T_CONTINUE,     0,      0,      0,        0, 0, 0 },
+       { "default",    T_DEFAULT,      0,      0,      0,        0, 0, 0 },
+       { "do",         T_DO,           0,      0,      0,        0, 0, 0 },
+       { "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 },
+       { "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 },
+       { "goto",       T_GOTO,         0,      0,      0,        0, 0, 0 },
+       { "if",         T_IF,           0,      0,      0,        0, 0, 0 },
+       { "inline",     T_SCLASS,       INLINE, 0,      0,        0, 1, 0 },
+       { "__inline__", T_SCLASS,       INLINE, 0,      0,        0, 0, 0 },
+       { "__inline",   T_SCLASS,       INLINE, 0,      0,        0, 0, 0 },
+       { "int",        T_TYPE,         0,      INT,    0,        0, 0, 0 },
+       { "__symbolrename", T_SYMBOLRENAME, 0,  0,      0,        0, 0, 0 },
+       { "long",       T_TYPE,         0,      LONG,   0,        0, 0, 0 },
+       { "register",   T_SCLASS,       REG,    0,      0,        0, 0, 0 },
+       { "return",     T_RETURN,       0,      0,      0,        0, 0, 0 },
+       { "short",      T_TYPE,         0,      SHORT,  0,        0, 0, 0 },
+       { "signed",     T_TYPE,         0,      SIGNED, 0,        1, 0, 0 },
+       { "__signed__", T_TYPE,         0,      SIGNED, 0,        0, 0, 0 },
+       { "__signed",   T_TYPE,         0,      SIGNED, 0,        0, 0, 0 },
+       { "sizeof",     T_SIZEOF,       0,      0,      0,        0, 0, 0 },
+       { "static",     T_SCLASS,       STATIC, 0,      0,        0, 0, 0 },
+       { "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 },
+       { "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 },
+       { "volatile",   T_QUAL,         0,      0,      VOLATILE, 1, 0, 0 },
+       { "__volatile__", T_QUAL,       0,      0,      VOLATILE, 0, 0, 0 },
+       { "__volatile", T_QUAL,         0,      0,      VOLATILE, 0, 0, 0 },
+       { "while",      T_WHILE,        0,      0,      0,        0, 0, 0 },
+       { NULL,         0,              0,      0,      0,        0, 0, 0 }
 };
 
 /* Symbol table */
@@ -271,7 +272,9 @@
        uint64_t uq;
 
        for (kw = kwtab; kw->kw_name != NULL; kw++) {
-               if (kw->kw_stdc && tflag)
+               if ((kw->kw_c89 || kw->kw_c99) && tflag)
+                       continue;
+               if (kw->kw_c99 && !(Sflag || gflag))
                        continue;
                if (kw->kw_gcc && !gflag)
                        continue;
@@ -1134,7 +1137,7 @@
 {
        int c;
 
-       if (sflag < 2 && !gflag)
+       if (!Sflag && !gflag)
                /* // comments only supported in C99 */
                (void)gnuism(312, tflag ? "traditional" : "ANSI");
 



Home | Main Index | Thread Index | Old Index