From: Jim Wilson Date: Wed, 1 Sep 1993 22:59:32 +0000 (-0700) Subject: (finish_decl): For static const variables, preserve X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=549a367ad6bf68e95e6c08fe9fb49a29a4e92177;p=gcc.git (finish_decl): For static const variables, preserve initializers instead of discarding them. From-SVN: r5245 --- diff --git a/gcc/c-decl.c b/gcc/c-decl.c index eede16315b6..eca89fa2365 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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