commit bfabb2dff84a409cf856cda7959ff4395f073d8b
Author: Jason Merrill <jason@redhat.com>
Date: Wed Apr 13 11:43:59 2016 -0400
PR c++/70627
* decl.c (start_enum): Don't change an existing ENUM_UNDERLYING_TYPE.
@@ -13257,7 +13257,10 @@ start_enum (tree name, tree enumtype, tree underlying_type,
if (underlying_type)
{
- if (CP_INTEGRAL_TYPE_P (underlying_type))
+ if (ENUM_UNDERLYING_TYPE (enumtype))
+ /* We already checked that it matches, don't change it to a different
+ typedef variant. */;
+ else if (CP_INTEGRAL_TYPE_P (underlying_type))
{
copy_type_enum (enumtype, underlying_type);
ENUM_UNDERLYING_TYPE (enumtype) = underlying_type;
new file mode 100644
@@ -0,0 +1,29 @@
+// PR c++/70627
+// { dg-do compile { target c++11 } }
+
+struct D;
+struct A
+{
+ D *operator->();
+};
+struct B
+{
+ template <typename... T> void foo (T &&...) {}
+};
+typedef unsigned char G;
+enum class H : G;
+struct C
+{
+};
+struct D : C
+{
+ B foo () const { B a; a.foo (d); }
+ H d;
+};
+struct F : C
+{
+ void foo ();
+ A f;
+};
+enum class H : unsigned char;
+void F::foo () { B b = f->foo (); }