Implement P0840, language support for empty objects

Programming / Compilers / GCC - jason [138bc75d-0d04-0410-961f-82ee72b054a4] - 3 October 2018 15:56 EDT

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.

0c9e54e8269 Implement P0840, language support for empty objects.
gcc/c-family/ChangeLog | 4 +
gcc/c-family/c-lex.c | 2 +
gcc/cp/ChangeLog | 12 ++
gcc/cp/class.c | 180 +++++++++++++++++-------
gcc/cp/tree.c | 27 ++++
gcc/testsuite/g++.dg/abi/empty4.C | 27 ++++
gcc/testsuite/g++.dg/abi/empty5.C | 11 ++
gcc/testsuite/g++.dg/abi/empty8.C | 10 ++
gcc/testsuite/g++.dg/abi/no_unique_address1.C | 38 +++++
gcc/testsuite/g++.dg/abi/no_unique_address2.C | 43 ++++++
gcc/testsuite/g++.dg/abi/no_unique_address3.C | 19 +++
gcc/testsuite/g++.dg/cpp2a/no_unique_address1.C | 13 ++
12 files changed, 333 insertions(+), 53 deletions(-)

Upstream: gcc.gnu.org


  • Share