aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/init.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-03-04 12:08:42 -0500
committerJason Merrill <jason@redhat.com>2020-03-04 17:32:10 -0500
commit6876b269bc7fe6465fedfed87c31e6175992129f (patch)
tree932e196928b06bdf75240404f18593556310a575 /gcc/cp/init.c
parent10bbbb591cfe6cac200e926a73f3b8065147ce84 (diff)
downloadgcc-6876b269bc7fe6465fedfed87c31e6175992129f.zip
gcc-6876b269bc7fe6465fedfed87c31e6175992129f.tar.gz
gcc-6876b269bc7fe6465fedfed87c31e6175992129f.tar.bz2
c++: Fix [[no_unique_address]] and default mem-init [PR90432]
output_constructor doesn't like two consecutive entries with fields at the same position; let's avoid adding the one for the empty field. gcc/cp/ChangeLog 2020-03-04 Jason Merrill <jason@redhat.com> PR c++/90432 * init.c (perform_member_init): Don't do aggregate initialization of empty field. * constexpr.c (cx_check_missing_mem_inits): Don't enforce initialization of empty field.
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r--gcc/cp/init.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 61ed3aa..27623cf 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -865,6 +865,11 @@ perform_member_init (tree member, tree init)
}
if (init == error_mark_node)
return;
+ if (DECL_SIZE (member) && integer_zerop (DECL_SIZE (member))
+ && !TREE_SIDE_EFFECTS (init))
+ /* Don't add trivial initialization of an empty base/field, as they
+ might not be ordered the way the back-end expects. */
+ return;
/* A FIELD_DECL doesn't really have a suitable lifetime, but
make_temporary_var_for_ref_to_temp will treat it as automatic and
set_up_extended_ref_temp wants to use the decl in a warning. */