aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2021-01-20 16:15:30 -0500
committerPierre-Marie de Rodat <derodat@adacore.com>2021-05-06 03:51:35 -0400
commite84d25c9955dfe71b401f85291a56fa7f6375b0c (patch)
tree63cda0dc9fdde1d3fdbc10e2e4ae7598173ea46e
parentbcc6807c4bbcb782cc0f1453bb9275d52a7e1638 (diff)
downloadgcc-e84d25c9955dfe71b401f85291a56fa7f6375b0c.zip
gcc-e84d25c9955dfe71b401f85291a56fa7f6375b0c.tar.gz
gcc-e84d25c9955dfe71b401f85291a56fa7f6375b0c.tar.bz2
[Ada] Missing semantic error on ineffective Others_Clause
gcc/ada/ * exp_aggr.adb (Expand_Array_Aggregate): If the expression in an Others_Clause has not been analyzed because previous analysis of the enclosing aggregate showed the clause to be ineffective i.e. cover a null range, analyze it now to detect a possible type illegality.
-rw-r--r--gcc/ada/exp_aggr.adb15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 3a37f38..f8168fe 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -5958,6 +5958,21 @@ package body Exp_Aggr is
if Nkind (First (Choice_List (Assoc))) = N_Others_Choice then
Others_Present (Dim) := True;
+
+ -- An others_clause may be superfluous if previous components
+ -- cover the full given range of a constrained array. In such
+ -- a case an others_clause does not contribute any additional
+ -- components and has not been analyzed. We analyze it now to
+ -- detect type errors in the expression, even though no code
+ -- will be generated for it.
+
+ if Dim = Aggr_Dimension
+ and then Nkind (Assoc) /= N_Iterated_Component_Association
+ and then not Analyzed (Expression (Assoc))
+ and then not Box_Present (Assoc)
+ then
+ Preanalyze_And_Resolve (Expression (Assoc), Ctyp);
+ end if;
end if;
end if;