add a special case for __attribute__((__const))
authorMatthias Braun <matthias.braun@kit.edu>
Wed, 18 Jul 2012 08:50:16 +0000 (10:50 +0200)
committerMatthias Braun <matthias.braun@kit.edu>
Wed, 18 Jul 2012 08:50:16 +0000 (10:50 +0200)
according to gcc documentation only "__XXX__" and "XXX" should be
allowed for attribute names, but it seems gcc incorrectly also accepts
__XXX for keywords with an __XXX variant. And of course some glibc
headers use this feature.

parser.c

index 933d059..1fc7ed3 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1176,6 +1176,12 @@ static attribute_t *parse_attribute_gnu_single(void)
        char const *const name = symbol->string;
        for (kind = ATTRIBUTE_GNU_FIRST;; ++kind) {
                if (kind > ATTRIBUTE_GNU_LAST) {
+                       /* special case for "__const" */
+                       if (token.kind == T_const) {
+                               kind = ATTRIBUTE_GNU_CONST;
+                               break;
+                       }
+
                        warningf(WARN_ATTRIBUTE, HERE, "unknown attribute '%s' ignored", name);
                        /* TODO: we should still save the attribute in the list... */
                        kind = ATTRIBUTE_UNKNOWN;