From: Viljar Indus <[email protected]>

Some expansions and optimizations wrap the existing code in
functions that loose the range constraints of the original
variable. We should avoid triggering bogus errors in such scenarios.

gcc/ada/ChangeLog:

        * sem_warn.adb (Warn_On_Suspicious_Index): Only check elements
        that are coming from source.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_warn.adb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index 962a2230cc8..a1d421898df 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -4423,6 +4423,7 @@ package body Sem_Warn is
             if Is_Formal (Ent)
               and then Is_Suspicious_Type (Typ)
               and then not Low_Bound_Tested (Ent)
+              and then Comes_From_Source (Ent)
             then
                Test_Suspicious_Index;
             end if;
-- 
2.53.0

Reply via email to