GNAT has a heuristic to warn about missing return statements in
functions. This warning was escalated to errors when operating in
GNATprove mode and SPARK_Mode was On. However, this heuristic was
imprecise and caused spurious errors. Also, it was applied after the
Push_Scope/End_Scope, so for functions acting as compilation units it
was using the wrong SPARK_Mode.
It is better to simply leave this detection to GNATprove.
gcc/ada/
* sem_ch6.adb (Check_Statement_Sequence): Only warn about missing return
statements and let GNATprove emit a check when needed.
-- already, so the Assert_False is for the assertions off case.
if not Raise_Exception_Call and then not Assert_False then
-
- -- In GNATprove mode, it is an error to have a missing return
-
- Error_Msg_Warn := SPARK_Mode /= On;
-
- -- Issue error message or warning
-
Error_Msg_N
- ("RETURN statement missing following this statement<<!",
+ ("RETURN statement missing following this statement??!",
Last_Stm);
Error_Msg_N
- ("\Program_Error [<<!", Last_Stm);
+ ("\Program_Error [??!", Last_Stm);
end if;
-- Note: we set Err even though we have not issued a warning