[Ada] Simplify initialization of concurrent components

Message ID 20211011133919.GA1518826@adacore.com
State New
Headers show
  • [Ada] Simplify initialization of concurrent components
Related show

Commit Message

Jeff Law via Gcc-patches Oct. 11, 2021, 1:39 p.m.
Concurrent record types are either task record types or protected record
types. Now we detect them collectively (when looking for any of them) or
exclusively (when looking for one or the other).

Cleanup code related to fixes in expansion of boxes in record
aggregates. Behaviour is unaffected.

Tested on x86_64-pc-linux-gnu, committed on trunk


	* exp_ch3.adb (Build_Init_Statements): Simplify detection of
	concurrent record types.


diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -3206,9 +3206,7 @@  package body Exp_Ch3 is
          --  types moving any expanded code from the spec to the body of the
          --  init procedure.
-         if Is_Task_Record_Type (Rec_Type)
-           or else Is_Protected_Record_Type (Rec_Type)
-         then
+         if Is_Concurrent_Record_Type (Rec_Type) then
                Decl : constant Node_Id :=
                         Parent (Corresponding_Concurrent_Type (Rec_Type));
@@ -3589,12 +3587,11 @@  package body Exp_Ch3 is
                   end loop;
                end if;
-         end if;
          --  For a protected type, add statements generated by
          --  Make_Initialize_Protection.
-         if Is_Protected_Record_Type (Rec_Type) then
+         elsif Is_Protected_Record_Type (Rec_Type) then
             Append_List_To (Stmts,
               Make_Initialize_Protection (Rec_Type));
          end if;