From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id D108238708F9; Thu, 17 Dec 2020 10:51:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D108238708F9 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-6213] [Ada] Prevent In_Check_Node routine from going too far in the parent chain X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: 3e05da6849f5548db51ffa15030b1fc8aacb8d9c X-Git-Newrev: 2f29ceb054a350abb6d377472304ac9768eed11f Message-Id: <20201217105126.D108238708F9@sourceware.org> Date: Thu, 17 Dec 2020 10:51:26 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Dec 2020 10:51:26 -0000 https://gcc.gnu.org/g:2f29ceb054a350abb6d377472304ac9768eed11f commit r11-6213-g2f29ceb054a350abb6d377472304ac9768eed11f Author: Piotr Trojanek 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;