diff mbox series

[COMMITTED,19/30] ada: Define No_Return flag only for subprograms

Message ID 20240801151738.400796-19-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/30] ada: Remove obsolete workaround | expand

Commit Message

Marc Poulhiès Aug. 1, 2024, 3:17 p.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>

...instead of defining it for all entities.

gcc/ada/

	* einfo.ads (No_Return): Change description and adjust
	accordingly.
	* gen_il-gen-gen_entities.adb (Entity_Kind): Remove No_Return.
	(Subprogram_Kind): Add No_Return.
	(Generic_Subprogram_Kind): Likewise.
	* sem_ch6.adb (Analyze_Return_Statement): Adjust No_Return test.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/einfo.ads                   | 6 +++---
 gcc/ada/gen_il-gen-gen_entities.adb | 3 ++-
 gcc/ada/sem_ch6.adb                 | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index e51ab691860..95f524e6c21 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -3799,8 +3799,8 @@  package Einfo is
 --       pragma No_Component_Reordering applies.
 
 --    No_Return
---       Defined in all entities. Set for subprograms and generic subprograms
---       to which a valid aspect or pragma No_Return applies.
+--       Defined in subprograms and generic subprograms. Set if a valid aspect
+--       or pragma No_Return applies.
 
 --    No_Strict_Aliasing [base type only]
 --       Defined in access types. Set to direct the backend to avoid any
@@ -4969,7 +4969,6 @@  package Einfo is
    --    Materialize_Entity
    --    Needs_Debug_Info
    --    Never_Set_In_Source
-   --    No_Return
    --    Overlays_Constant
    --    Referenced
    --    Referenced_As_LHS
@@ -5579,6 +5578,7 @@  package Einfo is
    --    Is_Visible_Lib_Unit
    --    Is_Wrapper
    --    Needs_No_Actuals
+   --    No_Return
    --    Requires_Overriding                  (non-generic case only)
    --    Return_Present
    --    Returns_By_Ref
diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb
index 80b5925ebb8..2e0d51f6592 100644
--- a/gcc/ada/gen_il-gen-gen_entities.adb
+++ b/gcc/ada/gen_il-gen-gen_entities.adb
@@ -215,7 +215,6 @@  begin -- Gen_IL.Gen.Gen_Entities
         Sm (Needs_Activation_Record, Flag),
         Sm (Needs_Debug_Info, Flag),
         Sm (Never_Set_In_Source, Flag),
-        Sm (No_Return, Flag),
         Sm (Overlays_Constant, Flag),
         Sm (Prev_Entity, Node_Id),
         Sm (Referenced, Flag),
@@ -985,6 +984,7 @@  begin -- Gen_IL.Gen.Gen_Entities
         Sm (Linker_Section_Pragma, Node_Id),
         Sm (Overridden_Operation, Node_Id),
         Sm (Protected_Body_Subprogram, Node_Id),
+        Sm (No_Return, Flag),
         Sm (Scope_Depth_Value, Unat),
         Sm (Static_Call_Helper, Node_Id),
         Sm (SPARK_Pragma, Node_Id),
@@ -1193,6 +1193,7 @@  begin -- Gen_IL.Gen.Gen_Entities
        (Sm (Has_Out_Or_In_Out_Parameter, Flag),
         Sm (Is_Primitive, Flag),
         Sm (Next_Inlined_Subprogram, Node_Id),
+        Sm (No_Return, Flag),
         Sm (Overridden_Operation, Node_Id)));
 
    Cc (E_Generic_Function, Generic_Subprogram_Kind,
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 852055a3586..0988fad97e8 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -1937,8 +1937,8 @@  package body Sem_Ch6 is
       --  Check that pragma No_Return is obeyed. Don't complain about the
       --  implicitly-generated return that is placed at the end.
 
-      if No_Return (Scope_Id)
-        and then Kind in E_Procedure | E_Generic_Procedure
+      if Kind in E_Procedure | E_Generic_Procedure
+        and then No_Return (Scope_Id)
         and then Comes_From_Source (N)
       then
          Error_Msg_N