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.
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));
--- /dev/null
+-- { 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;