The RM C.6(19) clause says that atomic or volatile objects of types
that are not by reference must be passed by copy in a call if the
type of the formal is not atomic or volatile respectively.  But this
requirement does not apply to initialization procedures, which are
generated by the compiler, and doing it would create extra copies
for atomic or volatile components declared in record types.

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

gcc/ada/

        * exp_ch6.adb (Requires_Atomic_Or_Volatile_Copy): Return false
        inside an initialization procedure.
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -2196,6 +2196,13 @@ package body Exp_Ch6 is
             return False;
          end if;
 
+         --  There is no requirement inside initialization procedures and this
+         --  would generate copies for atomic or volatile composite components.
+
+         if Inside_Init_Proc then
+            return False;
+         end if;
+
          --  Check for atomicity mismatch
 
          if Is_Atomic_Object (Actual) and then not Is_Atomic (E_Formal)


Reply via email to