re PR tree-optimization/21610 (ICE in make_decl_rtl)
[gcc.git] / gcc / c-typeck.c
index 806a20ade96a65726dc3e79e3f0cbf4acc4d79f6..b96328d89b90f4174b2c414a0541b33dd0f305c0 100644 (file)
@@ -1249,10 +1249,18 @@ decl_constant_value (tree decl)
 static tree
 decl_constant_value_for_broken_optimization (tree decl)
 {
+  tree ret;
+
   if (pedantic || DECL_MODE (decl) == BLKmode)
     return decl;
-  else
-    return decl_constant_value (decl);
+
+  ret = decl_constant_value (decl);
+  /* Avoid unwanted tree sharing between the initializer and current
+     function's body where the tree can be modified e.g. by the
+     gimplifier.  */
+  if (ret != decl && TREE_STATIC (decl))
+    ret = unshare_expr (ret);
+  return ret;
 }