public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-6213] [Ada] Prevent In_Check_Node routine from going too far in the parent chain
@ 2020-12-17 10:51 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-12-17 10:51 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2f29ceb054a350abb6d377472304ac9768eed11f
commit r11-6213-g2f29ceb054a350abb6d377472304ac9768eed11f
Author: Piotr Trojanek <trojanek@adacore.com>
Date: Fri Dec 4 13:00:10 2020 +0100
[Ada] Prevent In_Check_Node routine from going too far in the parent chain
gcc/ada/
* sem_util.adb (In_Check_Node): Add guard and rename Node to
Par, just like it is done in surrounding routines, e.g.
In_Assertion_Expression_Pragma and In_Generic_Formal_Package.
Diff:
---
gcc/ada/sem_util.adb | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 20ec9075a51..759c727b29b 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -13878,14 +13878,20 @@ package body Sem_Util is
-------------------
function In_Check_Node (N : Node_Id) return Boolean is
- Node : Node_Id := Parent (N);
+ Par : Node_Id := Parent (N);
begin
- while Present (Node) loop
- if Nkind (Node) in N_Raise_xxx_Error then
+ while Present (Par) loop
+ if Nkind (Par) in N_Raise_xxx_Error then
return True;
- end if;
- Node := Parent (Node);
+ -- Prevent the search from going too far
+
+ elsif Is_Body_Or_Package_Declaration (Par) then
+ return False;
+
+ else
+ Par := Parent (Par);
+ end if;
end loop;
return False;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-12-17 10:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17 10:51 [gcc r11-6213] [Ada] Prevent In_Check_Node routine from going too far in the parent chain Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).