From 67f018391792e1ff69256f21742e9b2fe4c75ef8 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 5 Jun 2013 17:29:21 +0000 Subject: [PATCH] re PR c++/51908 ([C++11] ICE in cp_parser_abort_tentative_parse with decltype and variable template arguments) /cp 2013-06-05 Paolo Carlini PR c++/51908 * parser.c (cp_parser_postfix_expression [RID_*CAST]): Set parser->in_type_id_in_expr_p before calling cp_parser_type_id. /testsuite 2013-06-05 Paolo Carlini PR c++/51908 * g++.dg/cpp0x/decltype54.C: New. From-SVN: r199707 --- gcc/cp/ChangeLog | 8 +++++++- gcc/cp/parser.c | 4 ++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/decltype54.C | 26 +++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype54.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4698a183448..f8bacf5d42b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,6 +1,12 @@ +2013-06-05 Paolo Carlini + + PR c++/51908 + * parser.c (cp_parser_postfix_expression [RID_*CAST]): Set + parser->in_type_id_in_expr_p before calling cp_parser_type_id. + 2013-06-03 Jan Hubicka - * decl2.c (maybe_make_one_only): Use forced_by_abi instad of + * decl2.c (maybe_make_one_only): Use forced_by_abi instead of mark_decl_referenced. (mark_needed): Likewise. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 061b5714790..dfeeb0a94c2 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5546,6 +5546,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, tree type; tree expression; const char *saved_message; + bool saved_in_type_id_in_expr_p; /* All of these can be handled in the same way from the point of view of parsing. Begin by consuming the token @@ -5560,7 +5561,10 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, /* Look for the opening `<'. */ cp_parser_require (parser, CPP_LESS, RT_LESS); /* Parse the type to which we are casting. */ + saved_in_type_id_in_expr_p = parser->in_type_id_in_expr_p; + parser->in_type_id_in_expr_p = true; type = cp_parser_type_id (parser); + parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p; /* Look for the closing `>'. */ cp_parser_require (parser, CPP_GREATER, RT_GREATER); /* Restore the old message. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2985cb61966..f214b588a88 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-06-05 Paolo Carlini + + PR c++/51908 + * g++.dg/cpp0x/decltype54.C: New. + 2013-06-05 James Greenhalgh * gcc.dg/fshort-wchar.c: Add extra dg-options for diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype54.C b/gcc/testsuite/g++.dg/cpp0x/decltype54.C new file mode 100644 index 00000000000..9d301c0a739 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype54.C @@ -0,0 +1,26 @@ +// PR c++/51908 +// { dg-do compile { target c++11 } } + +struct foo1 +{ + template + operator decltype(static_cast(nullptr)) () const; +}; + +struct foo2 +{ + template + operator decltype(static_cast(nullptr)) () const; +}; + +struct foo3 +{ + template + operator decltype(static_cast(nullptr)) () const; +}; + +struct foo4 +{ + template + operator decltype(static_cast(nullptr)) () const; +}; -- 2.30.2