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 handle __ symbols differently (so we don...
details: https://anonhg.NetBSD.org/src/rev/de1920a4b66d
branches: trunk
changeset: 349971:de1920a4b66d
user: christos <christos%NetBSD.org@localhost>
date: Thu Dec 29 23:54:29 2016 +0000
description:
handle __ symbols differently (so we don't duplicate entries in the table)
and add non_null.
diffstat:
usr.bin/xlint/lint1/cgram.y | 6 +-
usr.bin/xlint/lint1/scan.l | 274 ++++++++++++++++++++-----------------------
2 files changed, 134 insertions(+), 146 deletions(-)
diffs (truncated from 354 to 300 lines):
diff -r f553a2912f9f -r de1920a4b66d usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Thu Dec 29 23:50:59 2016 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Thu Dec 29 23:54:29 2016 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.87 2016/12/29 19:40:21 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.88 2016/12/29 23:54:29 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.87 2016/12/29 19:40:21 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.88 2016/12/29 23:54:29 christos Exp $");
#endif
#include <stdlib.h>
@@ -214,6 +214,7 @@
%token <y_type> T_AT_MAY_ALIAS
%token <y_type> T_AT_MODE
%token <y_type> T_AT_NORETURN
+%token <y_type> T_AT_NON_NULL
%token <y_type> T_AT_NO_INSTRUMENT_FUNCTION
%token <y_type> T_AT_PACKED
%token <y_type> T_AT_PURE
@@ -513,6 +514,7 @@
| T_AT_ALIGNED T_LPARN constant T_RPARN
| T_AT_SENTINEL T_LPARN constant T_RPARN
| T_AT_FORMAT_ARG T_LPARN constant T_RPARN
+ | T_AT_NON_NULL T_LPARN constant T_RPARN
| T_AT_MODE T_LPARN T_NAME T_RPARN
| T_AT_ALIAS T_LPARN string T_RPARN
| T_AT_SECTION T_LPARN string T_RPARN
diff -r f553a2912f9f -r de1920a4b66d usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l Thu Dec 29 23:50:59 2016 +0000
+++ b/usr.bin/xlint/lint1/scan.l Thu Dec 29 23:54:29 2016 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: scan.l,v 1.72 2016/12/29 19:40:35 christos Exp $ */
+/* $NetBSD: scan.l,v 1.73 2016/12/29 23:54:29 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.72 2016/12/29 19:40:35 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.73 2016/12/29 23:54:29 christos Exp $");
#endif
#include <stdlib.h>
@@ -203,132 +203,84 @@
u_int kw_c99 : 1; /* c99 keyword */
u_int kw_gcc : 1; /* GCC keyword */
u_int kw_attr : 1; /* GCC attribute, keyword */
+ u_int kw_deco : 3; /* name[1] __name[2] __name__[4] */
} kwtab[] = {
- { "__alignof__", T_ALIGNOF, 0, 0, 0, 0, 0, 0, 0 },
- { "__attribute__",T_ATTRIBUTE, 0, 0, 0, 0, 0, 1, 0 },
- { "__attribute",T_ATTRIBUTE, 0, 0, 0, 0, 0, 1, 0 },
- { "__packed__", T_AT_PACKED, 0, 0, 0, 0, 0, 1, 1 },
- { "packed", T_AT_PACKED, 0, 0, 0, 0, 0, 1, 1 },
- { "__alias__", T_AT_ALIAS, 0, 0, 0, 0, 0, 1, 1 },
- { "alias", T_AT_ALIAS, 0, 0, 0, 0, 0, 1, 1 },
- { "__aligned__",T_AT_ALIGNED, 0, 0, 0, 0, 0, 1, 1 },
- { "aligned", T_AT_ALIGNED, 0, 0, 0, 0, 0, 1, 1 },
- { "__transparent_union__",T_AT_TUNION,0,0, 0, 0, 0, 1, 1 },
- { "transparent_union",T_AT_TUNION,0, 0, 0, 0, 0, 1, 1 },
- { "__unused__", T_AT_UNUSED, 0, 0, 0, 0, 0, 1, 1 },
- { "unused", T_AT_UNUSED, 0, 0, 0, 0, 0, 1, 1 },
- { "__used__", T_AT_USED, 0, 0, 0, 0, 0, 1, 1 },
- { "used", T_AT_USED, 0, 0, 0, 0, 0, 1, 1 },
- { "__always_inline__", T_AT_ALWAYS_INLINE,
- 0, 0, 0, 0, 0, 1, 1 },
- { "always_inline", T_AT_ALWAYS_INLINE,
- 0, 0, 0, 0, 0, 1, 1 },
- { "__gnu_inline__",T_AT_GNU_INLINE,0, 0, 0, 0, 0, 1, 1 },
- { "gnu_inline", T_AT_GNU_INLINE,0, 0, 0, 0, 0, 1, 1 },
- { "__constructor__",T_AT_CONSTRUCTOR,0, 0, 0, 0, 0, 1, 1 },
- { "constructor",T_AT_CONSTRUCTOR,0, 0, 0, 0, 0, 1, 1 },
- { "__deprecated__",T_AT_DEPRECATED,0, 0, 0, 0, 0, 1, 1 },
- { "deprecated", T_AT_DEPRECATED,0, 0, 0, 0, 0, 1, 1 },
- { "__may_alias__",T_AT_MAY_ALIAS,0, 0, 0, 0, 0, 1, 1 },
- { "may_alias", T_AT_MAY_ALIAS, 0, 0, 0, 0, 0, 1, 1 },
- { "format", T_AT_FORMAT, 0, 0, 0, 0, 0, 1, 1 },
- { "__format__", T_AT_FORMAT, 0, 0, 0, 0, 0, 1, 1 },
- { "printf", T_AT_FORMAT_PRINTF,0, 0, 0, 0, 0, 1, 1 },
- { "__printf__", T_AT_FORMAT_PRINTF,0, 0, 0, 0, 0, 1, 1 },
- { "scanf", T_AT_FORMAT_SCANF,0, 0, 0, 0, 0, 1, 1 },
- { "__scanf__", T_AT_FORMAT_SCANF,0, 0, 0, 0, 0, 1, 1 },
- { "strfmon", T_AT_FORMAT_STRFMON,0, 0, 0, 0, 0, 1, 1 },
- { "__strfmon__",T_AT_FORMAT_STRFMON,0, 0, 0, 0, 0, 1, 1 },
- { "strftime", T_AT_FORMAT_STRFTIME,0, 0, 0, 0, 0, 1, 1 },
- { "__strftime__",T_AT_FORMAT_STRFTIME,0,0, 0, 0, 0, 1, 1 },
- { "pure", T_AT_PURE, 0, 0, 0, 0, 0, 1, 1 },
- { "__pure__", T_AT_PURE, 0, 0, 0, 0, 0, 1, 1 },
- { "noreturn", T_AT_NORETURN, 0, 0, 0, 0, 0, 1, 1 },
- { "__noreturn__",T_AT_NORETURN, 0, 0, 0, 0, 0, 1, 1 },
+ { "_Bool", T_TYPE, 0, BOOL, 0, 0,1,0,0,1 },
+ { "_Complex", T_TYPE, 0, COMPLEX,0, 0,1,0,0,1 },
+ { "_Generic", T_GENERIC, 0, 0, 0, 0,1,0,0,1 },
+ { "alias", T_AT_ALIAS, 0, 0, 0, 0,0,1,1,5 },
+ { "aligned", T_AT_ALIGNED, 0, 0, 0, 0,0,1,1,5 },
+ { "alignof", T_ALIGNOF, 0, 0, 0, 0,0,0,0,4 },
+ { "always_inline", T_AT_ALWAYS_INLINE, 0,0, 0, 0,0,1,1,5 },
+ { "asm", T_ASM, 0, 0, 0, 0,0,1,0,7 },
+ { "attribute", T_ATTRIBUTE, 0, 0, 0, 0,0,1,0,6 },
+ { "auto", T_SCLASS, AUTO, 0, 0, 0,0,0,0,1 },
+ { "break", T_BREAK, 0, 0, 0, 0,0,0,0,1 },
+ { "case", T_CASE, 0, 0, 0, 0,0,0,0,1 },
+ { "char", T_TYPE, 0, CHAR, 0, 0,0,0,0,1 },
+ { "cold", T_AT_COLD, 0, 0, 0, 0,0,1,1,5 },
+ { "const", T_QUAL, 0, 0, CONST, 1,0,0,0,7 },
+ { "constructor",T_AT_CONSTRUCTOR,0, 0, 0, 0,0,1,1,5 },
+ { "continue", T_CONTINUE, 0, 0, 0, 0,0,0,0,1 },
+ { "default", T_DEFAULT, 0, 0, 0, 0,0,0,0,1 },
+ { "deprecated", T_AT_DEPRECATED,0, 0, 0, 0,0,1,1,5 },
+ { "do", T_DO, 0, 0, 0, 0,0,0,0,1 },
+ { "double", T_TYPE, 0, DOUBLE, 0, 0,0,0,0,1 },
+ { "else", T_ELSE, 0, 0, 0, 0,0,0,0,1 },
+ { "enum", T_ENUM, 0, 0, 0, 0,0,0,0,1 },
+ { "extension", T_EXTENSION, 0, 0, 0, 0,0,1,0,4 },
+ { "extern", T_SCLASS, EXTERN, 0, 0, 0,0,0,0,1 },
+ { "float", T_TYPE, 0, FLOAT, 0, 0,0,0,0,1 },
+ { "for", T_FOR, 0, 0, 0, 0,0,0,0,1 },
+ { "format", T_AT_FORMAT, 0, 0, 0, 0,0,1,1,5 },
+ { "format_arg", T_AT_FORMAT_ARG,0, 0, 0, 0,0,1,1,5 },
+ { "gnu_inline", T_AT_GNU_INLINE,0, 0, 0, 0,0,1,1,5 },
+ { "goto", T_GOTO, 0, 0, 0, 0,0,0,0,1 },
+ { "if", T_IF, 0, 0, 0, 0,0,0,0,1 },
+ { "imag", T_IMAG, 0, 0, 0, 0,1,0,0,4 },
+ { "inline", T_SCLASS, INLINE, 0, 0, 0,1,0,0,7 },
+ { "int", T_TYPE, 0, INT, 0, 0,0,0,0,1 },
+ { "long", T_TYPE, 0, LONG, 0, 0,0,0,0,1 },
+ { "may_alias", T_AT_MAY_ALIAS, 0, 0, 0, 0,0,1,1,5 },
+ { "mode", T_AT_MODE, 0, 0, 0, 0,0,1,1,5 },
{ "no_instrument_function", T_AT_NO_INSTRUMENT_FUNCTION,
- 0, 0, 0, 0, 0, 1, 1 },
- { "__no_instrument_function", T_AT_NO_INSTRUMENT_FUNCTION,
- 0, 0, 0, 0, 0, 1, 1 },
- { "__no_instrument_function__", T_AT_NO_INSTRUMENT_FUNCTION,
- 0, 0, 0, 0, 0, 1, 1 },
- { "sentinel", T_AT_SENTINEL, 0, 0, 0, 0, 0, 1, 1 },
- { "__sentinel__",T_AT_SENTINEL, 0, 0, 0, 0, 0, 1, 1 },
- { "format_arg", T_AT_FORMAT_ARG,0, 0, 0, 0, 0, 1, 1 },
- { "__format_arg__", T_AT_FORMAT_ARG,0, 0, 0, 0, 0, 1, 1 },
- { "returns_twice", T_AT_RETURNS_TWICE,0,0, 0, 0, 0, 1, 1 },
- { "__returns_twice__", T_AT_RETURNS_TWICE,0,0, 0, 0, 0, 1, 1 },
- { "cold", T_AT_COLD, 0, 0, 0, 0, 0, 1, 1 },
- { "__cold__", T_AT_COLD, 0, 0, 0, 0, 0, 1, 1 },
- { "asm", T_ASM, 0, 0, 0, 0, 0, 1, 0 },
- { "__asm", T_ASM, 0, 0, 0, 0, 0, 0, 0 },
- { "__asm__", T_ASM, 0, 0, 0, 0, 0, 0, 0 },
- { "auto", T_SCLASS, AUTO, 0, 0, 0, 0, 0, 0 },
- { "break", T_BREAK, 0, 0, 0, 0, 0, 0, 0 },
- { "_Bool", T_TYPE, 0, BOOL, 0, 0, 1, 0, 0 },
- { "case", T_CASE, 0, 0, 0, 0, 0, 0, 0 },
- { "char", T_TYPE, 0, CHAR, 0, 0, 0, 0, 0 },
- { "const", T_QUAL, 0, 0, CONST, 1, 0, 0, 0 },
- { "_Complex", T_TYPE, 0, COMPLEX,0, 0, 1, 0, 0 },
- { "__const__", T_QUAL, 0, 0, CONST, 0, 0, 0, 0 },
- { "__const", T_QUAL, 0, 0, CONST, 0, 0, 0, 0 },
- { "continue", T_CONTINUE, 0, 0, 0, 0, 0, 0, 0 },
- { "default", T_DEFAULT, 0, 0, 0, 0, 0, 0, 0 },
- { "do", T_DO, 0, 0, 0, 0, 0, 0, 0 },
- { "double", T_TYPE, 0, DOUBLE, 0, 0, 0, 0, 0 },
- { "else", T_ELSE, 0, 0, 0, 0, 0, 0, 0 },
- { "enum", T_ENUM, 0, 0, 0, 0, 0, 0, 0 },
- { "__extension__", T_EXTENSION, 0, 0, 0, 0, 0, 1, 0 },
- { "extern", T_SCLASS, EXTERN, 0, 0, 0, 0, 0, 0 },
- { "float", T_TYPE, 0, FLOAT, 0, 0, 0, 0, 0 },
- { "for", T_FOR, 0, 0, 0, 0, 0, 0, 0 },
- { "_Generic", T_GENERIC, 0, 0, 0, 0, 1, 0, 0 },
- { "goto", T_GOTO, 0, 0, 0, 0, 0, 0, 0 },
- { "if", T_IF, 0, 0, 0, 0, 0, 0, 0 },
- { "__imag__", T_IMAG, 0, 0, 0, 0, 1, 0, 0 },
- { "inline", T_SCLASS, INLINE, 0, 0, 0, 1, 0, 0 },
- { "__inline__", T_SCLASS, INLINE, 0, 0, 0, 0, 0, 0 },
- { "__inline", T_SCLASS, INLINE, 0, 0, 0, 0, 0, 0 },
- { "int", T_TYPE, 0, INT, 0, 0, 0, 0, 0 },
- { "__symbolrename", T_SYMBOLRENAME, 0, 0, 0, 0, 0, 0, 0 },
- { "long", T_TYPE, 0, LONG, 0, 0, 0, 0, 0 },
- { "mode", T_AT_MODE, 0, 0, 0, 0, 0, 1, 1 },
- { "__mode", T_AT_MODE, 0, 0, 0, 0, 0, 1, 1 },
- { "__mode__", T_AT_MODE, 0, 0, 0, 0, 0, 1, 1 },
- { "__real__", T_REAL, 0, 0, 0, 0, 1, 0, 0 },
- { "register", T_SCLASS, REG, 0, 0, 0, 0, 0, 0 },
- { "__restrict__",T_QUAL, 0, 0, RESTRICT, 0, 1, 0, 0 },
- { "restrict", T_QUAL, 0, 0, RESTRICT, 0, 1, 0, 0 },
- { "return", T_RETURN, 0, 0, 0, 0, 0, 0, 0 },
- { "__packed", T_PACKED, 0, 0, 0, 0, 0, 0, 0 },
- { "section", T_AT_SECTION, 0, 0, 0, 0, 0, 1, 1 },
- { "__section", T_AT_SECTION, 0, 0, 0, 0, 0, 1, 1 },
- { "__section__",T_AT_SECTION, 0, 0, 0, 0, 0, 1, 1 },
- { "short", T_TYPE, 0, SHORT, 0, 0, 0, 0, 0 },
- { "signed", T_TYPE, 0, SIGNED, 0, 1, 0, 0, 0 },
- { "__signed__", T_TYPE, 0, SIGNED, 0, 0, 0, 0, 0 },
- { "__signed", T_TYPE, 0, SIGNED, 0, 0, 0, 0, 0 },
- { "sizeof", T_SIZEOF, 0, 0, 0, 0, 0, 0, 0 },
- { "static", T_SCLASS, STATIC, 0, 0, 0, 0, 0, 0 },
- { "struct", T_SOU, 0, STRUCT, 0, 0, 0, 0, 0 },
- { "switch", T_SWITCH, 0, 0, 0, 0, 0, 0, 0 },
- { "typedef", T_SCLASS, TYPEDEF, 0, 0, 0, 0, 0, 0 },
- { "typeof", T_TYPEOF, 0, 0, 0, 0, 0, 1, 0 },
- { "__typeof", T_TYPEOF, 0, 0, 0, 0, 0, 1, 0 },
- { "__typeof__", T_TYPEOF, 0, 0, 0, 0, 0, 1, 0 },
- { "union", T_SOU, 0, UNION, 0, 0, 0, 0, 0 },
- { "unsigned", T_TYPE, 0, UNSIGN, 0, 0, 0, 0, 0 },
- { "void", T_TYPE, 0, VOID, 0, 0, 0, 0, 0 },
- { "volatile", T_QUAL, 0, 0, VOLATILE, 1, 0, 0, 0 },
- { "__volatile__", T_QUAL, 0, 0, VOLATILE, 0, 0, 0, 0 },
- { "__volatile", T_QUAL, 0, 0, VOLATILE, 0, 0, 0, 0 },
- { "visibility", T_AT_VISIBILITY,0, 0, 0, 0, 0, 1, 1 },
- { "__visibility",T_AT_VISIBILITY,0, 0, 0, 0, 0, 1, 1 },
- { "__visibility__",T_AT_VISIBILITY,0, 0, 0, 0, 0, 1, 1 },
- { "weak", T_AT_WEAK, 0, 0, 0, 0, 0, 1, 1 },
- { "__weak", T_AT_WEAK, 0, 0, 0, 0, 0, 1, 1 },
- { "__weak__", T_AT_WEAK, 0, 0, 0, 0, 0, 1, 1 },
- { "while", T_WHILE, 0, 0, 0, 0, 0, 0, 0 },
- { NULL, 0, 0, 0, 0, 0, 0, 0, 0 }
+ 0, 0, 0, 0,0,1,1,5 },
+ { "non_null", T_AT_NON_NULL, 0, 0, 0, 0,0,1,1,5 },
+ { "noreturn", T_AT_NORETURN, 0, 0, 0, 0,0,1,1,5 },
+ { "packed", T_AT_PACKED, 0, 0, 0, 0,0,1,1,5 },
+ { "packed", T_PACKED, 0, 0, 0, 0,0,0,0,2 },
+ { "printf", T_AT_FORMAT_PRINTF,0, 0, 0, 0,0,1,1,5 },
+ { "pure", T_AT_PURE, 0, 0, 0, 0,0,1,1,5 },
+ { "real", T_REAL, 0, 0, 0, 0,1,0,0,4 },
+ { "register", T_SCLASS, REG, 0, 0, 0,0,0,0,1 },
+ { "restrict", T_QUAL, 0, 0, RESTRICT, 0,1,0,0,5 },
+ { "return", T_RETURN, 0, 0, 0, 0,0,0,0,1 },
+ { "returns_twice", T_AT_RETURNS_TWICE,0,0, 0, 0,0,1,1,5 },
+ { "scanf", T_AT_FORMAT_SCANF,0, 0, 0, 0,0,1,1,5 },
+ { "section", T_AT_SECTION, 0, 0, 0, 0,0,1,1,7 },
+ { "sentinel", T_AT_SENTINEL, 0, 0, 0, 0,0,1,1,5 },
+ { "short", T_TYPE, 0, SHORT, 0, 0,0,0,0,1 },
+ { "signed", T_TYPE, 0, SIGNED, 0, 1,0,0,0,3 },
+ { "sizeof", T_SIZEOF, 0, 0, 0, 0,0,0,0,1 },
+ { "static", T_SCLASS, STATIC, 0, 0, 0,0,0,0,1 },
+ { "strfmon", T_AT_FORMAT_STRFMON,0, 0, 0, 0,0,1,1,5 },
+ { "strftime", T_AT_FORMAT_STRFTIME,0, 0, 0, 0,0,1,1,5 },
+ { "struct", T_SOU, 0, STRUCT, 0, 0,0,0,0,1 },
+ { "switch", T_SWITCH, 0, 0, 0, 0,0,0,0,1 },
+ { "symbolrename", T_SYMBOLRENAME, 0, 0, 0, 0,0,0,0,2 },
+ { "transparent_union",T_AT_TUNION,0, 0, 0, 0,0,1,1,5 },
+ { "typedef", T_SCLASS, TYPEDEF, 0, 0, 0,0,0,0,1 },
+ { "typeof", T_TYPEOF, 0, 0, 0, 0,0,1,0,5 },
+ { "union", T_SOU, 0, UNION, 0, 0,0,0,0,1 },
+ { "unsigned", T_TYPE, 0, UNSIGN, 0, 0,0,0,0,1 },
+ { "unused", T_AT_UNUSED, 0, 0, 0, 0,0,1,1,5 },
+ { "used", T_AT_USED, 0, 0, 0, 0,0,1,1,5 },
+ { "visibility", T_AT_VISIBILITY,0, 0, 0, 0,0,1,1,5 },
+ { "void", T_TYPE, 0, VOID, 0, 0,0,0,0,1 },
+ { "volatile", T_QUAL, 0, 0, VOLATILE, 1,0,0,0,7 },
+ { "weak", T_AT_WEAK, 0, 0, 0, 0,0,1,1,5 },
+ { "while", T_WHILE, 0, 0, 0, 0,0,0,0,1 },
+ { NULL, 0, 0, 0, 0, 0,0,0,0,0 }
};
/* Symbol table */
@@ -350,6 +302,54 @@
symt_t symtyp;
+static void
+addkw(struct kwtab *kw, int deco)
+{
+ sym_t *sym;
+ size_t h;
+ char buf[256];
+ const char *name;
+
+ if (!(kw->kw_deco & deco))
+ return;
+
+ switch (deco) {
+ case 1:
+ name = kw->kw_name;
+ break;
+ case 2:
+ snprintf(buf, sizeof(buf), "__%s", kw->kw_name);
+ name = strdup(buf);
+ break;
+ case 4:
+ snprintf(buf, sizeof(buf), "__%s__", kw->kw_name);
+ name = strdup(buf);
+ break;
+ default:
+ abort();
+ }
+
+ if (name == NULL)
+ err(1, "Can't init symbol table");
+
+ sym = getblk(sizeof (sym_t));
+ sym->s_name = name;
+ sym->s_keyw = kw;
Home |
Main Index |
Thread Index |
Old Index