Commit 686dca76 by Jakub Jelinek Committed by Jakub Jelinek

P1008R1 - prohibit aggregates with user-declared constructors

	P1008R1 - prohibit aggregates with user-declared constructors
	* class.c (check_bases_and_members): For C++2a set
	CLASSTYPE_NON_AGGREGATE based on TYPE_HAS_USER_CONSTRUCTOR rather than
	type_has_user_provided_or_explicit_constructor.

	* g++.dg/ext/is_aggregate.C: Add tests with deleted or defaulted ctor.
	* g++.dg/cpp0x/defaulted1.C (main): Ifdef out for C++2a B b = {1};.
	* g++.dg/cpp0x/deleted2.C: Expect error for C++2a.
	* g++.dg/cpp2a/aggr1.C: New test.
	* g++.dg/cpp2a/aggr2.C: New test.

From-SVN: r263115
parent 8810325f
2018-07-31 Jakub Jelinek <jakub@redhat.com>
P1008R1 - prohibit aggregates with user-declared constructors
* class.c (check_bases_and_members): For C++2a set
CLASSTYPE_NON_AGGREGATE based on TYPE_HAS_USER_CONSTRUCTOR rather than
type_has_user_provided_or_explicit_constructor.
2018-07-31 Martin Liska <mliska@suse.cz>
PR c++/86653
......
......@@ -5571,7 +5571,9 @@ check_bases_and_members (tree t)
Again, other conditions for being an aggregate are checked
elsewhere. */
CLASSTYPE_NON_AGGREGATE (t)
|= (type_has_user_provided_or_explicit_constructor (t)
|= ((cxx_dialect < cxx2a
? type_has_user_provided_or_explicit_constructor (t)
: TYPE_HAS_USER_CONSTRUCTOR (t))
|| TYPE_POLYMORPHIC_P (t));
/* This is the C++98/03 definition of POD; it changed in C++0x, but we
retain the old definition internally for ABI reasons. */
......
2018-07-31 Jakub Jelinek <jakub@redhat.com>
P1008R1 - prohibit aggregates with user-declared constructors
* g++.dg/ext/is_aggregate.C: Add tests with deleted or defaulted ctor.
* g++.dg/cpp0x/defaulted1.C (main): Ifdef out for C++2a B b = {1};.
* g++.dg/cpp0x/deleted2.C: Expect error for C++2a.
* g++.dg/cpp2a/aggr1.C: New test.
* g++.dg/cpp2a/aggr2.C: New test.
2018-07-31 Segher Boessenkool <segher@kernel.crashing.org>
PR target/86640
......
......@@ -23,7 +23,9 @@ struct B
int main()
{
A a1, a2;
#if __cplusplus <= 201703L
B b = {1};
#endif
a1 = a2;
}
......
......@@ -6,4 +6,4 @@ struct A {
A() = delete;
};
A a = {1};
A a = {1}; // { dg-error "could not convert" "" { target c++2a } }
// { dg-do compile { target c++11 } }
struct A {
A () = delete; // { dg-message "declared here" "" { target c++2a } }
};
struct B {
B () = default;
int b = 0;
};
struct C {
C (C&&) = default; // { dg-message "candidate" "" { target c++2a } }
int c, d;
};
A a {}; // { dg-error "use of deleted function" "" { target c++2a } }
B b = {1}; // { dg-error "could not convert" "" { target { c++11_only || c++2a } } }
C *c = new C {2, 3}; // { dg-error "no matching function for call to" "" { target c++2a } }
// { dg-do run { target c++11 } }
struct A;
struct B { operator A (); };
struct A { A (const A &) = default; A () = default; B a; };
A a {B {}};
bool seen;
B::operator A ()
{
seen = true;
return A ();
}
int
main ()
{
#if __cplusplus > 201703L
if (!seen)
__builtin_abort ();
#else
if (seen)
__builtin_abort ();
#endif
}
......@@ -61,6 +61,8 @@ struct K { int a, b; virtual void foo (); };
struct L : virtual public A { int d, e; };
struct M : protected A { int d, e; };
struct N : private A { int d, e; };
struct O { O () = delete; int a, b, c; };
struct P { P () = default; int a, b, c; };
typedef int T;
typedef float U;
typedef int V __attribute__((vector_size (4 * sizeof (int))));
......@@ -94,6 +96,13 @@ main ()
assert (NTEST (L));
assert (NTEST (M));
assert (NTEST (N));
#if __cplusplus > 201703L
assert (NTEST (O));
assert (NTEST (P));
#else
assert (PTEST (O));
assert (PTEST (P));
#endif
assert (PTEST (int[]));
assert (PTEST (double[]));
assert (PTEST (T[2]));
......@@ -114,4 +123,6 @@ main ()
assert (PTEST (L[]));
assert (PTEST (M[6]));
assert (PTEST (N[]));
assert (PTEST (O[]));
assert (PTEST (P[]));
}
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