From 32da2be4ccf3662d354e954d705b7a8e8ea5f0eb Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 28 May 2011 18:01:28 -0400 Subject: [PATCH] re PR c++/47277 ([C++0x] pseudo destructor code that cause an internal compiler error with std=gnu++0x) PR c++/47277 * parser.c (cp_parser_pseudo_destructor_name): Commit to parse after we see the ~. From-SVN: r174385 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/parser.c | 5 +++++ gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/enum18.C | 6 +++--- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 269e0d1e60f..1f39aeb8355 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-05-27 Jason Merrill + PR c++/47277 + * parser.c (cp_parser_pseudo_destructor_name): Commit to parse + after we see the ~. + * mangle.c (mangle_decl_string): Make sure we don't try to mangle templates. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a16ba89e364..75ad3f87065 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5642,6 +5642,11 @@ cp_parser_pseudo_destructor_name (cp_parser* parser, /* Look for the `~'. */ cp_parser_require (parser, CPP_COMPL, RT_COMPL); + + /* Once we see the ~, this has to be a pseudo-destructor. */ + if (!processing_template_decl && !cp_parser_error_occurred (parser)) + cp_parser_commit_to_tentative_parse (parser); + /* Look for the type-name again. We are not responsible for checking that it matches the first type-name. */ *type = cp_parser_nonclass_name (parser); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 36edc225434..8e55e4b4147 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-05-27 Jason Merrill + * g++.dg/cpp0x/enum18.C: Adjust. + * g++.dg/cpp0x/lambda/lambda-template2.C: New. 2011-05-27 Tobias Burnus diff --git a/gcc/testsuite/g++.dg/cpp0x/enum18.C b/gcc/testsuite/g++.dg/cpp0x/enum18.C index 5575ca6ce94..306ed8259f9 100644 --- a/gcc/testsuite/g++.dg/cpp0x/enum18.C +++ b/gcc/testsuite/g++.dg/cpp0x/enum18.C @@ -2,7 +2,7 @@ // { dg-options -std=c++0x } int main(void) { - enum e {}; - e ev; - ev.e::~e_u(); // { dg-error "" } + enum e {}; + e ev; + ev.e::~e_u(); // { dg-error "e_u. has not been declared" } } -- 2.30.2