public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1039] ada: Better error message if non-Ada2022 code declares No_Return function
@ 2023-05-22  8:48 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2023-05-22  8:48 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e1f5cf0b14c460f04e878e8c52c90132f19c5e3f

commit r14-1039-ge1f5cf0b14c460f04e878e8c52c90132f19c5e3f
Author: Steve Baird <baird@adacore.com>
Date:   Mon Jan 30 15:41:48 2023 -0800

    ada: Better error message if non-Ada2022 code declares No_Return function
    
    When a feature that is legal in Ada2022 but not in earlier Ada versions
    is used, we typically want to call Error_Msg_Ada_2022_Feature in order to
    generate an informative message in the error case. Specifying No_Return
    for a function (as opposed to a procedure) is no exception to this rule.
    
    gcc/ada/
    
            * sem_prag.adb (Analyze_Pragma): In Check_No_Return, call
            Error_Msg_Ada_2022_Feature in the case of a function. Remove code
            outside of Check_No_Return that was querying Ada_Version.

Diff:
---
 gcc/ada/sem_prag.adb | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 6b1f9263f9d..36c1add5ea4 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -20035,7 +20035,11 @@ package body Sem_Prag is
                 N : Node_Id) return Boolean
             is
             begin
-               if Ekind (E) = E_Procedure then
+               if Ekind (E) in E_Function | E_Generic_Function then
+                  Error_Msg_Ada_2022_Feature ("No_Return function", Sloc (N));
+                  return Ada_Version >= Ada_2022;
+
+               elsif Ekind (E) = E_Procedure then
 
                   --  If E is a generic instance, marking it with No_Return
                   --  is forbidden, but having it inherit the No_Return of
@@ -20106,9 +20110,7 @@ package body Sem_Prag is
                   --  Ada 2022 (AI12-0269): A function can be No_Return
 
                   if Ekind (E) in E_Generic_Procedure | E_Procedure
-                    or else (Ada_Version >= Ada_2022
-                              and then
-                             Ekind (E) in E_Generic_Function | E_Function)
+                                   | E_Generic_Function | E_Function
                   then
                      --  Check that the pragma is not applied to a body.
                      --  First check the specless body case, to give a

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

only message in thread, other threads:[~2023-05-22  8:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22  8:48 [gcc r14-1039] ada: Better error message if non-Ada2022 code declares No_Return function 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).