https://gcc.gnu.org/g:e932c5f8365954ea90da7c6b4ff1a994b8ae927f
commit r17-854-ge932c5f8365954ea90da7c6b4ff1a994b8ae927f Author: Piotr Trojanek <[email protected]> Date: Mon Feb 16 15:23:41 2026 +0100 ada: Remove spurious error on attribute Count with expansion disabled When expansion is disabled, e.g. because of GNAT switch -gnatc or because GNAT is operating in the GNATprove mode, then attribute Count is not expanded and can legitimately appear in a barrier of a protected entry, even if restriction Pure_Barriers is enabled. gcc/ada/ChangeLog: * exp_ch9.adb (Is_Pure_Barrier): Handle unexpanded attribute Count. Diff: --- gcc/ada/exp_ch9.adb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index 6e1e0fedf34c..08ff42ee32b0 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -5746,6 +5746,30 @@ package body Exp_Ch9 is null; end case; + when N_Attribute_Reference => + + -- Attribute Count has been already expanded to function call, + -- or it is illegal, or expansion is disabled and attribute + -- is legal, i.e. it is prefixed by a name of entry or by a + -- indexed entry family of the current protected object. + + if Attribute_Name (N) = Name_Count then + pragma Assert + (if Serious_Errors_Detected = 0 + then not Expander_Active + and then + ((Is_Entity_Name (Prefix (N)) + and then Is_Entry (Entity (Prefix (N))) + and then Scope (Entity (Prefix (N))) = Prot) + or else + (Nkind (Prefix (N)) = N_Indexed_Component + and then Is_Entity_Name (Prefix (Prefix (N))) + and then Is_Entry (Entity (Prefix (Prefix (N)))) + and then Scope (Entity (Prefix (Prefix (N)))) = Prot)) + ); + return Skip; + end if; + when N_Function_Call => -- Function call checks are carried out as part of the analysis
