]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/88181 (ICE: verify_type failed (error: type variant differs by...
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:14:56 +0000 (13:14 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:14:56 +0000 (13:14 +0200)
Backported from mainline
2018-11-27  Jakub Jelinek  <jakub@redhat.com>

PR c++/88181
* class.c (fixup_attribute_variants): Also propagate TYPE_PACKED
to variants.

* g++.dg/debug/pr88181.C: New test.

From-SVN: r275071

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/pr88181.C [new file with mode: 0644]

index f9d98365517975ade889faf75000b0f15ad09156..881df4a89a69273012555c47df39eddfa487f74e 100644 (file)
@@ -1,3 +1,12 @@
+2019-08-30  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2018-11-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/88181
+       * class.c (fixup_attribute_variants): Also propagate TYPE_PACKED
+       to variants.
+
 2019-04-10  Matthias Klose  <doko@ubuntu.com>
 
        Backport from the gcc-8 branch
index 688cc0e58d33bcc473adcac18084d03cff131bc4..dbfea0ab653e5a565be7edef48b1c40ad4fdebfb 100644 (file)
@@ -2088,6 +2088,7 @@ fixup_attribute_variants (tree t)
   unsigned align = TYPE_ALIGN (t);
   bool user_align = TYPE_USER_ALIGN (t);
   bool may_alias = lookup_attribute ("may_alias", attrs);
+  bool packed = TYPE_PACKED (t);
 
   if (may_alias)
     fixup_may_alias (t);
@@ -2105,6 +2106,7 @@ fixup_attribute_variants (tree t)
       else
        TYPE_USER_ALIGN (variants) = user_align;
       SET_TYPE_ALIGN (variants, valign);
+      TYPE_PACKED (variants) = packed;
       if (may_alias)
        fixup_may_alias (variants);
     }
index 30c2257164f785a5e653c2f88a6995a1775bc96d..c90a43cd1c62e105a9e720d3e3d69ecd9d9e7d62 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-11-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/88181
+       * g++.dg/debug/pr88181.C: New test.
+
        2018-11-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/87895
diff --git a/gcc/testsuite/g++.dg/debug/pr88181.C b/gcc/testsuite/g++.dg/debug/pr88181.C
new file mode 100644 (file)
index 0000000..fc6f813
--- /dev/null
@@ -0,0 +1,29 @@
+// PR c++/88181
+// { dg-do compile }
+// { dg-options "-fpack-struct -g -std=c++11" }
+
+template <typename T> struct A { typedef T B; };
+template <typename...> class C;
+template <typename e> struct D { constexpr D (e) {} };
+template <int, typename...> struct E;
+template <int N, typename T, typename... U>
+struct E<N, T, U...> : E<1, U...>, D<T> {
+  constexpr E (T x, U... y) : E<1, U...>(y...), D<T>(x) {}
+};
+template <int N, typename T> struct E<N, T> : D<T> {
+  constexpr E (T x) : D<T>(x) {}
+};
+template <typename T, typename U> struct C<T, U> : E<0, T, U> {
+  constexpr C (T x, U y) : E<0, T, U>(x, y) {}
+  void operator= (typename A<const C>::B);
+};
+struct F {};
+struct G {};
+
+int
+main ()
+{
+  F f;
+  G g;
+  constexpr C<F, G> c(f, g);
+}