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
39163916 get_tok_str(v, NULL));
39173917 }
39183918 if ((type1.t & VT_BTYPE) == VT_FUNC ||
3919+ (type1.t & VT_BTYPE) == VT_VOID ||
39193920 (type1.t & VT_STORAGE))
39203921 tcc_error("invalid type for '%s'",
39213922 get_tok_str(v, NULL));
@@ -7362,6 +7363,9 @@ found: · 3440 unmodified lines
73627363 }
73637364 sym->a = ad.a;
73647365 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");
73657369 } else {
73667370 r = 0;
73677371 if ((type.t & VT_BTYPE) == VT_FUNC) {