From: Piotr Trojanek Date: Wed, 22 Oct 2025 15:38:04 +0000 (+0200) Subject: ada: Guard compile-time evaluator against rewritten if-expressions X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=85b6344379e7463c7cca0d731a09e122467dc1b6;p=thirdparty%2Fgcc.git ada: Guard compile-time evaluator against rewritten if-expressions A hopefully temporary fix for if-expression that has been rewritten into an if-statement, where a object reference has the if-statement as its parent, but is not part of the condition, then statements or else statements. gcc/ada/ChangeLog: * exp_util.adb (Get_Current_Value_Condition): Guard against orphaned references in rewritten if-expressions. --- diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index f1893c26e3a..e2d2554d3a1 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -7663,9 +7663,12 @@ package body Exp_Util is if Previous = Condition (If_Stmt) then return; - else - pragma Assert - (List_Containing (Previous) + -- Guard against if-statements coming from if-statements + -- with broken chain of parents. + + elsif Is_List_Member (Previous) then + pragma Assert ( + List_Containing (Previous) in Then_Statements (If_Stmt) | Elsif_Parts (If_Stmt) | Else_Statements (If_Stmt)); @@ -7674,6 +7677,9 @@ package body Exp_Util is (if CV = If_Stmt then List_Containing (Previous) = Then_Statements (CV) else Previous = CV); + else + pragma Assert (From_Conditional_Expression (If_Stmt)); + return; end if; else return;