Implement P0840, language support for empty objects.
authorJason Merrill <jason@redhat.com>
Wed, 3 Oct 2018 15:56:29 +0000 (11:56 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 3 Oct 2018 15:56:29 +0000 (11:56 -0400)
commitbedf03a298f87b43f02eaee57542fbd10228ec08
treeb89298bfa67ef964fcefa62e3d8b27bfd7807c1d
parent749c0e1d8b2c8dbc54af3365af506b3e1986e754
Implement P0840, language support for empty objects.

The [[no_unique_address]] attribute on a non-static data member
enables the equivalent of the empty base optimization.

gcc/cp/
* tree.c (handle_no_unique_addr_attribute): New.
(cxx_attribute_table): Add [[no_unique_address]].
* class.c (field_poverlapping_p): New.
(layout_class_type): Check it.  Adjust DECL_SIZE of potentially
overlapping fields.
(layout_empty_base_or_field): Rename from layout_empty_base, handle
FIELD_DECL as well.
(build_base_field, record_subobject_offsets): Adjust.
c-family/
* c-lex.c (c_common_has_attribute): Add no_unique_address.

From-SVN: r264813
12 files changed:
gcc/c-family/ChangeLog
gcc/c-family/c-lex.c
gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/tree.c
gcc/testsuite/g++.dg/abi/empty4.C
gcc/testsuite/g++.dg/abi/empty5.C
gcc/testsuite/g++.dg/abi/empty8.C
gcc/testsuite/g++.dg/abi/no_unique_address1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/no_unique_address2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/no_unique_address3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/no_unique_address1.C [new file with mode: 0644]