Patchwork C++ PATCH for c++/47277 (ICE on ill-formed enum dtor)

login
register
mail settings
Submitter Jason Merrill
Date May 27, 2011, 7:23 p.m.
Message ID <4DDFFA2A.6070502@redhat.com>
Download mbox | patch
Permalink /patch/97737/
State New
Headers show

Comments

Jason Merrill - May 27, 2011, 7:23 p.m.
Like 48935, we don't want to call constructor_name_p on non-classes.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 6e1aed3b584b9bf7bd3127d12516dd5ac5da7ba4
Author: Jason Merrill <jason@redhat.com>
Date:   Fri May 27 12:52:37 2011 -0400

    	PR c++/47277
    	* parser.c (cp_parser_unqualified_id): Don't check
    	constructor_name_p for enums.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 135ab14..a16ba89 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -4069,7 +4069,8 @@  cp_parser_unqualified_id (cp_parser* parser,
 	    && (cp_lexer_peek_nth_token (parser->lexer, 2)->type
 		!= CPP_LESS)
 	    && (token->u.value == TYPE_IDENTIFIER (scope)
-		|| constructor_name_p (token->u.value, scope)))
+		|| (CLASS_TYPE_P (scope)
+		    && constructor_name_p (token->u.value, scope))))
 	  {
 	    cp_lexer_consume_token (parser->lexer);
 	    return build_nt (BIT_NOT_EXPR, scope);
diff --git a/gcc/testsuite/g++.dg/cpp0x/enum18.C b/gcc/testsuite/g++.dg/cpp0x/enum18.C
new file mode 100644
index 0000000..5575ca6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/enum18.C
@@ -0,0 +1,8 @@ 
+// PR c++/47277
+// { dg-options -std=c++0x }
+
+int main(void) {
+           enum e {};
+           e ev;
+           ev.e::~e_u();	// { dg-error "" }
+}