Handle __attribute__((unused)).
authorChristoph Mallon <christoph.mallon@gmx.de>
Sat, 23 Aug 2008 08:02:32 +0000 (08:02 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sat, 23 Aug 2008 08:02:32 +0000 (08:02 +0000)
[r21373]

ast_t.h
parser.c

diff --git a/ast_t.h b/ast_t.h
index a2efa32..614dd06 100644 (file)
--- a/ast_t.h
+++ b/ast_t.h
@@ -528,11 +528,12 @@ typedef enum decl_modifier_t {
        DM_PURE              = 1 << 15,
        DM_CONSTRUCTOR       = 1 << 16,
        DM_DESTRUCTOR        = 1 << 17,
-       DM_USED              = 1 << 18,
-       DM_CDECL             = 1 << 19,
-       DM_FASTCALL          = 1 << 20,
-       DM_STDCALL           = 1 << 21,
-       DM_THISCALL          = 1 << 22
+       DM_UNUSED            = 1 << 18,
+       DM_USED              = 1 << 19,
+       DM_CDECL             = 1 << 20,
+       DM_FASTCALL          = 1 << 21,
+       DM_STDCALL           = 1 << 22,
+       DM_THISCALL          = 1 << 23
 } decl_modifier_t;
 
 typedef unsigned decl_modifiers_t;
index 116a8af..6acc5c6 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1580,7 +1580,6 @@ static decl_modifiers_t parse_gnu_attribute(gnu_attribute_t **attributes)
                                case GNU_AK_NOCOMMON:
                                case GNU_AK_SHARED:
                                case GNU_AK_NOTSHARED:
-                               case GNU_AK_UNUSED:
                                case GNU_AK_NO_INSTRUMENT_FUNCTION:
                                case GNU_AK_WARN_UNUSED_RESULT:
                                case GNU_AK_LONGCALL:
@@ -1609,6 +1608,7 @@ static decl_modifiers_t parse_gnu_attribute(gnu_attribute_t **attributes)
                                case GNU_AK_CDECL:             modifiers |= DM_CDECL;             goto no_arg;
                                case GNU_AK_FASTCALL:          modifiers |= DM_FASTCALL;          goto no_arg;
                                case GNU_AK_STDCALL:           modifiers |= DM_STDCALL;           goto no_arg;
+                               case GNU_AK_UNUSED:            modifiers |= DM_UNUSED;            goto no_arg;
                                case GNU_AK_USED:              modifiers |= DM_USED;              goto no_arg;
                                case GNU_AK_PURE:              modifiers |= DM_PURE;              goto no_arg;
                                case GNU_AK_ALWAYS_INLINE:     modifiers |= DM_FORCEINLINE;       goto no_arg;
@@ -8534,8 +8534,9 @@ static void check_unused_globals(void)
                return;
 
        for (const declaration_t *decl = global_scope->declarations; decl != NULL; decl = decl->next) {
-               if (decl->used                ||
-                   decl->modifiers & DM_USED ||
+               if (decl->used                  ||
+                   decl->modifiers & DM_UNUSED ||
+                   decl->modifiers & DM_USED   ||
                    decl->storage_class != STORAGE_CLASS_STATIC)
                        continue;