summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-05-01 13:53:32 -0400
committerJason Merrill <jason@redhat.com>2020-05-01 13:53:33 -0400
commita2f32550a085984fbaaec962bf7723514ac71dff (patch)
treedc8f3b56e92094cb353ea1a72932e7d5e7df5327 /gcc/cp
parentbcbf334afe091ad7d0f5ffe164299f8730cf41d1 (diff)
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.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c5
2 files changed, 10 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 039e946f950..44686909c83 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2020-05-01 Jason Merrill <jason@redhat.com>
+ PR c++/91529
+ * decl.c (cp_finish_decl): Also clear TREE_READONLY if
+ -fmerge-all-constants.
+
+2020-05-01 Jason Merrill <jason@redhat.com>
+
PR c++/93822
* pt.c (tsubst_decl): Make sure DECL_VALUE_EXPR continues to have
the same type as the variable.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 4c0ae1cfa2e..3e7ed98fed3 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7833,7 +7833,10 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
maybe_commonize_var (decl);
}
- if (var_definition_p && TREE_STATIC (decl))
+ if (var_definition_p
+ /* With -fmerge-all-constants, gimplify_init_constructor
+ might add TREE_STATIC to the variable. */
+ && (TREE_STATIC (decl) || flag_merge_constants >= 2))
{
/* If a TREE_READONLY variable needs initialization
at runtime, it is no longer readonly and we need to