diff options
author | Jason Merrill <jason@redhat.com> | 2019-11-15 09:51:05 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2019-11-15 09:51:05 -0500 |
commit | 9b41ebbcdf9e33285a0eebeb7c841afe20e4a7c1 (patch) | |
tree | 63d5b9a564430d47fdbe55993a501c3fa8fa098e /gcc/cp/class.c | |
parent | f6e20012ef792d659fec65fafecc29736c57f79c (diff) | |
download | gcc-9b41ebbcdf9e33285a0eebeb7c841afe20e4a7c1.zip gcc-9b41ebbcdf9e33285a0eebeb7c841afe20e4a7c1.tar.gz gcc-9b41ebbcdf9e33285a0eebeb7c841afe20e4a7c1.tar.bz2 |
Implement P1816R0, class template argument deduction for aggregates.
Rather than reimplement brace elision here, we call reshape_init and then
discard the result. We needed to set CLASSTYPE_NON_AGGREGATE a bit more in
this patch, since outside a template it's set in check_bases_and_members.
* pt.c (maybe_aggr_guide, collect_ctor_idx_types): New.
(is_spec_or_derived): Split out from do_class_deduction.
(build_deduction_guide): Handle aggregate guide.
* class.c (finish_struct): Set CLASSTYPE_NON_AGGREGATE in a
template.
* cp-tree.h (CP_AGGREGATE_TYPE_P): An incomplete class is not an
aggregate.
From-SVN: r278298
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index a9aa5e7..ef1d513 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -7349,7 +7349,16 @@ finish_struct (tree t, tree attributes) add_method (t, *iter, true); } else if (DECL_DECLARES_FUNCTION_P (x)) - DECL_IN_AGGR_P (x) = false; + { + DECL_IN_AGGR_P (x) = false; + if (DECL_VIRTUAL_P (x)) + CLASSTYPE_NON_AGGREGATE (t) = true; + } + else if (TREE_CODE (x) == FIELD_DECL) + { + if (TREE_PROTECTED (x) || TREE_PRIVATE (x)) + CLASSTYPE_NON_AGGREGATE (t) = true; + } /* Also add a USING_DECL for operator=. We know there'll be (at least) one, but we don't know the signature(s). We want name @@ -7387,6 +7396,9 @@ finish_struct (tree t, tree attributes) /* Remember current #pragma pack value. */ TYPE_PRECISION (t) = maximum_field_alignment; + if (TYPE_HAS_USER_CONSTRUCTOR (t)) + CLASSTYPE_NON_AGGREGATE (t) = 1; + /* Fix up any variants we've already built. */ for (x = TYPE_NEXT_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x)) { |