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

commit r16-5034-gc0132281f671a79da992cec75a65c4f739ad991f
Author: Eric Botcazou <[email protected]>
Date:   Tue Nov 4 20:05:25 2025 +0100

    Ada: Fix explicit raise on subtype of lock-free protected type
    
    The issue is that the Uses_Lock_Free flag is not propagated to the subtype.
    
    gcc/ada/
            * sem_ch3.adb (Analyze_Subtype_Declaration) <Concurrent_Kind>:
            Propagate the Uses_Lock_Free flag for protected types.
    
    gcc/testsuite/
            * gnat.dg/protected_subtype1.adb: New test.

Diff:
---
 gcc/ada/sem_ch3.adb                          |  4 ++++
 gcc/testsuite/gnat.dg/protected_subtype1.adb | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 233f8237aa5d..ba0af27471d8 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -6145,6 +6145,10 @@ package body Sem_Ch3 is
                Set_Is_Tagged_Type       (Id, Is_Tagged_Type        (T));
                Set_Last_Entity          (Id, Last_Entity           (T));
 
+               if Is_Protected_Type (T) then
+                  Set_Uses_Lock_Free (Id, Uses_Lock_Free (T));
+               end if;
+
                if Is_Tagged_Type (T) then
                   Set_No_Tagged_Streams_Pragma
                     (Id, No_Tagged_Streams_Pragma (T));
diff --git a/gcc/testsuite/gnat.dg/protected_subtype1.adb 
b/gcc/testsuite/gnat.dg/protected_subtype1.adb
new file mode 100644
index 000000000000..cb003c892a18
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/protected_subtype1.adb
@@ -0,0 +1,26 @@
+-- { dg-do compile }
+
+procedure Protected_Subtype1 is
+
+   protected type Object with Lock_Free => True is
+   end Object;
+
+   protected body Object is
+   end Object;
+
+   A : Object;
+
+   subtype Object_Subtype is Object;
+
+   B : Object_Subtype;
+
+   type Rec is record
+      A : Object;         
+      B : Object_Subtype;
+   end record;
+
+   C : Rec;
+
+begin
+  null;
+end;

Reply via email to