From 3bb4eb1cb3f3d41d82a46f05daba03c515be3813 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 25 Jul 2011 01:03:50 -0400 Subject: [PATCH] re PR c++/49823 ([C++0x] ICE on decltype(expr)::type with template) PR c++/49823 * parser.c (cp_parser_qualifying_entity): Handle templates. From-SVN: r176732 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parser.c | 4 +++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/decltype21.C | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 284224f57c6..a0f1f22bcdd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-07-23 Jason Merrill + + PR c++/49823 + * parser.c (cp_parser_qualifying_entity): Handle templates. + 2011-07-22 Jason Merrill PR c++/49793 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index dc54dc20d80..4e7d905627a 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -4638,7 +4638,9 @@ cp_parser_qualifying_entity (cp_parser *parser, cp_parser_simulate_error (parser); return error_mark_node; } - return TYPE_NAME (scope); + if (TYPE_NAME (scope)) + scope = TYPE_NAME (scope); + return scope; } /* Before we try to parse the class-name, we must save away the diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1d0d08952c5..9eb5de6fcd5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-07-23 Jason Merrill + + * g++.dg/cpp0x/decltype21.C: Add 49823 examples. + 2011-07-22 Jason Merrill PR c++/49793 diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype21.C b/gcc/testsuite/g++.dg/cpp0x/decltype21.C index ee73bfbc36c..733725626c3 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype21.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype21.C @@ -10,6 +10,22 @@ struct c : decltype(make

()) {}; decltype(make

())::t t; +// PR c++/49823 + +template < typename T > +auto f( const T &x ) + -> typename decltype( x )::type; // ICE on here + +template < typename T > +typename decltype( T{} )::type // ICE on here +f( T ); + +template < typename T > +void f( T x ) +{ typename decltype( x )::type t; } // ICE on here + +// Negative tests + int f(); decltype(f())::t t2; // { dg-error "not a class" } -- 2.30.2