re PR c++/92869 (C++17 wrongly reports aggregate type as not-aggregate (when explicitly defaulted ctors are added))
PR c++/92869 * class.c (finish_struct): For C++17 and earlier, check type_has_user_provided_or_explicit_constructor rather than TYPE_HAS_USER_CONSTRUCTOR whether to set CLASSTYPE_NON_AGGREGATE. * g++.dg/cpp0x/aggr3.C: New test. From-SVN: r279241
This commit is contained in:
parent
c20f7e9971
commit
3455115379
@ -1,3 +1,10 @@
|
||||
2019-12-11 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/92869
|
||||
* class.c (finish_struct): For C++17 and earlier, check
|
||||
type_has_user_provided_or_explicit_constructor rather than
|
||||
TYPE_HAS_USER_CONSTRUCTOR whether to set CLASSTYPE_NON_AGGREGATE.
|
||||
|
||||
2019-12-11 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c++/92878 - Parenthesized init of aggregates in new-expression.
|
||||
|
@ -7474,7 +7474,13 @@ finish_struct (tree t, tree attributes)
|
||||
/* Remember current #pragma pack value. */
|
||||
TYPE_PRECISION (t) = maximum_field_alignment;
|
||||
|
||||
if (TYPE_HAS_USER_CONSTRUCTOR (t))
|
||||
if (cxx_dialect < cxx2a)
|
||||
{
|
||||
if (!CLASSTYPE_NON_AGGREGATE (t)
|
||||
&& type_has_user_provided_or_explicit_constructor (t))
|
||||
CLASSTYPE_NON_AGGREGATE (t) = 1;
|
||||
}
|
||||
else if (TYPE_HAS_USER_CONSTRUCTOR (t))
|
||||
CLASSTYPE_NON_AGGREGATE (t) = 1;
|
||||
|
||||
/* Fix up any variants we've already built. */
|
||||
|
@ -1,3 +1,8 @@
|
||||
2019-12-11 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/92869
|
||||
* g++.dg/cpp0x/aggr3.C: New test.
|
||||
|
||||
2019-12-11 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c++/92878 - Parenthesized init of aggregates in new-expression.
|
||||
|
20
gcc/testsuite/g++.dg/cpp0x/aggr3.C
Normal file
20
gcc/testsuite/g++.dg/cpp0x/aggr3.C
Normal file
@ -0,0 +1,20 @@
|
||||
// PR c++/92869
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
struct A {
|
||||
A () = default;
|
||||
A (const A &) = default;
|
||||
A (A &&) = default;
|
||||
int arr[3];
|
||||
};
|
||||
|
||||
template <typename T, int N>
|
||||
struct B {
|
||||
B () = default;
|
||||
B (const B &) = default;
|
||||
B (B &&) = default;
|
||||
T arr[N];
|
||||
};
|
||||
|
||||
A a = { { 1, 2, 3 } }; // { dg-error "could not convert" "" { target c++2a } }
|
||||
B<int, 3> b = { { 1, 2, 3 } }; // { dg-error "could not convert" "" { target c++2a } }
|
Loading…
Reference in New Issue
Block a user