use static declaration from prototype

static int func();
    ...
    int func() { }

As result, func needs to be static.
tcc-xref
grischka 2009-06-17 02:09:20 +02:00
parent 69fdb57edd
commit a342bbadc8
1 changed files with 8 additions and 3 deletions

View File

@ -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'",