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 lint: reduce redundancy when defining GC...



details:   https://anonhg.NetBSD.org/src/rev/708617c8c684
branches:  trunk
changeset: 378997:708617c8c684
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon May 03 07:25:08 2021 +0000

description:
lint: reduce redundancy when defining GCC attributes

This macro would have prevented the unintended inconsistency in the
attribute 'pcs' (for ARM).

No functional change.  The generated code is the same, except for the
line numbers in lint_assert.

diffstat:

 usr.bin/xlint/lint1/lex.c |  98 +++++++++++++++++++++++-----------------------
 1 files changed, 50 insertions(+), 48 deletions(-)

diffs (170 lines):

diff -r 8707f2494996 -r 708617c8c684 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Mon May 03 07:08:54 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Mon May 03 07:25:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.33 2021/05/03 07:08:54 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.34 2021/05/03 07:25:08 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.33 2021/05/03 07:08:54 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.34 2021/05/03 07:25:08 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -112,6 +112,8 @@ lex_unknown_character(int c)
        kwdef(name, T_TYPE, 0, tspec, 0,        c89, c99, gcc, attr, deco)
 #define kwdef_tqual(name, tqual,               c89, c99, gcc, attr, deco) \
        kwdef(name, T_QUAL, 0, 0, tqual,        c89, c99, gcc, attr, deco)
