]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/70627
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Apr 2016 18:32:11 +0000 (18:32 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Apr 2016 18:32:11 +0000 (18:32 +0000)
* decl.c (start_enum): Don't change an existing ENUM_UNDERLYING_TYPE.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234956 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp0x/enum_base3.C [new file with mode: 0644]

index 8f1ae231521f703cb9c0bdd5ef29675d0392778f..837a58c338f1a4e014fbf3ecdd7cd536753f58d4 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/70627
+       * decl.c (start_enum): Don't change an existing ENUM_UNDERLYING_TYPE.
+
 2016-04-13  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/70635
index 2ac5c4b1fbf722a1043cc3e048d6dc1432f5c7c9..380bc79ea53292266ded6e6225315136159a7b0d 100644 (file)
@@ -13253,7 +13253,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;
diff --git a/gcc/testsuite/g++.dg/cpp0x/enum_base3.C b/gcc/testsuite/g++.dg/cpp0x/enum_base3.C
new file mode 100644 (file)
index 0000000..3cb2d6d
--- /dev/null
@@ -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 (); }