From 61ba9f229955f105af9d7dcdbfcc9c9effbe8af3 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Fri, 3 Aug 2018 22:39:00 +0200 Subject: [PATCH] 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. --- tccgen.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tccgen.c b/tccgen.c index a573e6b..7fa7e93 100644 --- a/tccgen.c +++ b/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) {