return;
end if;
- if Modify_Tree_For_C
+ if Transform_Function_Array
and then Nkind (Call_Node) = N_Function_Call
and then Is_Entity_Name (Name (Call_Node))
then
-- are not needed by the C generator (and this also produces cleaner
-- output).
- if Modify_Tree_For_C
+ if Transform_Function_Array
and then Nkind (Specification (N)) = N_Function_Specification
and then Is_Array_Type (Etype (Subp))
and then Is_Constrained (Etype (Subp))
-- outside the nested structure do not affect us.
if Scope_Within (Ent, Subp)
- and then Is_Subprogram (Ent)
- and then not Is_Imported (Ent)
+ and then Is_Subprogram (Ent)
+ and then not Is_Imported (Ent)
then
Append_Unique_Call ((N, Current_Subprogram, Ent));
end if;
Check_Overriding_Indicator (E, Empty, Is_Primitive (E));
end if;
- if Modify_Tree_For_C
+ if Transform_Function_Array
and then Nkind (Parent (E)) = N_Function_Specification
and then Is_Array_Type (Etype (E))
and then Is_Constrained (Etype (E))
if Debug_Flag_Dot_U then
Modify_Tree_For_C := True;
+ Transform_Function_Array := True;
end if;
-- -gnatd_A disables generation of ALI files
if Generate_C_Code then
Modify_Tree_For_C := True;
+ Transform_Function_Array := True;
Unnest_Subprogram_Mode := True;
Building_Static_Dispatch_Tables := False;
Minimize_Expression_With_Actions := True;
-- this way when we are doing CodePeer tests on existing test suites
-- that may have -gnateg set, to avoid the need for special casing.
- Modify_Tree_For_C := False;
- Generate_C_Code := False;
- Unnest_Subprogram_Mode := False;
+ Modify_Tree_For_C := False;
+ Transform_Function_Array := False;
+ Generate_C_Code := False;
+ Unnest_Subprogram_Mode := False;
-- Turn off inlining, confuses CodePeer output and gains nothing
-- this way when we are doing GNATprove tests on existing test suites
-- that may have -gnateg set, to avoid the need for special casing.
- Modify_Tree_For_C := False;
- Generate_C_Code := False;
- Unnest_Subprogram_Mode := False;
+ Modify_Tree_For_C := False;
+ Transform_Function_Array := False;
+ Generate_C_Code := False;
+ Unnest_Subprogram_Mode := False;
-- Turn off inlining, which would confuse formal verification output
-- and gain nothing.
-- Tolerate time stamp and other consistency errors. If this flag is set to
-- True (-t), then inconsistencies result in warnings rather than errors.
+ Transform_Function_Array : Boolean := False;
+ -- GNAT
+ -- If this switch is set True, then functions returning constrained arrays
+ -- are transformed into a procedure with an out parameter, and all calls
+ -- are updated accordingly.
+
Treat_Categorization_Errors_As_Warnings : Boolean := False;
-- Normally categorization errors are true illegalities. If this switch
-- is set, then such errors result in warning messages rather than error
-- Required to ensure that Expand_Call rewrites calls to this
-- function by calls to the built procedure.
- if Modify_Tree_For_C
+ if Transform_Function_Array
and then Nkind (Body_Spec) = N_Function_Specification
and then
- Rewritten_For_C (Defining_Entity (Specification (Subp_Decl)))
+ Rewritten_For_C (Defining_Entity (Specification (Subp_Decl)))
then
Set_Rewritten_For_C (Defining_Entity (Body_Spec));
Set_Corresponding_Procedure (Defining_Entity (Body_Spec),
Build_Subprogram_Declaration;
-- If this is a function that returns a constrained array, and
- -- we are generating C code, create subprogram declaration
- -- to simplify subsequent C generation.
+ -- Transform_Function_Array is set, create subprogram
+ -- declaration to simplify e.g. subsequent C generation.
elsif No (Spec_Id)
- and then Modify_Tree_For_C
+ and then Transform_Function_Array
and then Nkind (Body_Spec) = N_Function_Specification
and then Is_Array_Type (Etype (Body_Id))
and then Is_Constrained (Etype (Body_Id))
Spec_Id := Build_Internal_Protected_Declaration (N);
end if;
- -- If we are generating C and this is a function returning a constrained
- -- array type for which we must create a procedure with an extra out
- -- parameter, build and analyze the body now. The procedure declaration
- -- has already been created. We reuse the source body of the function,
- -- because in an instance it may contain global references that cannot
- -- be reanalyzed. The source function itself is not used any further,
- -- so we mark it as having a completion. If the subprogram is a stub the
- -- transformation is done later, when the proper body is analyzed.
+ -- If Transform_Function_Array is set and this is a function returning a
+ -- constrained array type for which we must create a procedure with an
+ -- extra out parameter, build and analyze the body now. The procedure
+ -- declaration has already been created. We reuse the source body of the
+ -- function, because in an instance it may contain global references
+ -- that cannot be reanalyzed. The source function itself is not used any
+ -- further, so we mark it as having a completion. If the subprogram is a
+ -- stub the transformation is done later, when the proper body is
+ -- analyzed.
if Expander_Active
- and then Modify_Tree_For_C
+ and then Transform_Function_Array
and then Present (Spec_Id)
and then Ekind (Spec_Id) = E_Function
and then Nkind (N) /= N_Subprogram_Body_Stub