diff mbox series

[Ada] Remove redundant initialization of Test_And_Set_Flag object

Message ID 20220111133210.GA748658@adacore.com
State New
Headers show
Series [Ada] Remove redundant initialization of Test_And_Set_Flag object | expand

Commit Message

Pierre-Marie de Rodat Jan. 11, 2022, 1:32 p.m. UTC
When expanding exception declarations we explicitly initialized the
System.Atomic_Operations.Test_And_Set.Test_And_Set_Flag object with 0.
This was redundant, because the Test_And_Set_Flag type has aspect
Default_Value => 0. It is better to not duplicate this constant in the
GNAT code, in case that the default value is changed at some point.

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

gcc/ada/

	* exp_ch11.adb (Expand_N_Exception_Declaration): Remove explicit
	initialization of the exceptF object.
diff mbox series

Patch

diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb
--- a/gcc/ada/exp_ch11.adb
+++ b/gcc/ada/exp_ch11.adb
@@ -1089,7 +1089,7 @@  package body Exp_Ch11 is
    --  (protecting test only needed if not at library level)
 
    --     exceptF : aliased System.Atomic_Operations.Test_And_Set.
-   --                         .Test_And_Set_Flag := 0; --  static data
+   --                         .Test_And_Set_Flag; --  static data
    --     if not Atomic_Test_And_Set (exceptF) then
    --        Register_Exception (except'Unrestricted_Access);
    --     end if;
@@ -1321,9 +1321,7 @@  package body Exp_Ch11 is
                       Defining_Identifier => Flag_Id,
                       Aliased_Present     => True,
                       Object_Definition   =>
-                        New_Occurrence_Of (RTE (RE_Test_And_Set_Flag), Loc),
-                      Expression          =>
-                        Make_Integer_Literal (Loc, 0));
+                        New_Occurrence_Of (RTE (RE_Test_And_Set_Flag), Loc));
                else
                   Flag_Decl :=
                     Make_Object_Declaration (Loc,