From 50ac1a972fcb5755b5e48b254933d87a6d42ba96 Mon Sep 17 00:00:00 2001 From: Volker Reichelt Date: Fri, 23 Jun 2006 17:10:11 +0000 Subject: [PATCH] re PR c++/28112 (ICE with invalid argument in attribute) 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 | 6 ++++++ gcc/cp/parser.c | 21 ++++++++++++--------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/attrib23.C | 11 +++++++++++ 4 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/attrib23.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index babd05421474..572286e10207 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-06-23 Volker Reichelt + + PR c++/28112 + * parser.c (cp_parser_attribute_list): Skip attributes with invalid + arguments. Fix comment. + 2006-06-22 Volker Reichelt PR c++/28109 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7eb05e8316c1..4e171899a74f 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8407c2f6eb73..fe73ad4ac9a0 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 Richard Guenther 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 index 000000000000..0a2c58689e25 --- /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.47.2