The problem is that the Uses_Lock_Free flag is not propagated to the subtype.
Tested on x86-64/Linux, applied on the mainline.
2025-11-04 Eric Botcazou <[email protected]>
PR ada/84320
* sem_ch3.adb (Analyze_Subtype_Declaration) <Concurrent_Kind>:
Propagate the Uses_Lock_Free flag for protected types.
2025-11-04 Eric Botcazou <[email protected]>
* gnat.dg/protected_subtype1.adb: New test.
--
Eric Botcazou-- { 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;
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 233f8237aa5..ba0af27471d 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));