[Ada] Prevent search for references in postconditions from going too far
authorPiotr Trojanek <trojanek@adacore.com>
Sat, 22 Jan 2022 13:51:27 +0000 (14:51 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 10 May 2022 08:19:27 +0000 (08:19 +0000)
Add a standard prevention against climbing the entire compilation unit.
Cleanup only; behaviour of the compiler is unaffected.

gcc/ada/

* sem_warn.adb (Within_Postcondition): Guard against search
going too far.

gcc/ada/sem_warn.adb

index 31ba4d1..d1f2036 100644 (file)
@@ -2007,6 +2007,11 @@ package body Sem_Warn is
                               then
                                  return True;
                               end if;
+
+                           --  Prevent the search from going too far
+
+                           elsif Is_Body_Or_Package_Declaration (Nod) then
+                              exit;
                            end if;
 
                            Nod := Parent (Nod);