c++: -fmerge-all-constants vs. destructors [PR91529]
authorJason Merrill <jason@redhat.com>
Fri, 1 May 2020 17:53:32 +0000 (13:53 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 1 May 2020 17:53:33 +0000 (13:53 -0400)
commita2f32550a085984fbaaec962bf7723514ac71dff
treedc8f3b56e92094cb353ea1a72932e7d5e7df5327
parentbcbf334afe091ad7d0f5ffe164299f8730cf41d1
c++: -fmerge-all-constants vs. destructors [PR91529]

cp_finish_decl avoids setting TREE_READONLY on TREE_STATIC variables that
have non-constant construction or destruction, but -fmerge-all-constants was
converting an automatic variable to static while leaving TREE_READONLY set.

Fixed by clearing the flag in cp_finish_decl in the presence of
-fmerge-all-constants.

gcc/cp/ChangeLog
2020-05-01  Jason Merrill  <jason@redhat.com>

PR c++/91529
* decl.c (cp_finish_decl): Also clear TREE_READONLY if
-fmerge-all-constants.
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/init/const14.C [new file with mode: 0644]