mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-17 15:44:18 +08:00
Allow mixing old/new function prototypes
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
This fixes another external testsuite failure
This commit is contained in:
parent
571868c4f7
commit
19fdef46f9
23
tccgen.c
23
tccgen.c
@ -8517,7 +8517,7 @@ static int decl(int l)
|
||||
{
|
||||
int v, has_init, r, oldint;
|
||||
CType type, btype;
|
||||
Sym *sym;
|
||||
Sym *sym, *s;
|
||||
AttributeDef ad, adbase;
|
||||
ElfSym *esym;
|
||||
|
||||
@ -8589,6 +8589,21 @@ static int decl(int l)
|
||||
if (sym->f.func_type == FUNC_OLD && l == VT_CONST) {
|
||||
func_vt = type;
|
||||
decl(VT_CMP);
|
||||
|
||||
/* Allow mixing old/new prototypes
|
||||
* void func(float a);
|
||||
* int main(void) { func(1.0); }
|
||||
* void func(a) float a; { printf("%g\n", a); }
|
||||
*/
|
||||
s = sym_find(v);
|
||||
if (type.ref->next && // skip old func(); definitions
|
||||
s && s->type.ref &&
|
||||
s->type.ref->f.func_type == FUNC_NEW) {
|
||||
sym->f.func_type = FUNC_NEW;
|
||||
if (!is_compatible_types(&s->type, &type))
|
||||
tcc_error("incompatible redefinition of '%s'",
|
||||
get_tok_str(v, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
if ((type.t & (VT_EXTERN|VT_INLINE)) == (VT_EXTERN|VT_INLINE)) {
|
||||
@ -8646,6 +8661,9 @@ static int decl(int l)
|
||||
while ((sym = sym->next) != NULL) {
|
||||
if (!(sym->v & ~SYM_FIELD))
|
||||
expect("identifier");
|
||||
if (type.ref->f.func_type == FUNC_OLD &&
|
||||
sym->type.t == VT_FLOAT)
|
||||
sym->type.t = VT_DOUBLE;
|
||||
if (sym->type.t == VT_VOID)
|
||||
sym->type = int_type;
|
||||
}
|
||||
@ -8693,9 +8711,6 @@ static int decl(int l)
|
||||
if (sym->type.t != VT_VOID)
|
||||
tcc_error("redefinition of parameter '%s'",
|
||||
get_tok_str(v, NULL));
|
||||
if (func_vt.ref->f.func_type == FUNC_OLD &&
|
||||
type.t == VT_FLOAT)
|
||||
type.t = VT_DOUBLE;
|
||||
convert_parameter_type(&type);
|
||||
sym->type = type;
|
||||
} else if (type.t & VT_TYPEDEF) {
|
||||
|
||||
@ -6,6 +6,8 @@ float x;
|
||||
return 2.0 * x;
|
||||
}
|
||||
|
||||
void func(float a);
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
@ -13,6 +15,7 @@ main(void)
|
||||
|
||||
printf("%g %g\n", fx(2.0), fy(10.0));
|
||||
printf("%g %g\n", fx(2.0f), fy(10.0f));
|
||||
func(1);
|
||||
}
|
||||
|
||||
float fy(x)
|
||||
@ -21,3 +24,8 @@ float x;
|
||||
return 3.0 * x;
|
||||
}
|
||||
|
||||
void func(a)
|
||||
float a;
|
||||
{
|
||||
printf("%g\n", a);
|
||||
}
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
4 30
|
||||
4 30
|
||||
1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user