* class.c (check_bases): Ignore empty bases.
authorJason Merrill <jason@redhat.com>
Tue, 9 May 2017 20:38:03 +0000 (16:38 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 9 May 2017 20:38:03 +0000 (16:38 -0400)
From-SVN: r247816

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

index 3a12217fbf8db2392e799faf8ec46559a0adef10..7c6331826660a5399d4b2f5c5803fbb45510f97e 100644 (file)
@@ -1,5 +1,7 @@
 2017-05-09  Jason Merrill  <jason@redhat.com>
 
+       * class.c (check_bases): Ignore empty bases.
+
        PR c++/70979 - literal class and closure types
        * class.c (finalize_literal_type_property): Handle closures
        specifically.
index fc7176655398bde3fc059a380bedf5822f336e09..085dbc389d98c45c90350d9d84397e0475fb1e54 100644 (file)
@@ -1860,7 +1860,9 @@ check_bases (tree t,
               members */
            for (basefield = TYPE_FIELDS (basetype); basefield;
                 basefield = DECL_CHAIN (basefield))
-             if (TREE_CODE (basefield) == FIELD_DECL)
+             if (TREE_CODE (basefield) == FIELD_DECL
+                 && DECL_SIZE (basefield)
+                 && !integer_zerop (DECL_SIZE (basefield)))
                {
                  if (field)
                    CLASSTYPE_NON_STD_LAYOUT (t) = 1;
diff --git a/gcc/testsuite/g++.dg/ext/is_std_layout1.C b/gcc/testsuite/g++.dg/ext/is_std_layout1.C
new file mode 100644 (file)
index 0000000..007c94a
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile { target c++11 } }
+
+template <int> struct E { };
+
+struct E1: E<0>, E<1> { };
+struct E2: E<2>, E<3> { };
+
+struct A1x { int n; };
+struct D2: A1x, E1, E2 { };
+
+#define SA(X) static_assert((X),#X)
+SA(__is_standard_layout (D2));