+#define kwdef_gcc_attr(name, token) \
+       kwdef(name, token, 0, 0, 0,             0, 0, 1, 1, 5)
 
 /*
  * Keywords.
@@ -142,96 +144,96 @@ static    struct  kwtab {
        kwdef_token(    "_Generic",     T_GENERIC,              0,1,0,0,1),
        kwdef_token(    "_Noreturn",    T_NORETURN,             0,1,0,0,1),
        kwdef_tqual(    "_Thread_local", THREAD,                0,1,0,0,1),
-       kwdef_token(    "alias",        T_AT_ALIAS,             0,0,1,1,5),
-       kwdef_token(    "aligned",      T_AT_ALIGNED,           0,0,1,1,5),
+       kwdef_gcc_attr( "alias",        T_AT_ALIAS),
+       kwdef_gcc_attr( "aligned",      T_AT_ALIGNED),
        kwdef_token(    "alignof",      T_ALIGNOF,              0,0,0,0,4),
-       kwdef_token(    "alloc_size",   T_AT_ALLOC_SIZE,        0,0,1,1,5),
-       kwdef_token(    "always_inline", T_AT_ALWAYS_INLINE,    0,0,1,1,5),
+       kwdef_gcc_attr( "alloc_size",   T_AT_ALLOC_SIZE),
+       kwdef_gcc_attr( "always_inline",T_AT_ALWAYS_INLINE),
        kwdef_token(    "asm",          T_ASM,                  0,0,1,0,7),
        kwdef_token(    "attribute",    T_ATTRIBUTE,            0,0,1,0,6),
        kwdef_sclass(   "auto",         AUTO,                   0,0,0,0,1),
-       kwdef_token(    "bounded",      T_AT_BOUNDED,           0,0,1,1,5),
+       kwdef_gcc_attr( "bounded",      T_AT_BOUNDED),
        kwdef_token(    "break",        T_BREAK,                0,0,0,0,1),
-       kwdef_token(    "buffer",       T_AT_BUFFER,            0,0,1,1,5),
+       kwdef_gcc_attr( "buffer",       T_AT_BUFFER),
        kwdef_token(    "builtin_offsetof", T_BUILTIN_OFFSETOF, 0,0,1,0,2),
        kwdef_token(    "case",         T_CASE,                 0,0,0,0,1),
        kwdef_type(     "char",         CHAR,                   0,0,0,0,1),
-       kwdef_token(    "cold",         T_AT_COLD,              0,0,1,1,5),
-       kwdef_token(    "common",       T_AT_COMMON,            0,0,1,1,5),
+       kwdef_gcc_attr( "cold",         T_AT_COLD),
+       kwdef_gcc_attr( "common",       T_AT_COMMON),
        kwdef_tqual(    "const",        CONST,                  1,0,0,0,7),
-       kwdef_token(    "constructor",  T_AT_CONSTRUCTOR,       0,0,1,1,5),
+       kwdef_gcc_attr( "constructor",  T_AT_CONSTRUCTOR),
        kwdef_token(    "continue",     T_CONTINUE,             0,0,0,0,1),
        kwdef_token(    "default",      T_DEFAULT,              0,0,0,0,1),
-       kwdef_token(    "deprecated",   T_AT_DEPRECATED,        0,0,1,1,5),
-       kwdef_token(    "destructor",   T_AT_DESTRUCTOR,        0,0,1,1,5),
+       kwdef_gcc_attr( "deprecated",   T_AT_DEPRECATED),
+       kwdef_gcc_attr( "destructor",   T_AT_DESTRUCTOR),
        kwdef_token(    "do",           T_DO,                   0,0,0,0,1),
        kwdef_type(     "double",       DOUBLE,                 0,0,0,0,1),
        kwdef_token(    "else",         T_ELSE,                 0,0,0,0,1),
        kwdef_token(    "enum",         T_ENUM,                 0,0,0,0,1),
        kwdef_token(    "extension",    T_EXTENSION,            0,0,1,0,4),
        kwdef_sclass(   "extern",       EXTERN,                 0,0,0,0,1),
-       kwdef_token(    "fallthrough",  T_AT_FALLTHROUGH,       0,0,1,1,5),
+       kwdef_gcc_attr( "fallthrough",  T_AT_FALLTHROUGH),
        kwdef_type(     "float",        FLOAT,                  0,0,0,0,1),
        kwdef_token(    "for",          T_FOR,                  0,0,0,0,1),
-       kwdef_token(    "format",       T_AT_FORMAT,            0,0,1,1,5),
-       kwdef_token(    "format_arg",   T_AT_FORMAT_ARG,        0,0,1,1,5),
-       kwdef_token(    "gnu_inline",   T_AT_GNU_INLINE,        0,0,1,1,5),
-       kwdef_token(    "gnu_printf",   T_AT_FORMAT_GNU_PRINTF, 0,0,1,1,5),
+       kwdef_gcc_attr( "format",       T_AT_FORMAT),
+       kwdef_gcc_attr( "format_arg",   T_AT_FORMAT_ARG),
+       kwdef_gcc_attr( "gnu_inline",   T_AT_GNU_INLINE),
+       kwdef_gcc_attr( "gnu_printf",   T_AT_FORMAT_GNU_PRINTF),
        kwdef_token(    "goto",         T_GOTO,                 0,0,0,0,1),
        kwdef_token(    "if",           T_IF,                   0,0,0,0,1),
        kwdef_token(    "imag",         T_IMAG,                 0,1,0,0,4),
        kwdef_sclass(   "inline",       INLINE,                 0,1,0,0,7),
        kwdef_type(     "int",          INT,                    0,0,0,0,1),
        kwdef_type(     "long",         LONG,                   0,0,0,0,1),
-       kwdef_token(    "malloc",       T_AT_MALLOC,            0,0,1,1,5),
-       kwdef_token(    "may_alias",    T_AT_MAY_ALIAS,         0,0,1,1,5),
-       kwdef_token(    "minbytes",     T_AT_MINBYTES,          0,0,1,1,5),
-       kwdef_token(    "mode",         T_AT_MODE,              0,0,1,1,5),
-       kwdef_token(    "no_instrument_function",
-                               T_AT_NO_INSTRUMENT_FUNCTION,    0,0,1,1,5),
-       kwdef_token(    "noinline",     T_AT_NOINLINE,          0,0,1,1,5),
-       kwdef_token(    "nonnull",      T_AT_NONNULL,           0,0,1,1,5),
-       kwdef_token(    "nonstring",    T_AT_NONSTRING,         0,0,1,1,5),
-       kwdef_token(    "noreturn",     T_AT_NORETURN,          0,0,1,1,5),
-       kwdef_token(    "nothrow",      T_AT_NOTHROW,           0,0,1,1,5),
-       kwdef_token(    "optimize",     T_AT_OPTIMIZE,          0,0,1,1,5),
-       kwdef_token(    "packed",       T_AT_PACKED,            0,0,1,1,5),
+       kwdef_gcc_attr( "malloc",       T_AT_MALLOC),
+       kwdef_gcc_attr( "may_alias",    T_AT_MAY_ALIAS),
+       kwdef_gcc_attr( "minbytes",     T_AT_MINBYTES),
+       kwdef_gcc_attr( "mode",         T_AT_MODE),
+       kwdef_gcc_attr("no_instrument_function",
+                                       T_AT_NO_INSTRUMENT_FUNCTION),
+       kwdef_gcc_attr( "noinline",     T_AT_NOINLINE),
+       kwdef_gcc_attr( "nonnull",      T_AT_NONNULL),
+       kwdef_gcc_attr( "nonstring",    T_AT_NONSTRING),
+       kwdef_gcc_attr( "noreturn",     T_AT_NORETURN),
+       kwdef_gcc_attr( "nothrow",      T_AT_NOTHROW),
+       kwdef_gcc_attr( "optimize",     T_AT_OPTIMIZE),
+       kwdef_gcc_attr( "packed",       T_AT_PACKED),
        kwdef_token(    "packed",       T_PACKED,               0,0,0,0,2),
-       kwdef_token(    "pcs",          T_AT_PCS,               0,0,1,1,5),
-       kwdef_token(    "printf",       T_AT_FORMAT_PRINTF,     0,0,1,1,5),
-       kwdef_token(    "pure",         T_AT_PURE,              0,0,1,1,5),
+       kwdef_gcc_attr( "pcs",          T_AT_PCS),
+       kwdef_gcc_attr( "printf",       T_AT_FORMAT_PRINTF),
+       kwdef_gcc_attr( "pure",         T_AT_PURE),
        kwdef_token(    "real",         T_REAL,                 0,1,0,0,4),
        kwdef_sclass(   "register",     REG,                    0,0,0,0,1),
        kwdef_tqual(    "restrict",     RESTRICT,               0,1,0,0,5),
        kwdef_token(    "return",       T_RETURN,               0,0,0,0,1),
-       kwdef_token(    "returns_twice", T_AT_RETURNS_TWICE,    0,0,1,1,5),
-       kwdef_token(    "scanf",        T_AT_FORMAT_SCANF,      0,0,1,1,5),
+       kwdef_gcc_attr( "returns_twice",T_AT_RETURNS_TWICE),
+       kwdef_gcc_attr( "scanf",        T_AT_FORMAT_SCANF),
        kwdef_token(    "section",      T_AT_SECTION,           0,0,1,1,7),
-       kwdef_token(    "sentinel",     T_AT_SENTINEL,          0,0,1,1,5),
+       kwdef_gcc_attr( "sentinel",     T_AT_SENTINEL),
        kwdef_type(     "short",        SHORT,                  0,0,0,0,1),
        kwdef_type(     "signed",       SIGNED,                 1,0,0,0,3),
        kwdef_token(    "sizeof",       T_SIZEOF,               0,0,0,0,1),
        kwdef_sclass(   "static",       STATIC,                 0,0,0,0,1),
-       kwdef_token(    "strfmon",      T_AT_FORMAT_STRFMON,    0,0,1,1,5),
-       kwdef_token(    "strftime",     T_AT_FORMAT_STRFTIME,   0,0,1,1,5),
-       kwdef_token(    "string",       T_AT_STRING,            0,0,1,1,5),
+       kwdef_gcc_attr( "strfmon",      T_AT_FORMAT_STRFMON),
+       kwdef_gcc_attr( "strftime",     T_AT_FORMAT_STRFTIME),
+       kwdef_gcc_attr( "string",       T_AT_STRING),
        kwdef("struct", T_STRUCT_OR_UNION, 0,   STRUCT, 0,      0,0,0,0,1),
        kwdef_token(    "switch",       T_SWITCH,               0,0,0,0,1),
        kwdef_token(    "symbolrename", T_SYMBOLRENAME,         0,0,0,0,2),
-       kwdef_token(    "syslog",       T_AT_FORMAT_SYSLOG,     0,0,1,1,5),
-       kwdef_token(    "transparent_union", T_AT_TUNION,       0,0,1,1,5),
-       kwdef_token(    "tls_model",    T_AT_TLS_MODEL,         0,0,1,1,5),
+       kwdef_gcc_attr( "syslog",       T_AT_FORMAT_SYSLOG),
+       kwdef_gcc_attr( "transparent_union", T_AT_TUNION),
+       kwdef_gcc_attr( "tls_model",    T_AT_TLS_MODEL),
        kwdef_sclass(   "typedef",      TYPEDEF,                0,0,0,0,1),
        kwdef_token(    "typeof",       T_TYPEOF,               0,0,1,0,7),
        kwdef("union",  T_STRUCT_OR_UNION, 0,   UNION,  0,      0,0,0,0,1),
        kwdef_type(     "unsigned",     UNSIGN,                 0,0,0,0,1),
-       kwdef_token(    "unused",       T_AT_UNUSED,            0,0,1,1,5),
-       kwdef_token(    "used",         T_AT_USED,              0,0,1,1,5),
-       kwdef_token(    "visibility",   T_AT_VISIBILITY,        0,0,1,1,5),
+       kwdef_gcc_attr( "unused",       T_AT_UNUSED),
+       kwdef_gcc_attr( "used",         T_AT_USED),
+       kwdef_gcc_attr( "visibility",   T_AT_VISIBILITY),
        kwdef_type(     "void",         VOID,                   0,0,0,0,1),
        kwdef_tqual(    "volatile",     VOLATILE,               1,0,0,0,7),
-       kwdef_token("warn_unused_result", T_AT_WARN_UNUSED_RESULT, 0,0,1,1,5),
-       kwdef_token(    "weak",         T_AT_WEAK,              0,0,1,1,5),
+       kwdef_gcc_attr( "warn_unused_result", T_AT_WARN_UNUSED_RESULT),
+       kwdef_gcc_attr( "weak",         T_AT_WEAK),
        kwdef_token(    "while",        T_WHILE,                0,0,0,0,1),
        kwdef(NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0),
 #undef kwdef



Home | Main Index | Thread Index | Old Index