c++: [[no_unique_address]] fixes. [PR96105]
authorJason Merrill <jason@redhat.com>
Thu, 9 Jul 2020 19:11:12 +0000 (15:11 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 10 Jul 2020 12:36:40 +0000 (08:36 -0400)
commite47dfca5aa473e77fdff95d631dc39de87a41eec
tree53f7d6d930a736ba88080c98544721a4d7da1f82
parenta6645a826f58b68f68dff30e6e6e78542099d0cc
c++: [[no_unique_address]] fixes. [PR96105]

We were wrongly checking is_empty_class on the result of strip_array_types
rather than the actual field type.  We weren't considering the alignment of
the data member.  We needed to handle unions the same way as
layout_nonempty_base_or_field.

gcc/cp/ChangeLog:

PR c++/96105
PR c++/96052
PR c++/95976
* class.c (check_field_decls): An array of empty classes is not an
empty data member.
(layout_empty_base_or_field): Handle explicit alignment.
Fix union handling.

gcc/testsuite/ChangeLog:

PR c++/96105
PR c++/96052
PR c++/95976
* g++.dg/cpp2a/no_unique_address4.C: New test.
* g++.dg/cpp2a/no_unique_address5.C: New test.
* g++.dg/cpp2a/no_unique_address6.C: New test.
gcc/cp/class.c
gcc/testsuite/g++.dg/cpp2a/no_unique_address4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/no_unique_address5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/no_unique_address6.C [new file with mode: 0644]