===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -2052,6 +2052,13 @@
Set_Parent (Expr, Parent (Expression (Assoc)));
Analyze (Expr);
+ -- Compute its dimensions now, rather than at the end
+ -- of resolution, because in the case of multidimensional
+ -- aggregates subsequent expansion may lead to spurious
+ -- errors.
+
+ Check_Expression_Dimensions (Expr, Component_Typ);
+
-- If the expression is a literal, propagate this info
-- to the expression in the association, to enable some
-- optimizations downstream.
===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 2011-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -1235,10 +1235,12 @@
-- since it may not be decorated at this point. We also don't want to
-- issue the same error message multiple times on the same expression
-- (may happen when an aggregate is converted into a positional
- -- aggregate).
+ -- aggregate). We also must verify that this is a scalar component,
+ -- and not a subaggregate of a multidimensional aggregate.
if Comes_From_Source (Original_Node (Expr))
and then Present (Etype (Expr))
+ and then Is_Numeric_Type (Etype (Expr))
and then Dimensions_Of (Expr) /= Dims_Of_Comp_Typ
and then Sloc (Comp) /= Sloc (Prev (Comp))
then
@@ -2270,6 +2272,27 @@
end case;
end Analyze_Dimension_Unary_Op;
+ ---------------------------------
+ -- Check_Expression_Dimensions --
+ ---------------------------------
+
+ procedure Check_Expression_Dimensions
+ (Expr : Node_Id;
+ Typ : Entity_Id)
+ is
+ begin
+ if Is_Floating_Point_Type (Etype (Expr)) then
+ Analyze_Dimension (Expr);
+
+ if Dimensions_Of (Expr) /= Dimensions_Of (Typ) then
+ Error_Msg_N ("dimensions mismatch in array aggregate", Expr);
+ Error_Msg_N
+ ("\expected dimension " & Dimensions_Msg_Of (Typ)
+ & ", found " & Dimensions_Msg_Of (Expr), Expr);
+ end if;
+ end if;
+ end Check_Expression_Dimensions;
+
---------------------
-- Copy_Dimensions --
---------------------
===================================================================
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
+-- Copyright (C) 2011-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -164,6 +164,16 @@
-- For sub spec N, issue a warning for each dimensioned formal with a
-- literal default value in the list of formals Formals.
+ procedure Check_Expression_Dimensions
+ (Expr : Node_Id;
+ Typ : Entity_Id);
+ -- Compute dimensions of a floating-point expression and compare them
+ -- with the dimensions of a the given type. Used to verify dimensions
+ -- of the components of a multidimensional array type, for which components
+ -- are typically themselves arrays. The resolution of such arrays delays
+ -- the resolution of the ultimate components to a separate phase, which
+ -- forces this separate dimension verification.
+
procedure Copy_Dimensions (From, To : Node_Id);
-- Copy dimension vector of node From to node To. Note that To must be a
-- node that is allowed to contain a dimension (see OK_For_Dimension in