]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Prevent search of calls in preconditions from going too far
authorPiotr Trojanek <trojanek@adacore.com>
Sat, 4 Mar 2023 17:07:55 +0000 (18:07 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 25 May 2023 07:44:17 +0000 (09:44 +0200)
When determining whether a call to protected function appears within
a pragma expression we can safely stop at the subprogram body.

Cleanup related to recently added support for a new SPARK aspects,
whose implementation was based on Contract_Cases.

gcc/ada/

* sem_util.adb (Check_Internal_Protected_Use): Add standard protection
against search going too far.

gcc/ada/sem_util.adb

index 2e2fb911c3885eb5a43f6e4bb9ff50b59c7d9e8c..bfe1b9fc74d9fded77438c21b1aa33291328b0a5 100644 (file)
@@ -3501,6 +3501,11 @@ package body Sem_Util is
                     ("internal call cannot appear in default for formal of "
                      & "protected operation", N);
                   return;
+
+               --  Prevent the search from going too far
+
+               elsif Is_Body_Or_Package_Declaration (P) then
+                  exit;
                end if;
 
                P := Parent (P);