Commit d976bf74 by Arnaud Charlet

[multiple changes]

2012-10-01  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_ch3.adb (Analyze_Declarations): Remove the specialized
	code which prevents freezing when the declarative list contains
	a _postconditions body. This is no longer needed because the
	body is now inserted at the end of the declarations.
	* sem_ch6.adb (Insert_After_Last_Declaration): New routine.
	(Insert_Before_First_Source_Declaration): Removed.
	(Process_PPCs): Insert the _postconditions body at the end of
	the declarative list to prevent premature freezing of types that
	appear in the declarations.

2012-10-01  Robert Dewar  <dewar@adacore.com>

	* sem_aggr.adb, sem_dim.adb: Minor reformatting.

From-SVN: r191911
parent 0929eaeb
2012-10-01 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch3.adb (Analyze_Declarations): Remove the specialized
code which prevents freezing when the declarative list contains
a _postconditions body. This is no longer needed because the
body is now inserted at the end of the declarations.
* sem_ch6.adb (Insert_After_Last_Declaration): New routine.
(Insert_Before_First_Source_Declaration): Removed.
(Process_PPCs): Insert the _postconditions body at the end of
the declarative list to prevent premature freezing of types that
appear in the declarations.
2012-10-01 Robert Dewar <dewar@adacore.com>
* sem_aggr.adb, sem_dim.adb: Minor reformatting.
2012-10-01 Ed Schonberg <schonberg@adacore.com> 2012-10-01 Ed Schonberg <schonberg@adacore.com>
* sem_prag.adb (Process_Convention, Process_Import_Or_Interface): * sem_prag.adb (Process_Convention, Process_Import_Or_Interface):
......
...@@ -2550,7 +2550,7 @@ package body Sem_Aggr is ...@@ -2550,7 +2550,7 @@ package body Sem_Aggr is
Duplicate_Subexpr (High_Bound (Aggregate_Bounds (N)))); Duplicate_Subexpr (High_Bound (Aggregate_Bounds (N))));
end if; end if;
-- Check the dimensions of each component in the array aggregate. -- Check the dimensions of each component in the array aggregate
Analyze_Dimension_Array_Aggregate (N, Component_Typ); Analyze_Dimension_Array_Aggregate (N, Component_Typ);
...@@ -3392,6 +3392,7 @@ package body Sem_Aggr is ...@@ -3392,6 +3392,7 @@ package body Sem_Aggr is
-- propagate here the dimensions form Expr to New_Expr. -- propagate here the dimensions form Expr to New_Expr.
Move_Dimensions (Expr, New_Expr); Move_Dimensions (Expr, New_Expr);
else else
New_Expr := Expr; New_Expr := Expr;
end if; end if;
...@@ -4504,7 +4505,7 @@ package body Sem_Aggr is ...@@ -4504,7 +4505,7 @@ package body Sem_Aggr is
Rewrite (N, New_Aggregate); Rewrite (N, New_Aggregate);
end Step_8; end Step_8;
-- Check the dimensions of the components in the record aggregate. -- Check the dimensions of the components in the record aggregate
Analyze_Dimension_Extension_Or_Record_Aggregate (N); Analyze_Dimension_Extension_Or_Record_Aggregate (N);
end Resolve_Record_Aggregate; end Resolve_Record_Aggregate;
......
...@@ -2152,9 +2152,7 @@ package body Sem_Ch3 is ...@@ -2152,9 +2152,7 @@ package body Sem_Ch3 is
-- explicitly checked that all required types are properly frozen, -- explicitly checked that all required types are properly frozen,
-- and we do not cause general freezing here. This special circuit -- and we do not cause general freezing here. This special circuit
-- is used when the encountered body is marked as having already -- is used when the encountered body is marked as having already
-- been analyzed (although we must take into account the special -- been analyzed.
-- case of the internally generated subprogram _postconditions,
-- may not have been analyzed yet)
-- In all other cases (bodies that come from source, and expander -- In all other cases (bodies that come from source, and expander
-- generated bodies that have not been analyzed yet), freeze all -- generated bodies that have not been analyzed yet), freeze all
...@@ -2170,11 +2168,6 @@ package body Sem_Ch3 is ...@@ -2170,11 +2168,6 @@ package body Sem_Ch3 is
N_Task_Body) N_Task_Body)
or else or else
Nkind (Next_Node) in N_Body_Stub) Nkind (Next_Node) in N_Body_Stub)
and then not
(Ada_Version = Ada_2012
and then Nkind (Next_Node) = N_Subprogram_Body
and then Chars (Defining_Entity (Next_Node))
= Name_uPostconditions)
then then
Adjust_D; Adjust_D;
Freeze_All (Freeze_From, D); Freeze_All (Freeze_From, D);
......
...@@ -11091,8 +11091,8 @@ package body Sem_Ch6 is ...@@ -11091,8 +11091,8 @@ package body Sem_Ch6 is
-- references to parameters of the inherited subprogram to point to the -- references to parameters of the inherited subprogram to point to the
-- corresponding parameters of the current subprogram. -- corresponding parameters of the current subprogram.
procedure Insert_Before_First_Source_Declaration (Nod : Node_Id); procedure Insert_After_Last_Declaration (Nod : Node_Id);
-- Insert node Nod before the first source declaration of the context -- Insert node Nod after the last declaration of the context
function Invariants_Or_Predicates_Present return Boolean; function Invariants_Or_Predicates_Present return Boolean;
-- Determines if any invariants or predicates are present for any OUT -- Determines if any invariants or predicates are present for any OUT
...@@ -11285,35 +11285,20 @@ package body Sem_Ch6 is ...@@ -11285,35 +11285,20 @@ package body Sem_Ch6 is
return CP; return CP;
end Grab_PPC; end Grab_PPC;
-------------------------------------------- -----------------------------------
-- Insert_Before_First_Source_Declaration -- -- Insert_After_Last_Declaration --
-------------------------------------------- -----------------------------------
procedure Insert_Before_First_Source_Declaration (Nod : Node_Id) is procedure Insert_After_Last_Declaration (Nod : Node_Id) is
Decls : constant List_Id := Declarations (N); Decls : constant List_Id := Declarations (N);
Decl : Node_Id;
begin begin
if No (Decls) then if No (Decls) then
Set_Declarations (N, New_List (Nod)); Set_Declarations (N, New_List (Nod));
else else
Decl := First (Decls); Append_To (Decls, Nod);
while Present (Decl) loop
if Comes_From_Source (Decl) then
exit;
end if;
Next (Decl);
end loop;
if No (Decl) then
Append_To (Decls, Nod);
else
Insert_Before (Decl, Nod);
end if;
end if; end if;
end Insert_Before_First_Source_Declaration; end Insert_After_Last_Declaration;
-------------------------------------- --------------------------------------
-- Invariants_Or_Predicates_Present -- -- Invariants_Or_Predicates_Present --
...@@ -11797,12 +11782,26 @@ package body Sem_Ch6 is ...@@ -11797,12 +11782,26 @@ package body Sem_Ch6 is
-- The entity for the _Postconditions procedure -- The entity for the _Postconditions procedure
begin begin
-- Insert the corresponding body of a post condition pragma before -- Insert the corresponding body of a post condition pragma after
-- the first source declaration of the context. This ensures that -- the last declaration of the context. This ensures that the body
-- any [sub]types generated in relation to the formals of the -- will not cause any premature freezing as it may mention types:
-- subprogram are still visible in the _postcondition body.
-- procedure Proc (Obj : Array_Typ) is
Insert_Before_First_Source_Declaration ( -- procedure _postconditions is
-- begin
-- ... Obj ...
-- end _postconditions;
-- subtype T is Array_Typ (Obj'First (1) .. Obj'Last (1));
-- begin
-- In the example above, Obj is of type T but the incorrect
-- placement of _postconditions will cause a crash in gigi due to
-- an out of order reference. The body of _postconditions must be
-- placed after the declaration of Temp to preserve correct
-- visibility.
Insert_After_Last_Declaration (
Make_Subprogram_Body (Loc, Make_Subprogram_Body (Loc,
Specification => Specification =>
Make_Procedure_Specification (Loc, Make_Procedure_Specification (Loc,
......
...@@ -1132,9 +1132,7 @@ package body Sem_Dim is ...@@ -1132,9 +1132,7 @@ package body Sem_Dim is
-- Aspect is an Ada 2012 feature. Note that there is no need to check -- Aspect is an Ada 2012 feature. Note that there is no need to check
-- dimensions for nodes that don't come from source. -- dimensions for nodes that don't come from source.
if Ada_Version < Ada_2012 if Ada_Version < Ada_2012 or else not Comes_From_Source (N) then
or else not Comes_From_Source (N)
then
return; return;
end if; end if;
...@@ -1226,6 +1224,7 @@ package body Sem_Dim is ...@@ -1226,6 +1224,7 @@ package body Sem_Dim is
end if; end if;
while Present (Comp) loop while Present (Comp) loop
-- Get the expression from the component -- Get the expression from the component
if Nkind (Comp) = N_Component_Association then if Nkind (Comp) = N_Component_Association then
...@@ -1255,10 +1254,12 @@ package body Sem_Dim is ...@@ -1255,10 +1254,12 @@ package body Sem_Dim is
Error_Detected := True; Error_Detected := True;
end if; end if;
Error_Msg_N ("\expected dimension " & Error_Msg_N
Dimensions_Msg_Of (Comp_Typ) & ", found " & ("\expected dimension "
Dimensions_Msg_Of (Expr), & Dimensions_Msg_Of (Comp_Typ)
Expr); & ", found "
& Dimensions_Msg_Of (Expr),
Expr);
end if; end if;
-- Look at the named components right after the positional components -- Look at the named components right after the positional components
...@@ -1301,7 +1302,7 @@ package body Sem_Dim is ...@@ -1301,7 +1302,7 @@ package body Sem_Dim is
is is
begin begin
Error_Msg_N ("dimensions mismatch in assignment", N); Error_Msg_N ("dimensions mismatch in assignment", N);
Error_Msg_N ("\left-hand side " & Dimensions_Msg_Of (Lhs, True), N); Error_Msg_N ("\left-hand side " & Dimensions_Msg_Of (Lhs, True), N);
Error_Msg_N ("\right-hand side " & Dimensions_Msg_Of (Rhs, True), N); Error_Msg_N ("\right-hand side " & Dimensions_Msg_Of (Rhs, True), N);
end Error_Dim_Msg_For_Assignment_Statement; end Error_Dim_Msg_For_Assignment_Statement;
...@@ -1337,7 +1338,7 @@ package body Sem_Dim is ...@@ -1337,7 +1338,7 @@ package body Sem_Dim is
"dimensions", "dimensions",
N, N,
Entity (N)); Entity (N));
Error_Msg_N ("\left operand " & Dimensions_Msg_Of (L, True), N); Error_Msg_N ("\left operand " & Dimensions_Msg_Of (L, True), N);
Error_Msg_N ("\right operand " & Dimensions_Msg_Of (R, True), N); Error_Msg_N ("\right operand " & Dimensions_Msg_Of (R, True), N);
end Error_Dim_Msg_For_Binary_Op; end Error_Dim_Msg_For_Binary_Op;
...@@ -1551,6 +1552,8 @@ package body Sem_Dim is ...@@ -1551,6 +1552,8 @@ package body Sem_Dim is
Ada_Numerics_Generic_Elementary_Functions); Ada_Numerics_Generic_Elementary_Functions);
end Is_Elementary_Function_Entity; end Is_Elementary_Function_Entity;
-- Start of processing for Elementary_Function_Calls
begin begin
-- Get the original subprogram entity following the renaming chain -- Get the original subprogram entity following the renaming chain
...@@ -1561,6 +1564,7 @@ package body Sem_Dim is ...@@ -1561,6 +1564,7 @@ package body Sem_Dim is
-- Check the call is an Elementary function call -- Check the call is an Elementary function call
if Is_Elementary_Function_Entity (Ent) then if Is_Elementary_Function_Entity (Ent) then
-- Sqrt function call case -- Sqrt function call case
if Chars (Ent) = Name_Sqrt then if Chars (Ent) = Name_Sqrt then
...@@ -1585,11 +1589,10 @@ package body Sem_Dim is ...@@ -1585,11 +1589,10 @@ package body Sem_Dim is
else else
Actual := First_Actual (N); Actual := First_Actual (N);
while Present (Actual) loop while Present (Actual) loop
if Exists (Dimensions_Of (Actual)) then if Exists (Dimensions_Of (Actual)) then
-- Check if an error has already been encountered so
-- far. -- Check if error has already been encountered so far
if not Error_Detected then if not Error_Detected then
Error_Msg_NE ("dimensions mismatch in call of&", Error_Msg_NE ("dimensions mismatch in call of&",
...@@ -1682,9 +1685,10 @@ package body Sem_Dim is ...@@ -1682,9 +1685,10 @@ package body Sem_Dim is
Expr : Node_Id) is Expr : Node_Id) is
begin begin
Error_Msg_N ("dimensions mismatch in component declaration", N); Error_Msg_N ("dimensions mismatch in component declaration", N);
Error_Msg_N ("\expected dimension " & Error_Msg_N ("\expected dimension "
Dimensions_Msg_Of (Etyp) & ", found " & & Dimensions_Msg_Of (Etyp)
Dimensions_Msg_Of (Expr), & ", found "
& Dimensions_Msg_Of (Expr),
Expr); Expr);
end Error_Dim_Msg_For_Component_Declaration; end Error_Dim_Msg_For_Component_Declaration;
...@@ -1703,9 +1707,8 @@ package body Sem_Dim is ...@@ -1703,9 +1707,8 @@ package body Sem_Dim is
-- dimensionless to indicate the literal is treated as if its -- dimensionless to indicate the literal is treated as if its
-- dimension matches the type dimension. -- dimension matches the type dimension.
if Nkind_In (Original_Node (Expr), if Nkind_In (Original_Node (Expr), N_Real_Literal,
N_Real_Literal, N_Integer_Literal)
N_Integer_Literal)
then then
Dim_Warning_For_Numeric_Literal (Expr, Etyp); Dim_Warning_For_Numeric_Literal (Expr, Etyp);
...@@ -1729,7 +1732,7 @@ package body Sem_Dim is ...@@ -1729,7 +1732,7 @@ package body Sem_Dim is
procedure Analyze_Dimension_Extended_Return_Statement (N : Node_Id) is procedure Analyze_Dimension_Extended_Return_Statement (N : Node_Id) is
Return_Ent : constant Entity_Id := Return_Statement_Entity (N); Return_Ent : constant Entity_Id := Return_Statement_Entity (N);
Return_Etyp : constant Entity_Id := Return_Etyp : constant Entity_Id :=
Etype (Return_Applies_To (Return_Ent)); Etype (Return_Applies_To (Return_Ent));
Return_Obj_Decls : constant List_Id := Return_Object_Declarations (N); Return_Obj_Decls : constant List_Id := Return_Object_Declarations (N);
Return_Obj_Decl : Node_Id; Return_Obj_Decl : Node_Id;
Return_Obj_Id : Entity_Id; Return_Obj_Id : Entity_Id;
...@@ -1754,9 +1757,10 @@ package body Sem_Dim is ...@@ -1754,9 +1757,10 @@ package body Sem_Dim is
is is
begin begin
Error_Msg_N ("dimensions mismatch in extended return statement", N); Error_Msg_N ("dimensions mismatch in extended return statement", N);
Error_Msg_N ("\expected dimension " & Error_Msg_N ("\expected dimension "
Dimensions_Msg_Of (Return_Etyp) & ", found " & & Dimensions_Msg_Of (Return_Etyp)
Dimensions_Msg_Of (Return_Obj_Typ), & ", found "
& Dimensions_Msg_Of (Return_Obj_Typ),
N); N);
end Error_Dim_Msg_For_Extended_Return_Statement; end Error_Dim_Msg_For_Extended_Return_Statement;
...@@ -1765,10 +1769,9 @@ package body Sem_Dim is ...@@ -1765,10 +1769,9 @@ package body Sem_Dim is
begin begin
if Present (Return_Obj_Decls) then if Present (Return_Obj_Decls) then
Return_Obj_Decl := First (Return_Obj_Decls); Return_Obj_Decl := First (Return_Obj_Decls);
while Present (Return_Obj_Decl) loop while Present (Return_Obj_Decl) loop
if Nkind (Return_Obj_Decl) = N_Object_Declaration then if Nkind (Return_Obj_Decl) = N_Object_Declaration then
Return_Obj_Id := Defining_Identifier (Return_Obj_Decl); Return_Obj_Id := Defining_Identifier (Return_Obj_Decl);
if Is_Return_Object (Return_Obj_Id) then if Is_Return_Object (Return_Obj_Id) then
Return_Obj_Typ := Etype (Return_Obj_Id); Return_Obj_Typ := Etype (Return_Obj_Id);
...@@ -1795,7 +1798,7 @@ package body Sem_Dim is ...@@ -1795,7 +1798,7 @@ package body Sem_Dim is
----------------------------------------------------- -----------------------------------------------------
procedure Analyze_Dimension_Extension_Or_Record_Aggregate (N : Node_Id) is procedure Analyze_Dimension_Extension_Or_Record_Aggregate (N : Node_Id) is
Comp : Node_Id := First (Component_Associations (N)); Comp : Node_Id;
Comp_Id : Entity_Id; Comp_Id : Entity_Id;
Comp_Typ : Entity_Id; Comp_Typ : Entity_Id;
Expr : Node_Id; Expr : Node_Id;
...@@ -1808,12 +1811,11 @@ package body Sem_Dim is ...@@ -1808,12 +1811,11 @@ package body Sem_Dim is
-- Aspect is an Ada 2012 feature. Note that there is no need to check -- Aspect is an Ada 2012 feature. Note that there is no need to check
-- dimensions for aggregates that don't come from source. -- dimensions for aggregates that don't come from source.
if Ada_Version < Ada_2012 if Ada_Version < Ada_2012 or else not Comes_From_Source (N) then
or else not Comes_From_Source (N)
then
return; return;
end if; end if;
Comp := First (Component_Associations (N));
while Present (Comp) loop while Present (Comp) loop
Comp_Id := Entity (First (Choices (Comp))); Comp_Id := Entity (First (Choices (Comp)));
Comp_Typ := Etype (Comp_Id); Comp_Typ := Etype (Comp_Id);
...@@ -1828,29 +1830,33 @@ package body Sem_Dim is ...@@ -1828,29 +1830,33 @@ package body Sem_Dim is
-- dimensions of the component mismatch. -- dimensions of the component mismatch.
if Dimensions_Of (Expr) /= Dimensions_Of (Comp_Typ) then if Dimensions_Of (Expr) /= Dimensions_Of (Comp_Typ) then
-- Check if an error has already been encountered so far -- Check if an error has already been encountered so far
if not Error_Detected then if not Error_Detected then
-- Extension aggregate case -- Extension aggregate case
if Nkind (N) = N_Extension_Aggregate then if Nkind (N) = N_Extension_Aggregate then
Error_Msg_N ("dimensions mismatch in extension aggregate", Error_Msg_N
N); ("dimensions mismatch in extension aggregate", N);
-- Record aggregate case -- Record aggregate case
else else
Error_Msg_N ("dimensions mismatch in record aggregate", Error_Msg_N
N); ("dimensions mismatch in record aggregate", N);
end if; end if;
Error_Detected := True; Error_Detected := True;
end if; end if;
Error_Msg_N ("\expected dimension " & Error_Msg_N
Dimensions_Msg_Of (Comp_Typ) & ", found " & ("\expected dimension "
Dimensions_Msg_Of (Expr), & Dimensions_Msg_Of (Comp_Typ)
Comp); & ", found "
& Dimensions_Msg_Of (Expr),
Comp);
end if; end if;
end if; end if;
...@@ -1871,14 +1877,11 @@ package body Sem_Dim is ...@@ -1871,14 +1877,11 @@ package body Sem_Dim is
-- Aspect is an Ada 2012 feature. Note that there is no need to check -- Aspect is an Ada 2012 feature. Note that there is no need to check
-- dimensions for sub specs that don't come from source. -- dimensions for sub specs that don't come from source.
if Ada_Version < Ada_2012 if Ada_Version < Ada_2012 or else not Comes_From_Source (N) then
or else not Comes_From_Source (N)
then
return; return;
end if; end if;
Formal := First (Formals); Formal := First (Formals);
while Present (Formal) loop while Present (Formal) loop
Typ := Parameter_Type (Formal); Typ := Parameter_Type (Formal);
Dims_Of_Typ := Dimensions_Of (Typ); Dims_Of_Typ := Dimensions_Of (Typ);
...@@ -1893,9 +1896,8 @@ package body Sem_Dim is ...@@ -1893,9 +1896,8 @@ package body Sem_Dim is
if Present (Expr) if Present (Expr)
and then Dims_Of_Typ /= Dimensions_Of (Expr) and then Dims_Of_Typ /= Dimensions_Of (Expr)
and then Nkind_In (Original_Node (Expr), and then Nkind_In (Original_Node (Expr), N_Real_Literal,
N_Real_Literal, N_Integer_Literal)
N_Integer_Literal)
then then
Dim_Warning_For_Numeric_Literal (Expr, Etype (Typ)); Dim_Warning_For_Numeric_Literal (Expr, Etype (Typ));
end if; end if;
...@@ -1990,10 +1992,12 @@ package body Sem_Dim is ...@@ -1990,10 +1992,12 @@ package body Sem_Dim is
Expr : Node_Id) is Expr : Node_Id) is
begin begin
Error_Msg_N ("dimensions mismatch in object declaration", N); Error_Msg_N ("dimensions mismatch in object declaration", N);
Error_Msg_N ("\expected dimension " & Error_Msg_N
Dimensions_Msg_Of (Etyp) & ", found " & ("\expected dimension "
Dimensions_Msg_Of (Expr), & Dimensions_Msg_Of (Etyp)
Expr); & ", found "
& Dimensions_Msg_Of (Expr),
Expr);
end Error_Dim_Msg_For_Object_Declaration; end Error_Dim_Msg_For_Object_Declaration;
-- Start of processing for Analyze_Dimension_Object_Declaration -- Start of processing for Analyze_Dimension_Object_Declaration
...@@ -2007,22 +2011,21 @@ package body Sem_Dim is ...@@ -2007,22 +2011,21 @@ package body Sem_Dim is
-- Check dimensions match -- Check dimensions match
if Dim_Of_Expr /= Dim_Of_Etyp then if Dim_Of_Expr /= Dim_Of_Etyp then
-- Numeric literal case. Issue a warning if the object type is not -- Numeric literal case. Issue a warning if the object type is not
-- dimensionless to indicate the literal is treated as if its -- dimensionless to indicate the literal is treated as if its
-- dimension matches the type dimension. -- dimension matches the type dimension.
if Nkind_In (Original_Node (Expr), if Nkind_In (Original_Node (Expr), N_Real_Literal,
N_Real_Literal, N_Integer_Literal)
N_Integer_Literal)
then then
Dim_Warning_For_Numeric_Literal (Expr, Etyp); Dim_Warning_For_Numeric_Literal (Expr, Etyp);
-- Case where the object is a constant whose type is a dimensioned -- Case of object is a constant whose type is a dimensioned type
-- type.
elsif Constant_Present (N) and then not Exists (Dim_Of_Etyp) then elsif Constant_Present (N) and then not Exists (Dim_Of_Etyp) then
-- Propagate the dimension from the expression to the object
-- entity -- Propagate dimension from expression to object entity
Set_Dimensions (Id, Dim_Of_Expr); Set_Dimensions (Id, Dim_Of_Expr);
...@@ -2064,10 +2067,12 @@ package body Sem_Dim is ...@@ -2064,10 +2067,12 @@ package body Sem_Dim is
Renamed_Name : Node_Id) is Renamed_Name : Node_Id) is
begin begin
Error_Msg_N ("dimensions mismatch in object renaming declaration", N); Error_Msg_N ("dimensions mismatch in object renaming declaration", N);
Error_Msg_N ("\expected dimension " & Error_Msg_N
Dimensions_Msg_Of (Sub_Mark) & ", found " & ("\expected dimension "
Dimensions_Msg_Of (Renamed_Name), & Dimensions_Msg_Of (Sub_Mark)
Renamed_Name); & ", found "
& Dimensions_Msg_Of (Renamed_Name),
Renamed_Name);
end Error_Dim_Msg_For_Object_Renaming_Declaration; end Error_Dim_Msg_For_Object_Renaming_Declaration;
-- Start of processing for Analyze_Dimension_Object_Renaming_Declaration -- Start of processing for Analyze_Dimension_Object_Renaming_Declaration
...@@ -2110,10 +2115,12 @@ package body Sem_Dim is ...@@ -2110,10 +2115,12 @@ package body Sem_Dim is
is is
begin begin
Error_Msg_N ("dimensions mismatch in return statement", N); Error_Msg_N ("dimensions mismatch in return statement", N);
Error_Msg_N ("\expected dimension " & Error_Msg_N
Dimensions_Msg_Of (Return_Etyp) & ", found " & ("\expected dimension "
Dimensions_Msg_Of (Expr), & Dimensions_Msg_Of (Return_Etyp)
Expr); & ", found "
& Dimensions_Msg_Of (Expr),
Expr);
end Error_Dim_Msg_For_Simple_Return_Statement; end Error_Dim_Msg_For_Simple_Return_Statement;
-- Start of processing for Analyze_Dimension_Simple_Return_Statement -- Start of processing for Analyze_Dimension_Simple_Return_Statement
...@@ -2148,8 +2155,9 @@ package body Sem_Dim is ...@@ -2148,8 +2155,9 @@ package body Sem_Dim is
-- it cannot inherit a dimension from its subtype. -- it cannot inherit a dimension from its subtype.
if Exists (Dims_Of_Id) then if Exists (Dims_Of_Id) then
Error_Msg_N ("subtype& already" & Dimensions_Msg_Of (Id, True), Error_Msg_N
N); ("subtype& already" & Dimensions_Msg_Of (Id, True), N);
else else
Set_Dimensions (Id, Dims_Of_Etyp); Set_Dimensions (Id, Dims_Of_Etyp);
Set_Symbol (Id, Symbol_Of (Etyp)); Set_Symbol (Id, Symbol_Of (Etyp));
...@@ -2842,7 +2850,6 @@ package body Sem_Dim is ...@@ -2842,7 +2850,6 @@ package body Sem_Dim is
if Exists (Symbol_Of (Etyp)) then if Exists (Symbol_Of (Etyp)) then
Symbols := Symbol_Of (Etyp); Symbols := Symbol_Of (Etyp);
else else
Symbols := From_Dim_To_Str_Of_Unit_Symbols Symbols := From_Dim_To_Str_Of_Unit_Symbols
(Dims_Of_Actual, System_Of (Base_Type (Etyp))); (Dims_Of_Actual, System_Of (Base_Type (Etyp)));
...@@ -3334,7 +3341,6 @@ package body Sem_Dim is ...@@ -3334,7 +3341,6 @@ package body Sem_Dim is
begin begin
Start_String; Start_String;
while Belong_To_Numeric_Literal (C) loop while Belong_To_Numeric_Literal (C) loop
Store_String_Char (C); Store_String_Char (C);
Src_Ptr := Src_Ptr + 1; Src_Ptr := Src_Ptr + 1;
...@@ -3350,11 +3356,9 @@ package body Sem_Dim is ...@@ -3350,11 +3356,9 @@ package body Sem_Dim is
function Symbol_Of (E : Entity_Id) return String_Id is function Symbol_Of (E : Entity_Id) return String_Id is
Subtype_Symbol : constant String_Id := Symbol_Table.Get (E); Subtype_Symbol : constant String_Id := Symbol_Table.Get (E);
begin begin
if Subtype_Symbol /= No_String then if Subtype_Symbol /= No_String then
return Subtype_Symbol; return Subtype_Symbol;
else else
return From_Dim_To_Str_Of_Unit_Symbols return From_Dim_To_Str_Of_Unit_Symbols
(Dimensions_Of (E), System_Of (Base_Type (E))); (Dimensions_Of (E), System_Of (Base_Type (E)));
...@@ -3388,4 +3392,5 @@ package body Sem_Dim is ...@@ -3388,4 +3392,5 @@ package body Sem_Dim is
return Null_System; return Null_System;
end System_Of; end System_Of;
end Sem_Dim; end Sem_Dim;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment