https://gcc.gnu.org/g:0d47252de16a026df2cf42076f225e1a940e4cac
commit r16-9020-g0d47252de16a026df2cf42076f225e1a940e4cac Author: Piotr Trojanek <[email protected]> Date: Mon Mar 16 13:40:44 2026 +0100 ada: Suppress warning for quantified expression with filters If quantified expression has a filter, it becomes less clear whether we should warn about quantified variable not being used. gcc/ada/ChangeLog: * sem_ch4.adb (Analyze_Quantified_Expression): If there is a filter, then suppress the warning. Diff: --- gcc/ada/sem_ch4.adb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 48f4a8bd8cac..6d6e8c4782b9 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -4670,6 +4670,7 @@ package body Sem_Ch4 is Cond : constant Node_Id := Condition (N); Loc : constant Source_Ptr := Sloc (N); + Filter : Node_Id; Loop_Id : Entity_Id; QE_Scop : Entity_Id; @@ -4765,8 +4766,10 @@ package body Sem_Ch4 is if Present (Iterator_Specification (N)) then Loop_Id := Defining_Identifier (Iterator_Specification (N)); + Filter := Iterator_Filter (Iterator_Specification (N)); else Loop_Id := Defining_Identifier (Loop_Parameter_Specification (N)); + Filter := Iterator_Filter (Loop_Parameter_Specification (N)); end if; declare @@ -4817,7 +4820,12 @@ package body Sem_Ch4 is and then not Is_Internal_Name (Chars (Loop_Id)) and then not Has_Junk_Name (Loop_Id) then - if Referenced (Loop_Id, Cond) then + -- If there is a filter, then it is less clear whether the loop + -- variable is used or not; just ignore this case, for simplicity. + + if Present (Filter) then + null; + elsif Referenced (Loop_Id, Cond) then Check_Subexpr (Cond, Kind => Full); elsif not Is_Trivial_Boolean (Cond) then Error_Msg_N ("?.t?unused variable &", Loop_Id);
