Correct off-by-one error when checking whether the end of the GNU attribute list...
authorChristoph Mallon <christoph.mallon@gmx.de>
Thu, 16 Jun 2011 13:29:40 +0000 (15:29 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Thu, 16 Jun 2011 13:29:40 +0000 (15:29 +0200)
parser.c

index 17f1a62..4fc3804 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1273,21 +1273,22 @@ static attribute_t *parse_attribute_gnu_single(void)
        next_token();
 
        attribute_kind_t kind;
-       for (kind = ATTRIBUTE_GNU_FIRST; kind <= ATTRIBUTE_GNU_LAST; ++kind) {
+       for (kind = ATTRIBUTE_GNU_FIRST;; ++kind) {
+               if (kind > ATTRIBUTE_GNU_LAST) {
+                       if (warning.attribute) {
+                               warningf(HERE, "unknown attribute '%s' ignored", name);
+                       }
+                       /* TODO: we should still save the attribute in the list... */
+                       kind = ATTRIBUTE_UNKNOWN;
+                       break;
+               }
+
                const char *attribute_name = get_attribute_name(kind);
                if (attribute_name != NULL
                                && strcmp_underscore(attribute_name, name) == 0)
                        break;
        }
 
-       if (kind >= ATTRIBUTE_GNU_LAST) {
-               if (warning.attribute) {
-                       warningf(HERE, "unknown attribute '%s' ignored", name);
-               }
-               /* TODO: we should still save the attribute in the list... */
-               kind = ATTRIBUTE_UNKNOWN;
-       }
-
        attribute_t *attribute = allocate_attribute_zero(kind);
 
        /* parse arguments */