public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2840] ada: Leave detection of missing return in functions to GNATprove
@ 2023-07-28  7:30 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2023-07-28  7:30 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:39e183a6780e4f62ac356198ec8f72a817693b89

commit r14-2840-g39e183a6780e4f62ac356198ec8f72a817693b89
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Mon Jul 10 15:02:43 2023 +0200

    ada: Leave detection of missing return in functions to GNATprove
    
    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.

Diff:
---
 gcc/ada/sem_ch6.adb | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 62ca985bf87..4e64833b3f7 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -7315,18 +7315,11 @@ package body Sem_Ch6 is
             --  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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-28  7:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28  7:30 [gcc r14-2840] ada: Leave detection of missing return in functions to GNATprove Marc Poulhi?s

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).