Detection of references to unset (uninitialized) objects requires calls
to Check_Unset_Reference on every subexpression of a composite statement
and expression. This was missing for if-expressions and incomplete for
case-expressions.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_res.adb (Resolve_Case_Expression): Check alternative
expressions for references to unset objects.
(Resolve_If_Expression): Check condition, then and else
expressions for references to unset objects.
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -7394,6 +7394,7 @@ package body Sem_Res is
end if;
Resolve (Alt_Expr, Typ);
+ Check_Unset_Reference (Alt_Expr);
Alt_Typ := Etype (Alt_Expr);
-- When the expression is of a scalar subtype different from the
@@ -9317,6 +9318,9 @@ package body Sem_Res is
Resolve (Condition, Any_Boolean);
Resolve (Then_Expr, Result_Type);
+ Check_Unset_Reference (Condition);
+ Check_Unset_Reference (Then_Expr);
+
Apply_Check (Then_Expr);
-- If ELSE expression present, just resolve using the determined type
@@ -9333,6 +9337,8 @@ package body Sem_Res is
Resolve (Else_Expr, Result_Type);
end if;
+ Check_Unset_Reference (Else_Expr);
+
Apply_Check (Else_Expr);
-- Apply RM 4.5.7 (17/3): whether the expression is statically or