From: Piotr Trojanek <[email protected]>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/exp_util.adb | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
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;
--
2.51.0