Improve error recovery in parse_attribute_gnu().
authorChristoph Mallon <christoph.mallon@gmx.de>
Fri, 27 Apr 2012 09:16:02 +0000 (11:16 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Fri, 27 Apr 2012 15:42:02 +0000 (17:42 +0200)
parser.c

index 0e22703..4362a81 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1242,14 +1242,18 @@ static attribute_t *parse_attribute_gnu(void)
        expect('(', end_error);
        expect('(', end_error);
 
+       add_anchor_token(')');
+       add_anchor_token(',');
        if (token.kind != ')') do {
                attribute_t *attribute = parse_attribute_gnu_single();
-               if (attribute == NULL)
-                       goto end_error;
-
-               *anchor = attribute;
-               anchor  = &attribute->next;
+               if (attribute) {
+                       *anchor = attribute;
+                       anchor  = &attribute->next;
+               }
        } while (next_if(','));
+       rem_anchor_token(',');
+       rem_anchor_token(')');
+
        expect(')', end_error);
        expect(')', end_error);