]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Ada: Fix explicit raise on subtype of lock-free protected type
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 4 Nov 2025 19:05:25 +0000 (20:05 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Tue, 4 Nov 2025 19:08:48 +0000 (20:08 +0100)
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.

gcc/ada/sem_ch3.adb
gcc/testsuite/gnat.dg/protected_subtype1.adb [new file with mode: 0644]

index 233f8237aa5de65abd0f4f7c88c61f3163f55cfa..ba0af27471d8431cbb76aaa2aec9b8a07b084014 100644 (file)
@@ -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 (file)
index 0000000..cb003c8
--- /dev/null
@@ -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;