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
1 changed files with 4 additions and 0 deletions
4
tccgen.c
4
tccgen.c
|
@ -3916,6 +3916,7 @@ do_decl:
|
|||
get_tok_str(v, NULL));
|
||||
}
|
||||
if ((type1.t & VT_BTYPE) == VT_FUNC ||
|
||||
(type1.t & VT_BTYPE) == VT_VOID ||
|
||||
(type1.t & VT_STORAGE))
|
||||
tcc_error("invalid type for '%s'",
|
||||
get_tok_str(v, NULL));
|
||||
|
@ -7362,6 +7363,9 @@ found:
|
|||
}
|
||||
sym->a = ad.a;
|
||||
sym->f = ad.f;
|
||||
} else if ((type.t & VT_BTYPE) == VT_VOID
|
||||
&& !(type.t & VT_EXTERN)) {
|
||||
tcc_error("declaration of void object");
|
||||
} else {
|
||||
r = 0;
|
||||
if ((type.t & VT_BTYPE) == VT_FUNC) {
|
||||
|
|
Loading…
Reference in a new issue