+2019-07-04 Marek Polacek <polacek@redhat.com>
+
+ DR 1813
+ PR c++/83374 - __is_standard_layout wrong for a class with repeated bases.
+ * class.c (check_bases): Set CLASSTYPE_NON_STD_LAYOUT for a class if
+ CLASSTYPE_REPEATED_BASE_P is true.
+
2019-07-04 Andrew Stubbs <ams@codesourcery.com>
* cp-tree.h (cp_omp_emit_unmappable_type_notes): New prototype.
&& (same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (field), basetype)))
CLASSTYPE_NON_STD_LAYOUT (t) = 1;
+ /* DR 1813:
+ ...has at most one base class subobject of any given type... */
+ else if (CLASSTYPE_REPEATED_BASE_P (t))
+ CLASSTYPE_NON_STD_LAYOUT (t) = 1;
else
/* ...either has no non-static data members in the most-derived
class and at most one base class with non-static data
members, or has no base classes with non-static data
- members */
+ members. FIXME This was reworded in DR 1813. */
for (basefield = TYPE_FIELDS (basetype); basefield;
basefield = DECL_CHAIN (basefield))
if (TREE_CODE (basefield) == FIELD_DECL
+2019-07-04 Marek Polacek <polacek@redhat.com>
+
+ DR 1813
+ PR c++/83374 - __is_standard_layout wrong for a class with repeated bases.
+ * g++.dg/ext/is_std_layout3.C: New test.
+ * g++.dg/ext/is_std_layout4.C: New test.
+
2019-07-05 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/ssa-fre-77.c: New testcase.
--- /dev/null
+// DR 1813
+// PR c++/83374 - __is_standard_layout wrong for a class with repeated bases.
+// { dg-do compile { target c++11 } }
+
+struct B { int i; }; // standard-layout class
+struct C : B { }; // standard-layout class
+struct D : C { }; // standard-layout class
+struct E : D { char : 4; }; // not a standard-layout class
+static_assert( __is_standard_layout(B), "" );
+static_assert( __is_standard_layout(C), "" );
+static_assert( __is_standard_layout(D), "" );
+static_assert( ! __is_standard_layout(E), "" );
+
+struct Q {};
+struct S : Q { };
+struct T : Q { };
+struct U : S, T { }; // not a standard-layout class
+static_assert( ! __is_standard_layout(U), "" );
--- /dev/null
+// DR 1813
+// PR c++/83374 - __is_standard_layout wrong for a class with repeated bases.
+// { dg-do compile { target c++11 } }
+
+struct R { };
+struct Q { };
+struct S : R { };
+struct T : Q { };
+struct U : S, T { };
+// No repeated base class subobjects.
+static_assert(__is_standard_layout(U), "");