Don't endlessly recurse on invalid nested typedefs
see testcase.
This commit is contained in:
parent
d00f98a7a5
commit
5ac2a26666
3 changed files with 11 additions and 1 deletions
3
tccgen.c
3
tccgen.c
|
@ -2782,7 +2782,7 @@ ST_FUNC int type_size(CType *type, int *a)
|
||||||
*a = PTR_SIZE;
|
*a = PTR_SIZE;
|
||||||
return PTR_SIZE;
|
return PTR_SIZE;
|
||||||
}
|
}
|
||||||
} else if (IS_ENUM(type->t) && type->ref->c == -1) {
|
} else if (IS_ENUM(type->t) && type->ref->c < 0) {
|
||||||
return -1; /* incomplete enum */
|
return -1; /* incomplete enum */
|
||||||
} else if (bt == VT_LDOUBLE) {
|
} else if (bt == VT_LDOUBLE) {
|
||||||
*a = LDOUBLE_ALIGN;
|
*a = LDOUBLE_ALIGN;
|
||||||
|
@ -3934,6 +3934,7 @@ do_decl:
|
||||||
next();
|
next();
|
||||||
if (s->c != -1)
|
if (s->c != -1)
|
||||||
tcc_error("struct/union/enum already defined");
|
tcc_error("struct/union/enum already defined");
|
||||||
|
s->c = -2;
|
||||||
/* cannot be empty */
|
/* cannot be empty */
|
||||||
/* non empty enums are not allowed */
|
/* non empty enums are not allowed */
|
||||||
ps = &s->next;
|
ps = &s->next;
|
||||||
|
|
|
@ -160,4 +160,10 @@ void foo(void) {
|
||||||
i = 42.2;
|
i = 42.2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif defined test_nested_types
|
||||||
|
union u {
|
||||||
|
union u {
|
||||||
|
int i;
|
||||||
|
} m;
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -74,3 +74,6 @@
|
||||||
|
|
||||||
[test_conflicting_types]
|
[test_conflicting_types]
|
||||||
60_errors_and_warnings.c:159: error: conflicting types for 'i'
|
60_errors_and_warnings.c:159: error: conflicting types for 'i'
|
||||||
|
|
||||||
|
[test_nested_types]
|
||||||
|
60_errors_and_warnings.c:166: error: struct/union/enum already defined
|
||||||
|
|
Loading…
Add table
Reference in a new issue