This is a regression present on the mainline and 15 branch: the compiler
gives a bogus "potentially unsynchronized barrier" when the condition of
an entry barrier requires the creation of a controlled temporary, because
it comes with a transient scope that fools the test on scopes done in the
Is_Global_Entity procedure.
gcc/ada/
PR ada/124025
* exp_ch9.adb (Expand_Entry_Barrier.Is_Global_Entity): Use
Scope_Within_Or_Same to test whether the object is local.
gcc/testsuite/
* gnat.dg/protected_type1.adb: New test.
Co-authored-by: Liam Powell <liam@liampwll.com>
-- during expansion, it is ok. If expansion is not performed,
-- then Func is Empty so this test cannot succeed.
- if Scope (E) = Func_Id then
+ if Scope_Within_Or_Same (S, Func_Id) then
null;
-- A protected call from a barrier to another object is ok
--- /dev/null
+-- { dg-do compile }
+
+with Ada.Finalization;
+
+procedure Protected_Type1 is
+
+ type T is new Ada.Finalization.Controlled with null record;
+
+ protected type Queue is
+ entry Get_Next_Line (Line : out String);
+ private
+ A : T;
+ end Queue;
+
+ protected body Queue is
+ entry Get_Next_Line (Line : out String)
+ when A /= (Ada.Finalization.Controlled with null record) is
+ begin
+ null;
+ end Get_Next_Line;
+ end Queue;
+
+begin
+ null;
+end;