Hello, We crash upon these alias-declarations in which the identifier part is invalid. This is because make_id_declarator is called with an error_mark_node for the identifier.
The patch below just avoids calling make_id_declarator in this case. It try to get out as early as possible to avoid the numerous diagnostic messages that add up otherwise. Bootstrapped and Tested on x86_64-unknown-linux-gnu against trunk. 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. --- gcc/cp/parser.c | 6 ++++++ gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C | 9 +++++++++ 2 files changed, 15 insertions(+), 0 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 0f5bb8e..476a773 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15034,7 +15034,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/g++.dg/cpp0x/alias-decl-18.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-18.C new file mode 100644 index 0000000..ba65561 --- /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<typename Z> using ::T = void(int n); // { dg-error "" } +template<typename Z> using operator int = void(int n); // { dg-error "" } +template<typename Z> using typename U = void; // { dg-error "" } +template<typename Z> using typename ::V = void(int n); // { dg-error "" } +template<typename Z> using typename ::operator bool = void(int n); // { dg-error "" } +using foo __attribute__((aligned(4)) = int; // { dg-error "" } -- 1.7.6.4 -- Dodji