aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-10-28 07:42:54 +0100
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-11-12 14:00:52 +0100
commit1d602710a2feb91b66cb09d2d18bdbe7d429dee9 (patch)
treedc6b8c635260c0d6b950ac7adfda69595326ce31
parentf0a2e57d0525b3372d5de543c77c5e1d7f830c69 (diff)
downloadgcc-1d602710a2feb91b66cb09d2d18bdbe7d429dee9.zip
gcc-1d602710a2feb91b66cb09d2d18bdbe7d429dee9.tar.gz
gcc-1d602710a2feb91b66cb09d2d18bdbe7d429dee9.tar.bz2
ada: Remove couple of irregular calls to Resolve_Aggr_Expr
The function is supposed to be passed an expression, but it is passed the enclosing N_Component_Association node in a couple of cases, only to give an error that can as well be given in the caller, at the cost of bypasses to disable most of its processing. gcc/ada/ChangeLog: * sem_aggr.adb (Resolve_Array_Aggregate): In the case of an others choice with a box, do not call Resolve_Aggr_Exp and give the error for a multidimensional array directly. (Resolve_Aggr_Expr): Remove bypasses for above case.
-rw-r--r--gcc/ada/sem_aggr.adb44
1 files changed, 12 insertions, 32 deletions
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 0faca28..9a7d352 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -1649,10 +1649,6 @@ package body Sem_Aggr is
-- for discrete choices such as "L .. H => Expr" or the OTHERS choice).
-- In this event we do not resolve Expr unless expansion is disabled.
-- To know why, see the DELAYED COMPONENT RESOLUTION note above.
- --
- -- NOTE: In the case of "... => <>", we pass the N_Component_Association
- -- node as Expr, since there is no Expression and we need a Sloc for the
- -- error message.
function Resolve_Iterated_Component_Association
(N : Node_Id;
@@ -2039,13 +2035,6 @@ package body Sem_Aggr is
end if;
end if;
- -- If it's "... => <>", nothing to resolve
-
- if Nkind (Expr) = N_Component_Association then
- pragma Assert (Box_Present (Expr));
- return Success;
- end if;
-
-- Ada 2005 (AI-231): Propagate the type to the nested aggregate.
-- Required to check the null-exclusion attribute (if present).
-- This value may be overridden later on.
@@ -2062,13 +2051,6 @@ package body Sem_Aggr is
end if;
else
- -- If it's "... => <>", nothing to resolve
-
- if Nkind (Expr) = N_Component_Association then
- pragma Assert (Box_Present (Expr));
- return Success;
- end if;
-
-- Do not resolve the expressions of discrete or others choices
-- unless the expression covers a single component, or else the
-- expander is inactive or this is a spec expression.
@@ -3095,15 +3077,13 @@ package body Sem_Aggr is
if Box_Present (Assoc) then
- -- Ada 2005 (AI-287): In case of default initialization of a
- -- component the expander will generate calls to the
- -- corresponding initialization subprogram. We need to call
- -- Resolve_Aggr_Expr to check the rules about
- -- dimensionality.
+ -- Ada 2005 (AI-287): In case of default initialization of
+ -- a component, the expander will generate calls to the
+ -- corresponding initialization subprogram. Check that we
+ -- have a single dimension.
- if not Resolve_Aggr_Expr
- (Assoc, Single_Elmt => Single_Choice)
- then
+ if Present (Next_Index (Index)) then
+ Error_Msg_N ("nested array aggregate expected", Assoc);
return Failure;
end if;
@@ -3635,13 +3615,13 @@ package body Sem_Aggr is
if Box_Present (Assoc) then
- -- Ada 2005 (AI-287): In case of default initialization of a
- -- component the expander will generate calls to the
- -- corresponding initialization subprogram. We need to call
- -- Resolve_Aggr_Expr to check the rules about
- -- dimensionality.
+ -- Ada 2005 (AI-287): In case of default initialization of
+ -- a component, the expander will generate calls to the
+ -- corresponding initialization subprogram. Check that we
+ -- have a single dimension.
- if not Resolve_Aggr_Expr (Assoc, Single_Elmt => False) then
+ if Present (Next_Index (Index)) then
+ Error_Msg_N ("nested array aggregate expected", Assoc);
return Failure;
end if;