| @@ -8517,7 +8517,7 @@ static int decl(int l) · 8516 unmodified lines |
| 8517 | { | 8517 | { |
| 8518 | int v, has_init, r, oldint; | 8518 | int v, has_init, r, oldint; |
| 8519 | CType type, btype; | 8519 | CType type, btype; |
| 8520 | Sym *sym; | 8520 | Sym *sym, *s; |
| 8521 | AttributeDef ad, adbase; | 8521 | AttributeDef ad, adbase; |
| 8522 | ElfSym *esym; | 8522 | ElfSym *esym; |
| 8523 | | 8523 | |
| @@ -8589,6 +8589,21 @@ static int decl(int l) · 65 unmodified lines |
| 8589 | if (sym->f.func_type == FUNC_OLD && l == VT_CONST) { | 8589 | if (sym->f.func_type == FUNC_OLD && l == VT_CONST) { |
| 8590 | func_vt = type; | 8590 | func_vt = type; |
| 8591 | decl(VT_CMP); | 8591 | decl(VT_CMP); |
| | 8592 | |
| | 8593 | /* Allow mixing old/new prototypes |
| | 8594 | * void func(float a); |
| | 8595 | * int main(void) { func(1.0); } |
| | 8596 | * void func(a) float a; { printf("%g\n", a); } |
| | 8597 | */ |
| | 8598 | s = sym_find(v); |
| | 8599 | if (type.ref->next && // skip old func(); definitions |
| | 8600 | s && s->type.ref && |
| | 8601 | s->type.ref->f.func_type == FUNC_NEW) { |
| | 8602 | sym->f.func_type = FUNC_NEW; |
| | 8603 | if (!is_compatible_types(&s->type, &type)) |
| | 8604 | tcc_error("incompatible redefinition of '%s'", |
| | 8605 | get_tok_str(v, NULL)); |
| | 8606 | } |
| 8592 | } | 8607 | } |
| 8593 | | 8608 | |
| 8594 | if ((type.t & (VT_EXTERN|VT_INLINE)) == (VT_EXTERN|VT_INLINE)) { | 8609 | if ((type.t & (VT_EXTERN|VT_INLINE)) == (VT_EXTERN|VT_INLINE)) { |
| @@ -8646,6 +8661,9 @@ static int decl(int l) · 51 unmodified lines |
| 8646 | while ((sym = sym->next) != NULL) { | 8661 | while ((sym = sym->next) != NULL) { |
| 8647 | if (!(sym->v & ~SYM_FIELD)) | 8662 | if (!(sym->v & ~SYM_FIELD)) |
| 8648 | expect("identifier"); | 8663 | expect("identifier"); |
| | 8664 | if (type.ref->f.func_type == FUNC_OLD && |
| | 8665 | sym->type.t == VT_FLOAT) |
| | 8666 | sym->type.t = VT_DOUBLE; |
| 8649 | if (sym->type.t == VT_VOID) | 8667 | if (sym->type.t == VT_VOID) |
| 8650 | sym->type = int_type; | 8668 | sym->type = int_type; |
| 8651 | } | 8669 | } |
| @@ -8693,9 +8711,6 @@ static int decl(int l) · 41 unmodified lines |
| 8693 | if (sym->type.t != VT_VOID) | 8711 | if (sym->type.t != VT_VOID) |
| 8694 | tcc_error("redefinition of parameter '%s'", | 8712 | tcc_error("redefinition of parameter '%s'", |
| 8695 | get_tok_str(v, NULL)); | 8713 | get_tok_str(v, NULL)); |
| 8696 | if (func_vt.ref->f.func_type == FUNC_OLD && | | |
| 8697 | type.t == VT_FLOAT) | | |
| 8698 | type.t = VT_DOUBLE; | | |
| 8699 | convert_parameter_type(&type); | 8714 | convert_parameter_type(&type); |
| 8700 | sym->type = type; | 8715 | sym->type = type; |
| 8701 | } else if (type.t & VT_TYPEDEF) { | 8716 | } else if (type.t & VT_TYPEDEF) { |