c++: mutable temps in rodata
commit47c3144c2f6b001031b1fbfa301bb987075408a7
authorJason Merrill <jason@redhat.com>
Tue, 13 Jun 2023 11:29:34 +0000 (13 07:29 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 13 Jun 2023 12:09:48 +0000 (13 08:09 -0400)
treebf09f778ec639bfe20ff6324059fafcba0834c42
parent1d4d302acd915a81f4b7d7a6db44999531f2fd31
c++: mutable temps in rodata

If the type of a temporary has mutable members, we can't set TREE_READONLY
on the VAR_DECL; this is parallel to the check in
cp_apply_type_quals_to_decl.

gcc/cp/ChangeLog:

* tree.cc (build_target_expr): Check TYPE_HAS_MUTABLE_P.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/initlist-opt6.C: New test.
gcc/cp/tree.cc
gcc/testsuite/g++.dg/tree-ssa/initlist-opt6.C [new file with mode: 0644]