scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 149ab2b982334ac3efa9034e595afff1b9df17ad
parent 046982d523fdd935c5b30924de2e143f4fbbf6df
Author: Michael Forney <mforney@mforney.org>
Date:   Mon, 20 Feb 2017 13:10:28 -0800

[cc1] Clear SEXTERN for global symbols previously declared as extern

Diffstat:
Mcc1/decl.c | 3++-
Atests/execute/0113-externredecl.c | 8++++++++
Mtests/execute/scc-tests.lst | 1+
3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/cc1/decl.c b/cc1/decl.c @@ -703,7 +703,8 @@ redcl(Symbol *sym, Type *tp, Symbol **pars, int sclass) break; case NOSCLASS: if ((flags & SPRIVATE) == 0) { - flags &= ~SEXTERN; + if (flags & SEXTERN) + flags &= ~(SEXTERN|SEMITTED); flags |= SGLOBAL; break; } diff --git a/tests/execute/0113-externredecl.c b/tests/execute/0113-externredecl.c @@ -0,0 +1,8 @@ +extern int x; +int x; + +int +main() +{ + return x; +} diff --git a/tests/execute/scc-tests.lst b/tests/execute/scc-tests.lst @@ -103,3 +103,4 @@ 0110-typedefcast.c 0111-doubledef.c 0112-cond.c +0113-externredecl.c