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 more attributes.



details:   https://anonhg.NetBSD.org/src/rev/043e49775d2c
branches:  trunk
changeset: 349952:043e49775d2c
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Dec 29 16:41:16 2016 +0000

description:
Add more attributes.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  45 ++++++++++++++++++++++++++++++++-------------
 usr.bin/xlint/lint1/scan.l  |  24 +++++++++++++++++++++---
 2 files changed, 53 insertions(+), 16 deletions(-)

diffs (182 lines):

diff -r d0f53ec2cb5d -r 043e49775d2c usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Thu Dec 29 16:01:46 2016 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Thu Dec 29 16:41:16 2016 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.83 2016/12/29 16:01:46 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.84 2016/12/29 16:41:16 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.83 2016/12/29 16:01:46 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.84 2016/12/29 16:41:16 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -199,25 +199,31 @@
 /* Type Attributes */
 %token <y_type>                T_ATTRIBUTE
 %token <y_type>                T_AT_ALIGNED
+%token <y_type>                T_AT_COLD
+%token <y_type>                T_AT_CONSTRUCTOR
 %token <y_type>                T_AT_DEPRECATED
-%token <y_type>                T_AT_NORETURN
+%token <y_type>                T_AT_FORMAT
+%token <y_type>                T_AT_FORMAT_ARG
+%token <y_type>                T_AT_FORMAT_PRINTF
+%token <y_type>                T_AT_FORMAT_SCANF
+%token <y_type>                T_AT_FORMAT_STRFTIME
+%token <y_type>                T_AT_FORMAT_STRFMON
 %token <y_type>                T_AT_GNU_INLINE
 %token <y_type>                T_AT_MAY_ALIAS
+%token <y_type>                T_AT_MODE
+%token <y_type>                T_AT_NORETURN
+%token <y_type>                T_AT_NO_INSTRUMENT_FUNCTION
 %token <y_type>                T_AT_PACKED
 %token <y_type>                T_AT_PURE
+%token <y_type>                T_AT_RETURNS_TWICE
+%token <y_type>                T_AT_SECTION
+%token <y_type>                T_AT_SENTINEL
 %token <y_type>                T_AT_TUINION
 %token <y_type>                T_AT_TUNION
 %token <y_type>                T_AT_UNUSED
-%token <y_type>                T_AT_WEAK
+%token <y_type>                T_AT_USED
 %token <y_type>                T_AT_VISIBILITY
-%token <y_type>                T_AT_FORMAT
-%token <y_type>                T_AT_FORMAT_PRINTF
-%token <y_type>                T_AT_FORMAT_SCANF
-%token <y_type>                T_AT_FORMAT_STRFTIME
-%token <y_type>                T_AT_FORMAT_ARG
-%token <y_type>                T_AT_SENTINEL
-%token <y_type>                T_AT_RETURNS_TWICE
-%token <y_type>                T_AT_COLD
+%token <y_type>                T_AT_WEAK
 
 %left  T_COMMA
 %right T_ASSIGN T_OPASS
@@ -496,6 +502,7 @@
 type_attribute_format_type:
          T_AT_FORMAT_PRINTF
        | T_AT_FORMAT_SCANF
+       | T_AT_FORMAT_STRFMON
        | T_AT_FORMAT_STRFTIME
        ;
 
@@ -504,8 +511,12 @@
        | 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_MODE T_LPARN T_NAME T_RPARN
+       | T_AT_SECTION T_LPARN string T_RPARN
        | T_AT_ALIGNED 
+       | T_AT_CONSTRUCTOR 
        | T_AT_MAY_ALIAS
+       | T_AT_NO_INSTRUMENT_FUNCTION
        | T_AT_NORETURN
        | T_AT_COLD
        | T_AT_RETURNS_TWICE
@@ -517,6 +528,9 @@
        | T_AT_GNU_INLINE
        | T_AT_FORMAT T_LPARN type_attribute_format_type T_COMMA
            constant T_COMMA constant T_RPARN
+       | T_AT_USED {
+               addused();
+       }
        | T_AT_UNUSED {
                addused();
        }
@@ -528,10 +542,15 @@
        }
        ;
 
+type_attribute_spec_list:
+         type_attribute_spec
+       | type_attribute_spec_list T_COMMA type_attribute_spec
+       ;
+
 type_attribute:
          T_ATTRIBUTE T_LPARN T_LPARN {
            attron = 1;
-       } type_attribute_spec {
+       } type_attribute_spec_list {
            attron = 0;
        } T_RPARN T_RPARN
        | T_PACKED {
diff -r d0f53ec2cb5d -r 043e49775d2c usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Thu Dec 29 16:01:46 2016 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Thu Dec 29 16:41:16 2016 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.68 2016/12/24 17:43:45 christos Exp $ */
+/* $NetBSD: scan.l,v 1.69 2016/12/29 16:41:16 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.68 2016/12/24 17:43:45 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.69 2016/12/29 16:41:16 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -215,8 +215,12 @@
        { "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 },
        { "__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 },
@@ -227,12 +231,20 @@
        { "__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 },
-       { "strftime",   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 },
+       { "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 },
@@ -273,12 +285,18 @@
        { "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 },



Home | Main Index | Thread Index | Old Index