From 45a29025db259d111bcb5093ddda1ef4ef416a19 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Thu, 5 Jan 2012 23:00:14 +0000 Subject: [PATCH] PR c++/51541 - ICE with invalid identifier in alias-declaration gcc/cp/ PR c++/51541 * parser.c (cp_parser_alias_declaration): Get out early upon errors in the identifier or the attributes. gcc/testsuite/ PR c++/51541 * g++.dg/cpp0x/alias-decl-18.C: New test. From-SVN: r182935 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C | 9 +++++++++ 4 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d889d2921ac..e6ea3bf119b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-01-05 Dodji Seketeli + + PR c++/51541 + * parser.c (cp_parser_alias_declaration): Get out early upon + errors in the identifier or the attributes. + 2012-01-04 Paolo Carlini PR c++/51064 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8f2357e64a0..0ae55a25090 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15046,7 +15046,13 @@ cp_parser_alias_declaration (cp_parser* parser) cp_parser_require_keyword (parser, RID_USING, RT_USING); id_location = cp_lexer_peek_token (parser->lexer)->location; id = cp_parser_identifier (parser); + if (id == error_mark_node) + return error_mark_node; + attributes = cp_parser_attributes_opt (parser); + if (attributes == error_mark_node) + return error_mark_node; + cp_parser_require (parser, CPP_EQ, RT_EQ); /* Now we are going to parse the type-id of the declaration. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5fdcd1189d3..59800669f09 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-01-05 Dodji Seketeli + + PR c++/51541 + * g++.dg/cpp0x/alias-decl-18.C: New test. + 2012-01-05 Eric Botcazou diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C new file mode 100644 index 00000000000..ba655613117 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C @@ -0,0 +1,9 @@ +// Origin: PR c++/51541 +// { dg-options -std=c++11 } + +template using ::T = void(int n); // { dg-error "" } +template using operator int = void(int n); // { dg-error "" } +template using typename U = void; // { dg-error "" } +template using typename ::V = void(int n); // { dg-error "" } +template using typename ::operator bool = void(int n); // { dg-error "" } +using foo __attribute__((aligned(4)) = int; // { dg-error "" } -- 2.30.2