static int func(); ... int func() { } As result, func needs to be static.
Unified · Split
| @@ -5032,16 +5032,21 @@ static void decl(int l) · 5031 unmodified lines | |||
| 5032 | if (sym) { | 5032 | if (sym) { |
| 5033 | if ((sym->type.t & VT_BTYPE) != VT_FUNC) | 5033 | if ((sym->type.t & VT_BTYPE) != VT_FUNC) |
| 5034 | goto func_error1; | 5034 | goto func_error1; |
| 5035 | /* specific case: if not func_call defined, we put | 5035 | |
| 5036 | the one of the prototype */ | ||
| 5037 | /* XXX: should have default value */ | ||
| 5038 | r = sym->type.ref->r; | 5036 | r = sym->type.ref->r; |
| 5037 | /* use func_call from prototype if not defined */ | ||
| 5039 | if (FUNC_CALL(r) != FUNC_CDECL | 5038 | if (FUNC_CALL(r) != FUNC_CDECL |
| 5040 | && FUNC_CALL(type.ref->r) == FUNC_CDECL) | 5039 | && FUNC_CALL(type.ref->r) == FUNC_CDECL) |
| 5041 | FUNC_CALL(type.ref->r) = FUNC_CALL(r); | 5040 | FUNC_CALL(type.ref->r) = FUNC_CALL(r); |
| 5041 | |||
| 5042 | /* use export from prototype */ | ||
| 5042 | if (FUNC_EXPORT(r)) | 5043 | if (FUNC_EXPORT(r)) |
| 5043 | FUNC_EXPORT(type.ref->r) = 1; | 5044 | FUNC_EXPORT(type.ref->r) = 1; |
| 5044 | 5045 | ||
| 5046 | /* use static from prototype */ | ||
| 5047 | if (sym->type.t & VT_STATIC) | ||
| 5048 | type.t = (type.t & ~VT_EXTERN) | VT_STATIC; | ||
| 5049 | |||
| 5045 | if (!is_compatible_types(&sym->type, &type)) { | 5050 | if (!is_compatible_types(&sym->type, &type)) { |
| 5046 | func_error1: | 5051 | func_error1: |
| 5047 | error("incompatible types for redefinition of '%s'", | 5052 | error("incompatible types for redefinition of '%s'", |