https://gcc.gnu.org/g:a2a400aca24fc13da3628d0cd871512ca4e92241

commit r16-9019-ga2a400aca24fc13da3628d0cd871512ca4e92241
Author: Piotr Trojanek <[email protected]>
Date:   Fri Mar 13 12:54:06 2026 +0100

    ada: Suppress warning about unused variable in trivial quantification
    
    When condition of a quantification expression is written as True or False, 
then
    the user has likely done this on purpose and there is no need for a warning.
    
    gcc/ada/ChangeLog:
    
            * sem_ch4.adb (Analyze_Quantified_Expression): Suppress warning for
            trivial conditions.

Diff:
---
 gcc/ada/sem_ch4.adb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 6aecf1ae21d8..48f4a8bd8cac 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -4817,10 +4817,10 @@ package body Sem_Ch4 is
            and then not Is_Internal_Name (Chars (Loop_Id))
            and then not Has_Junk_Name (Loop_Id)
          then
-            if not Referenced (Loop_Id, Cond) then
-               Error_Msg_N ("?.t?unused variable &", Loop_Id);
-            else
+            if 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);
             end if;
          end if;
       end;

Reply via email to