summaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c5
1 files changed, 4 insertions, 1 deletions
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