OSDN Git Service

PR c++/28112
authorreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 23 Jun 2006 17:02:38 +0000 (17:02 +0000)
committerreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 23 Jun 2006 17:02:38 +0000 (17:02 +0000)
* parser.c (cp_parser_attribute_list): Skip attributes with invalid
arguments.  Fix comment.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114941 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 2f726bd..76ed3a0 100644 (file)
@@ -1,5 +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.
+
        PR c++/11468
        * init.c (build_new_1): Handle error_mark_nodes returned by
        build_java_class_ref.
index 5820cb7..deb36fe 100644 (file)
@@ -14614,6 +14614,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);
 
@@ -14627,18 +14629,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 cadfeef..70264d9 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  Olivier Hainque  <hainque@adacore.com>
 
        * gnat.dg/varsize_temp.adb: New test.
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" }