c++: rodata and defaulted ctor [PR104142]
authorJason Merrill <jason@redhat.com>
Mon, 11 Apr 2022 18:50:14 +0000 (14:50 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 12 Apr 2022 03:57:42 +0000 (23:57 -0400)
commit0899b22d9329c1e8fc12d6f0deee0f87dcc0163a
tree88d977d162577f8d8d05987acafed587faac8a25
parent4195fced8a13422db94e179404588d9d887a036a
c++: rodata and defaulted ctor [PR104142]

Trivial initialization shouldn't bump a variable out of .rodata; if the
result of build_aggr_init is an empty STATEMENT_LIST, throw it away.

PR c++/104142

gcc/cp/ChangeLog:

* decl.cc (check_initializer): Check TREE_SIDE_EFFECTS.

gcc/testsuite/ChangeLog:

* g++.dg/opt/const7.C: New test.
gcc/cp/decl.cc
gcc/testsuite/g++.dg/opt/const7.C [new file with mode: 0644]