Patchwork C++ PATCH for undeclared enum regression

login
register
mail settings
Submitter Jason Merrill
Date Feb. 6, 2013, 8:55 p.m.
Message ID <5112C352.9010604@redhat.com>
Download mbox | patch
Permalink /patch/218747/
State New
Headers show

Comments

Jason Merrill - Feb. 6, 2013, 8:55 p.m.
Since the patch to add C++11 opaque enum declarations went in, we 
haven't been giving a diagnostic about defining a nested enum that was 
never declared.

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

Patch

commit fc9c83ce083e197c17ad7377431ff219e43d7eff
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Feb 6 15:06:30 2013 -0500

    	* parser.c (cp_parser_enum_specifier): Check for error_mark_node.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 74db9ae..72da561 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14567,7 +14567,7 @@  cp_parser_enum_specifier (cp_parser* parser)
 				     /*check_dependency=*/true,
 				     /*ambiguous_decls=*/NULL,
 				     input_location);
-      if (name)
+      if (name && name != error_mark_node)
 	{
 	  type = TREE_TYPE (name);
 	  if (TREE_CODE (type) == TYPENAME_TYPE)
diff --git a/gcc/testsuite/g++.dg/parse/enum10.C b/gcc/testsuite/g++.dg/parse/enum10.C
new file mode 100644
index 0000000..8760597
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/enum10.C
@@ -0,0 +1,2 @@ 
+namespace A { }
+enum A::B { };			// { dg-error "" }