Deal with more tentative definitions

see testcase.
mob
Michael Matz 2019-06-17 18:52:49 +02:00
parent 69a46b0c53
commit fe23a14ebb
2 changed files with 11 additions and 0 deletions

View File

@ -1005,6 +1005,7 @@ static Sym *external_sym(int v, CType *type, int r, AttributeDef *ad)
Sym *s;
s = sym_find(v);
if (!s || (!IS_ASM_SYM(s) && !(s->type.t & VT_EXTERN)
&& (!(type->t & VT_EXTERN) || s->sym_scope)
&& (s->type.t & VT_BTYPE) != VT_FUNC)) {
if (s && !is_compatible_types(&s->type, type))
tcc_error("conflicting types for '%s'", get_tok_str(s->v, NULL));

View File

@ -816,6 +816,16 @@ void scope_test2()
printf("exloc: %d\n", *st2_p);
}
/* C has tentative definition, and they may be repeated. */
extern int st_global1;
int st_global1=42;
extern int st_global1;
int st_global1;
extern int st_global2;
int st_global2;
extern int st_global2;
int st_global2;
void array_test()
{
int i, j, a[4];