mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-04 06:30:10 +08:00
Check for void type in top-level decls
give an error message from the parser on things like "void x;" instead of relying on codegen erroring out.
This commit is contained in:
parent
22420ee1ee
commit
61ba9f2299
4
tccgen.c
4
tccgen.c
@ -3916,6 +3916,7 @@ do_decl:
|
|||||||
get_tok_str(v, NULL));
|
get_tok_str(v, NULL));
|
||||||
}
|
}
|
||||||
if ((type1.t & VT_BTYPE) == VT_FUNC ||
|
if ((type1.t & VT_BTYPE) == VT_FUNC ||
|
||||||
|
(type1.t & VT_BTYPE) == VT_VOID ||
|
||||||
(type1.t & VT_STORAGE))
|
(type1.t & VT_STORAGE))
|
||||||
tcc_error("invalid type for '%s'",
|
tcc_error("invalid type for '%s'",
|
||||||
get_tok_str(v, NULL));
|
get_tok_str(v, NULL));
|
||||||
@ -7362,6 +7363,9 @@ found:
|
|||||||
}
|
}
|
||||||
sym->a = ad.a;
|
sym->a = ad.a;
|
||||||
sym->f = ad.f;
|
sym->f = ad.f;
|
||||||
|
} else if ((type.t & VT_BTYPE) == VT_VOID
|
||||||
|
&& !(type.t & VT_EXTERN)) {
|
||||||
|
tcc_error("declaration of void object");
|
||||||
} else {
|
} else {
|
||||||
r = 0;
|
r = 0;
|
||||||
if ((type.t & VT_BTYPE) == VT_FUNC) {
|
if ((type.t & VT_BTYPE) == VT_FUNC) {
|
||||||
|
Loading…
Reference in New Issue
Block a user