Fix noreturn in main()

ISO C requires 'main' falling through the end without explicit
returns to implicitely return 0 (if declared as returning int).
This commit is contained in:
Michael Matz 2018-11-03 22:17:20 +01:00
parent 61ba9f2299
commit 3b9c3fd186
1 changed files with 9 additions and 0 deletions

View File

@ -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();