From 3b9c3fd1860ceaa5684d5837455084707a7848c9 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Sat, 3 Nov 2018 22:17:20 +0100 Subject: [PATCH] Fix noreturn in main() ISO C requires 'main' falling through the end without explicit returns to implicitely return 0 (if declared as returning int). --- tccgen.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tccgen.c b/tccgen.c index 7fa7e932..dece3745 100644 --- a/tccgen.c +++ b/tccgen.c @@ -7118,6 +7118,15 @@ static void gen_function(Sym *sym) local_scope = 0; rsym = 0; block(NULL, NULL, 0); + if (!(nocode_wanted & 0x20000000) + && ((func_vt.t & VT_BTYPE) == VT_INT) + && !strcmp (funcname, "main")) + { + nocode_wanted = 0; + vpushi(0); + gen_assign_cast(&func_vt); + gfunc_return(&func_vt); + } nocode_wanted = 0; gsym(rsym); gfunc_epilog();