Commit 899a1997 by Marek Polacek Committed by Marek Polacek

DR 1813 PR c++/83374 - __is_standard_layout wrong for a class with repeated bases.

	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.

	* g++.dg/ext/is_std_layout3.C: New test.
	* g++.dg/ext/is_std_layout4.C: New test.

From-SVN: r273139
parent 2bdc7dcb
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.
......
......@@ -1715,11 +1715,15 @@ check_bases (tree t,
&& (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.
......
// 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), "" );
// 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), "");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment