[C++ PATCH] Fix error-recovery for scoped enum templates (PR c++/38637)
Jakub Jelinek
jakub@redhat.com
Sat Dec 27 15:41:00 GMT 2008
Hi!
Neither SET_SCOPED_ENUM_P, nor ENUM_UNDERLYING_TYPE etc. apply well to
error_mark_node, which can be returned e.g. from pushtag. The following
patch fixes it by returning early if enumtype is error_mark_node.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2008-12-27 Jakub Jelinek <jakub@redhat.com>
PR c++/38637
* decl.c (start_enum): If enumtype is error_mark_node, exit early.
* g++.dg/cpp0x/enum2.C: New test.
--- gcc/cp/decl.c.jj 2008-12-19 10:19:10.000000000 +0100
+++ gcc/cp/decl.c 2008-12-27 10:19:00.000000000 +0100
@@ -10891,6 +10891,9 @@ start_enum (tree name, tree underlying_t
enumtype = pushtag (name, enumtype, /*tag_scope=*/ts_current);
}
+ if (enumtype == error_mark_node)
+ return enumtype;
+
if (scoped_enum_p)
{
SET_SCOPED_ENUM_P (enumtype, 1);
--- gcc/testsuite/g++.dg/cpp0x/enum2.C.jj 2008-12-27 10:21:51.000000000 +0100
+++ gcc/testsuite/g++.dg/cpp0x/enum2.C 2008-12-27 10:21:11.000000000 +0100
@@ -0,0 +1,5 @@
+// PR c++/38637
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+template<int> enum E : int { e }; // { dg-error "template declaration of" }
Jakub
More information about the Gcc-patches
mailing list