File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
regression/ansi-c/function_return1 Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ void fun ()
2+ {
3+ return 5 ;
4+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+ --verbosity 2
4+ ^file main.c line 3 function fun: function has return void but a return statement returning signed int$
5+ ^SIGNAL=0$
6+
7+ --
8+ ^warning: ignoring
9+ ^CONVERSION ERROR$
Original file line number Diff line number Diff line change @@ -911,7 +911,16 @@ void c_typecheck_baset::typecheck_return(codet &code)
911911 {
912912 // gcc doesn't actually complain, it just warns!
913913 if (follow (code.op0 ().type ()).id ()!=ID_empty)
914+ {
915+ warning ().source_location =code.source_location ();
916+
917+ warning () << " function has return void " ;
918+ warning () << " but a return statement returning " ;
919+ warning () << to_string (follow (code.op0 ().type ()));
920+ warning () << eom;
921+
914922 code.op0 ().make_typecast (return_type);
923+ }
915924 }
916925 else
917926 implicit_typecast (code.op0 (), return_type);
You can’t perform that action at this time.
0 commit comments