diff options
| author | grischka <grischka> | 2009-06-17 02:09:20 +0200 |
|---|---|---|
| committer | grischka <grischka> | 2009-06-17 02:09:20 +0200 |
| commit | a342bbadc8da67c8cb64c6ad9731b27a1ad30bad (patch) | |
| tree | 47dd04602727fe60ca5291a9eefd4b9f43064cdb | |
| parent | 69fdb57eddd00c592828605819f0678522d346c6 (diff) | |
| download | tinycc-a342bbadc8da67c8cb64c6ad9731b27a1ad30bad.tar.gz tinycc-a342bbadc8da67c8cb64c6ad9731b27a1ad30bad.tar.bz2 | |
use static declaration from prototype
static int func();
...
int func() { }
As result, func needs to be static.
| -rw-r--r-- | tccgen.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -5032,16 +5032,21 @@ static void decl(int l) if (sym) { if ((sym->type.t & VT_BTYPE) != VT_FUNC) goto func_error1; - /* specific case: if not func_call defined, we put - the one of the prototype */ - /* XXX: should have default value */ + r = sym->type.ref->r; + /* use func_call from prototype if not defined */ if (FUNC_CALL(r) != FUNC_CDECL && FUNC_CALL(type.ref->r) == FUNC_CDECL) FUNC_CALL(type.ref->r) = FUNC_CALL(r); + + /* use export from prototype */ if (FUNC_EXPORT(r)) FUNC_EXPORT(type.ref->r) = 1; + /* use static from prototype */ + if (sym->type.t & VT_STATIC) + type.t = (type.t & ~VT_EXTERN) | VT_STATIC; + if (!is_compatible_types(&sym->type, &type)) { func_error1: error("incompatible types for redefinition of '%s'", |
