From ce601f92b93da71f8891c021a298a84c2e901301 Mon Sep 17 00:00:00 2001 From: reichelt Date: Fri, 23 Jun 2006 17:02:38 +0000 Subject: [PATCH] PR c++/28112 * 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 | 4 ++++ gcc/cp/parser.c | 21 ++++++++++++--------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/attrib23.C | 11 +++++++++++ 4 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/attrib23.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2f726bdf8ed..76ed3a0abba 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2006-06-23 Volker Reichelt + 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. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5820cb74a03..deb36fe9e52 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cadfeef986d..70264d94545 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-06-23 Volker Reichelt + + PR c++/28112 + * g++.dg/ext/attrib23.C: New test. + 2006-06-23 Olivier Hainque * 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 index 00000000000..0a2c58689e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib23.C @@ -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" } -- 2.11.4.GIT