(finish_decl): For static const variables, preserve
authorJim Wilson <wilson@gcc.gnu.org>
Wed, 1 Sep 1993 22:59:32 +0000 (15:59 -0700)
committerJim Wilson <wilson@gcc.gnu.org>
Wed, 1 Sep 1993 22:59:32 +0000 (15:59 -0700)
initializers instead of discarding them.

From-SVN: r5245

gcc/c-decl.c

index eede16315b6bb137f6ba4a7a3f87fed803a2a047..eca89fa2365998d96176362257c603a01165c091 100644 (file)
@@ -3557,7 +3557,15 @@ finish_decl (decl, init, asmspec_tree)
         normal for a local extern redeclaration of an inline function
         to have a copy of the top-level decl's DECL_INLINE.  */
       if (DECL_INITIAL (decl) != 0)
-       DECL_INITIAL (decl) = error_mark_node;
+       {
+         /* If this is a static const variable, then preserve the
+            initializer instead of discarding it so that we can optimize
+            references to it.  */
+         if (TREE_STATIC (decl) && TREE_READONLY (decl))
+           preserve_initializer ();
+         else
+           DECL_INITIAL (decl) = error_mark_node;
+       }
     }
 
 #if 0