aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_res.adb
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2022-01-21 00:33:06 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-10 08:19:25 +0000
commit469688bfee89002aa8e5a7812dcbf2b1ee9073dc (patch)
tree4ecbfb73be1e65decfbe3205fba5f072461a1d3d /gcc/ada/sem_res.adb
parent850bf074c5fd27abf154c704ff51bf89f1e9d56c (diff)
downloadgcc-469688bfee89002aa8e5a7812dcbf2b1ee9073dc.zip
gcc-469688bfee89002aa8e5a7812dcbf2b1ee9073dc.tar.gz
gcc-469688bfee89002aa8e5a7812dcbf2b1ee9073dc.tar.bz2
[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.
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r--gcc/ada/sem_res.adb6
1 files changed, 6 insertions, 0 deletions
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