aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1993-11-01 07:38:45 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1993-11-01 07:38:45 -0500
commit3564e40e2c1d041491de0319989296cf46a1f10c (patch)
tree100255374aa27f3a64d0c0d2a23e29525533fae2
parentc0b262c16625f8e9650ce58fb299d1cef5383dbd (diff)
downloadgcc-3564e40e2c1d041491de0319989296cf46a1f10c.zip
gcc-3564e40e2c1d041491de0319989296cf46a1f10c.tar.gz
gcc-3564e40e2c1d041491de0319989296cf46a1f10c.tar.bz2
(expand_decl_init): If CONST_DECL, don't generate any code, but call
expand_expr if DECL_INITIAL is a constant. From-SVN: r5962
-rw-r--r--gcc/stmt.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 8b07813..e6caa9f 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -3604,6 +3604,20 @@ expand_decl_init (decl)
{
int was_used = TREE_USED (decl);
+ /* If this is a CONST_DECL, we don't have to generate any code, but
+ if DECL_INITIAL is a constant, call expand_expr to force TREE_CST_RTL
+ to be set while in the obstack containing the constant. If we don't
+ do this, we can lose if we have functions nested three deep and the middle
+ function makes a CONST_DECL whose DECL_INITIAL is a STRING_CST while
+ the innermost function is the first to expand that STRING_CST. */
+ if (TREE_CODE (decl) == CONST_DECL)
+ {
+ if (DECL_INITIAL (decl) && TREE_CONSTANT (DECL_INITIAL (decl)))
+ expand_expr (DECL_INITIAL (decl), NULL_RTX, VOIDmode,
+ EXPAND_INITIALIZER);
+ return;
+ }
+
if (TREE_STATIC (decl))
return;