summaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorJoseph Myers <jsm@polyomino.org.uk>2004-07-25 19:42:24 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2004-07-25 19:42:24 +0100
commitbbbcb2e1c4e122b5e10c3439c271ab0e00adbf08 (patch)
treed3c7f6481189c072679dc6bb540f8fc40de014c8 /gcc/c-decl.c
parent07a434923a44d1a7aecb0859aa22f10e2e26656a (diff)
downloadgcc-bbbcb2e1c4e122b5e10c3439c271ab0e00adbf08.tar.gz
re PR c/15360 (c99: extern w/initializer; extern w/internal linkage)
PR c/15360 * c-decl.c (start_decl): Do not set DECL_EXTERNAL for initialized declarations until after calling pushdecl. (grokdeclarator): Set DECL_EXTERNAL for variables based on use of "extern" and not on whether the declaration is initialized. testsuite: * gcc.dg/pr15360-1.c: New test. From-SVN: r85156
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index e5e1ee242c3..f7075b182ee 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -2766,7 +2766,6 @@ start_decl (tree declarator, tree declspecs, int initialized, tree attributes)
if (initialized)
{
- DECL_EXTERNAL (decl) = 0;
if (current_scope == file_scope)
TREE_STATIC (decl) = 1;
@@ -2833,6 +2832,9 @@ start_decl (tree declarator, tree declspecs, int initialized, tree attributes)
TEM may equal DECL or it may be a previous decl of the same name. */
tem = pushdecl (decl);
+ if (initialized)
+ DECL_EXTERNAL (tem) = 0;
+
return tem;
}
@@ -4599,7 +4601,10 @@ grokdeclarator (tree declarator, tree declspecs,
if (inlinep)
pedwarn ("%Jvariable '%D' declared `inline'", decl, decl);
- DECL_EXTERNAL (decl) = extern_ref;
+ /* At file scope, an initialized extern declaration may follow
+ a static declaration. In that case, DECL_EXTERNAL will be
+ reset later in start_decl. */
+ DECL_EXTERNAL (decl) = !!(specbits & (1 << (int) RID_EXTERN));
/* At file scope, the presence of a `static' or `register' storage
class specifier, or the absence of all storage class specifiers