From: Eric Botcazou Date: Sun, 8 Feb 2026 23:55:45 +0000 (+0100) Subject: Ada: Fix bogus "potentially unsynchronized barrier" warning X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3350e383b057fb7816f0f51ed6c3d36b7ca690d0;p=thirdparty%2Fgcc.git Ada: Fix bogus "potentially unsynchronized barrier" warning 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 --- diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index a2769df383d..2f5446e79f1 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -5596,7 +5596,7 @@ package body Exp_Ch9 is -- 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 diff --git a/gcc/testsuite/gnat.dg/protected_type1.adb b/gcc/testsuite/gnat.dg/protected_type1.adb new file mode 100644 index 00000000000..44ae6745193 --- /dev/null +++ b/gcc/testsuite/gnat.dg/protected_type1.adb @@ -0,0 +1,25 @@ +-- { 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;