History

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.

Michael Matz committed 8 years ago

Commit 61ba9f21 parent 22420ee1 file · +4 −0Browse files

Unified · Split

tccgen.c+4−0
@@ -3916,6 +3916,7 @@ do_decl: · 3915 unmodified lines
3916 get_tok_str(v, NULL));3916 get_tok_str(v, NULL));
3917 }3917 }
3918 if ((type1.t & VT_BTYPE) == VT_FUNC ||3918 if ((type1.t & VT_BTYPE) == VT_FUNC ||
3919 (type1.t & VT_BTYPE) == VT_VOID ||
3919 (type1.t & VT_STORAGE))3920 (type1.t & VT_STORAGE))
3920 tcc_error("invalid type for '%s'", 3921 tcc_error("invalid type for '%s'",
3921 get_tok_str(v, NULL));3922 get_tok_str(v, NULL));
@@ -7362,6 +7363,9 @@ found: · 3440 unmodified lines
7362 }7363 }
7363 sym->a = ad.a;7364 sym->a = ad.a;
7364 sym->f = ad.f;7365 sym->f = ad.f;
7366 } else if ((type.t & VT_BTYPE) == VT_VOID
7367 && !(type.t & VT_EXTERN)) {
7368 tcc_error("declaration of void object");
7365 } else {7369 } else {
7366 r = 0;7370 r = 0;
7367 if ((type.t & VT_BTYPE) == VT_FUNC) {7371 if ((type.t & VT_BTYPE) == VT_FUNC) {