]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/28112 (ICE with invalid argument in attribute)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Fri, 23 Jun 2006 17:10:11 +0000 (17:10 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Fri, 23 Jun 2006 17:10:11 +0000 (17:10 +0000)
PR c++/28112
* parser.c (cp_parser_attribute_list): Skip attributes with invalid
arguments.  Fix comment.

* g++.dg/ext/attrib23.C: New test.

From-SVN: r114943

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/attrib23.C [new file with mode: 0644]

index babd054214743877eed46136ac03005ece8fc306..572286e1020704a35bc0e1616f886d8878faf47e 100644 (file)
@@ -1,3 +1,9 @@
+2006-06-23  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/28112
+       * parser.c (cp_parser_attribute_list): Skip attributes with invalid
+       arguments.  Fix comment.
+
 2006-06-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/28109
index 7eb05e8316c1a9edffa8dd40b45e6d452706528f..4e171899a74f20a23bb8d4ef05e1337307fd242f 100644 (file)
@@ -14289,6 +14289,8 @@ cp_parser_attribute_list (cp_parser* parser)
       if (token->type == CPP_NAME
          || token->type == CPP_KEYWORD)
        {
+         tree arguments = NULL_TREE;
+
          /* Consume the token.  */
          token = cp_lexer_consume_token (parser->lexer);
 
@@ -14302,18 +14304,19 @@ cp_parser_attribute_list (cp_parser* parser)
          /* If it's an `(', then parse the attribute arguments.  */
          if (token->type == CPP_OPEN_PAREN)
            {
-             tree arguments;
-
-             arguments = (cp_parser_parenthesized_expression_list
-                          (parser, true, /*cast_p=*/false, 
-                           /*non_constant_p=*/NULL));
-             /* Save the identifier and arguments away.  */
+             arguments = cp_parser_parenthesized_expression_list
+                         (parser, true, /*cast_p=*/false,
+                          /*non_constant_p=*/NULL);
+             /* Save the arguments away.  */
              TREE_VALUE (attribute) = arguments;
            }
 
-         /* Add this attribute to the list.  */
-         TREE_CHAIN (attribute) = attribute_list;
-         attribute_list = attribute;
+         if (arguments != error_mark_node)
+           {
+             /* Add this attribute to the list.  */
+             TREE_CHAIN (attribute) = attribute_list;
+             attribute_list = attribute;
+           }
 
          token = cp_lexer_peek_token (parser->lexer);
        }
index 8407c2f6eb73f296fcf00c72a283946088023e80..fe73ad4ac9a0cdc732c446d57d25cf2273fb0807 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-23  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/28112
+       * g++.dg/ext/attrib23.C: New test.
+
 2006-06-23  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/28045
diff --git a/gcc/testsuite/g++.dg/ext/attrib23.C b/gcc/testsuite/g++.dg/ext/attrib23.C
new file mode 100644 (file)
index 0000000..0a2c586
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/28112
+// { dg-do compile }
+
+int i       __attribute__((init_priority(;)));  // { dg-error "before" }
+int j       __attribute__((vector_size(;)));    // { dg-error "before" }
+int k       __attribute__((visibility(;)));     // { dg-error "before" }
+struct A {} __attribute__((aligned(;)));        // { dg-error "before" }
+struct B {} __attribute__((mode(;)));           // { dg-error "before" }
+void foo()  __attribute__((alias(;)));          // { dg-error "before" }
+void bar()  __attribute__((nonnull(;)));        // { dg-error "before" }
+void baz()  __attribute__((section(;)));        // { dg-error "before" }