commit b01c647f6754097ac85e4ca1d7c80c1da8edc660
Author: Jason Merrill <jason@redhat.com>
Date: Sat Dec 17 09:30:43 2011 -0500
PR c++/51587
* decl.c (start_enum): Avoid using ENUM_UNDERLYING_TYPE on a
non-enum.
@@ -12069,6 +12069,7 @@ start_enum (tree name, tree enumtype, tree underlying_type,
/* Do not push the decl more than once, unless we need to
compare underlying types at instantiation time */
if (!enumtype
+ || TREE_CODE (enumtype) != ENUMERAL_TYPE
|| (underlying_type
&& dependent_type_p (underlying_type))
|| (ENUM_UNDERLYING_TYPE (enumtype)
new file mode 100644
@@ -0,0 +1,8 @@
+// PR c++/51587
+
+namespace N
+{
+ struct X; // { dg-message "previous declaration" }
+}
+
+enum N::X {}; // { dg-error "conflicting declaration" }