diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2020-12-04 13:00:10 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-12-17 05:49:23 -0500 |
commit | 2f29ceb054a350abb6d377472304ac9768eed11f (patch) | |
tree | 39119f0a248f9afb4624e2bc8a005aa2a039fdc5 | |
parent | 3e05da6849f5548db51ffa15030b1fc8aacb8d9c (diff) | |
download | gcc-2f29ceb054a350abb6d377472304ac9768eed11f.zip gcc-2f29ceb054a350abb6d377472304ac9768eed11f.tar.gz gcc-2f29ceb054a350abb6d377472304ac9768eed11f.tar.bz2 |
[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.
-rw-r--r-- | gcc/ada/sem_util.adb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 20ec907..759c727 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; |