aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Wilson <wilson@gcc.gnu.org>1993-09-01 15:59:32 -0700
committerJim Wilson <wilson@gcc.gnu.org>1993-09-01 15:59:32 -0700
commit549a367ad6bf68e95e6c08fe9fb49a29a4e92177 (patch)
treea1e477951b0bfc41531b981d238cbb0c57ffaaad
parent915bb7632b64ad515e041b1c077b7c4306b6a8fa (diff)
downloadgcc-549a367ad6bf68e95e6c08fe9fb49a29a4e92177.zip
gcc-549a367ad6bf68e95e6c08fe9fb49a29a4e92177.tar.gz
gcc-549a367ad6bf68e95e6c08fe9fb49a29a4e92177.tar.bz2
(finish_decl): For static const variables, preserve
initializers instead of discarding them. From-SVN: r5245
-rw-r--r--gcc/c-decl.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index eede163..eca89fa 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