From 469688bfee89002aa8e5a7812dcbf2b1ee9073dc Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Fri, 21 Jan 2022 00:33:06 +0100 Subject: [PATCH] [Ada] Check if- and case-expressions for unset references 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. 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. --- gcc/ada/sem_res.adb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 26da4ff..7d30f15 100644 --- 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 -- 2.7.4