Commit 2700b9c1 by Arnaud Charlet

[multiple changes]

2015-10-23  Arnaud Charlet  <charlet@adacore.com>

	* gnat1drv.adb (Adjust_Global_Switches): Adjust.

2015-10-23  Hristian Kirtchev  <kirtchev@adacore.com>

	* exp_dbug.ads, exp_dbug.adb (Get_External_Name): The special prefix for
	ignored Ghost entities is now ___ghost_.

2015-10-23  Hristian Kirtchev  <kirtchev@adacore.com>

	* ghost.adb (Is_Subject_To_Ghost): Check the
	original node when searching for pragma Ghost to catch cases
	where a source construct has been rewritten into something else.

2015-10-23  Ed Schonberg  <schonberg@adacore.com>

	* einfo.ads, einfo.adb (Rewritten_For_C): New flag on functions
	that return a constrained array type.  When generating C these
	functions are rewritten as procedures with an out parameter,
	and calls to such functions are rewritten accordingly.
	* exp_ch6.adb (Expand_N_Subprogram_Declaration): When
	Modify_Tree_For_C is set and the function returns a constrained
	array type, generate a procedure declaration with an additional
	out parameter. Mark original function as Rewritten_For_C.
	The new declaration is inserted in tree immediately after
	current declaration.
	(Expand_Subprogram_Body): If entity is marked Rewritten_For_C,
	generate body of corresponding procedure using declarations
	and statements for function body. Replace return statements
	with assignments to the out parameter, followed by a simple
	return statement.
	(Rewrite_Function_Call_For_C): New procedure to replace a function
	call that returns an array by a procedure call.

From-SVN: r229241
parent 774454ac
2015-10-23 Arnaud Charlet <charlet@adacore.com>
* gnat1drv.adb (Adjust_Global_Switches): Adjust.
2015-10-23 Hristian Kirtchev <kirtchev@adacore.com>
* exp_dbug.ads, exp_dbug.adb (Get_External_Name): The special prefix for
ignored Ghost entities is now ___ghost_.
2015-10-23 Hristian Kirtchev <kirtchev@adacore.com>
* ghost.adb (Is_Subject_To_Ghost): Check the
original node when searching for pragma Ghost to catch cases
where a source construct has been rewritten into something else.
2015-10-23 Ed Schonberg <schonberg@adacore.com>
* einfo.ads, einfo.adb (Rewritten_For_C): New flag on functions
that return a constrained array type. When generating C these
functions are rewritten as procedures with an out parameter,
and calls to such functions are rewritten accordingly.
* exp_ch6.adb (Expand_N_Subprogram_Declaration): When
Modify_Tree_For_C is set and the function returns a constrained
array type, generate a procedure declaration with an additional
out parameter. Mark original function as Rewritten_For_C.
The new declaration is inserted in tree immediately after
current declaration.
(Expand_Subprogram_Body): If entity is marked Rewritten_For_C,
generate body of corresponding procedure using declarations
and statements for function body. Replace return statements
with assignments to the out parameter, followed by a simple
return statement.
(Rewrite_Function_Call_For_C): New procedure to replace a function
call that returns an array by a procedure call.
2015-10-23 Hristian Kirtchev <kirtchev@adacore.com>
* sem_util.adb (Denotes_Iterator): New routine.
......
......@@ -597,8 +597,8 @@ package body Einfo is
-- Is_Unimplemented Flag284
-- Is_Volatile_Full_Access Flag285
-- Needs_Typedef Flag286
-- Rewritten_For_C Flag287
-- (unused) Flag287
-- (unused) Flag288
-- (unused) Flag289
-- (unused) Flag300
......@@ -3042,6 +3042,12 @@ package body Einfo is
return Flag93 (Base_Type (Id));
end Reverse_Storage_Order;
function Rewritten_For_C (Id : E) return B is
begin
pragma Assert (Ekind (Id) = E_Function);
return Flag287 (Id);
end Rewritten_For_C;
function RM_Size (Id : E) return U is
begin
pragma Assert (Is_Type (Id));
......@@ -6046,6 +6052,12 @@ package body Einfo is
Set_Flag93 (Id, V);
end Set_Reverse_Storage_Order;
procedure Set_Rewritten_For_C (Id : E; V : B := True) is
begin
pragma Assert (Ekind (Id) = E_Function);
Set_Flag287 (Id, V);
end Set_Rewritten_For_C;
procedure Set_RM_Size (Id : E; V : U) is
begin
pragma Assert (Is_Type (Id));
......@@ -8964,6 +8976,7 @@ package body Einfo is
W ("Returns_Limited_View", Flag134 (Id));
W ("Reverse_Bit_Order", Flag164 (Id));
W ("Reverse_Storage_Order", Flag93 (Id));
W ("Rewritten_For_C", Flag287 (Id));
W ("Sec_Stack_Needed_For_Return", Flag167 (Id));
W ("Size_Depends_On_Discriminant", Flag177 (Id));
W ("Size_Known_At_Compile_Time", Flag92 (Id));
......@@ -10246,6 +10259,9 @@ package body Einfo is
procedure Write_Field38_Name (Id : Entity_Id) is
begin
case Ekind (Id) is
when E_Function | E_Procedure =>
Write_Str ("Class-wide preconditions");
when others =>
Write_Str ("Field38??");
end case;
......@@ -10258,6 +10274,9 @@ package body Einfo is
procedure Write_Field39_Name (Id : Entity_Id) is
begin
case Ekind (Id) is
when E_Function | E_Procedure =>
Write_Str ("Class-wide postcondition");
when others =>
Write_Str ("Field39??");
end case;
......
......@@ -3943,6 +3943,12 @@ package Einfo is
-- the Bit_Order aspect must be set to the same value (either explicitly
-- or as the target default value).
-- Rewritten_For_C (Flag287)
-- Defined on functions that return a constrained array type, when
-- Modify_Tree_For_C is set. indicates that a procedure with an extra
-- out parameter has been created for it, and calls must be rewritten as
-- calls to the new procedure.
-- RM_Size (Uint13)
-- Defined in all type and subtype entities. Contains the value of
-- type'Size as defined in the RM. See also the Esize field and
......@@ -5908,6 +5914,7 @@ package Einfo is
-- Return_Present (Flag54)
-- Returns_By_Ref (Flag90)
-- Returns_Limited_View (Flag134) (non-generic case only)
-- Rewritten_For_C (Flag287)
-- Sec_Stack_Needed_For_Return (Flag167)
-- SPARK_Pragma_Inherited (Flag265)
-- Uses_Sec_Stack (Flag95)
......@@ -7078,6 +7085,7 @@ package Einfo is
function Returns_Limited_View (Id : E) return B;
function Reverse_Bit_Order (Id : E) return B;
function Reverse_Storage_Order (Id : E) return B;
function Rewritten_For_C (Id : E) return B;
function RM_Size (Id : E) return U;
function Scalar_Range (Id : E) return N;
function Scale_Value (Id : E) return U;
......@@ -7743,6 +7751,7 @@ package Einfo is
procedure Set_Returns_Limited_View (Id : E; V : B := True);
procedure Set_Reverse_Bit_Order (Id : E; V : B := True);
procedure Set_Reverse_Storage_Order (Id : E; V : B := True);
procedure Set_Rewritten_For_C (Id : E; V : B := True);
procedure Set_RM_Size (Id : E; V : U);
procedure Set_Scalar_Range (Id : E; V : N);
procedure Set_Scale_Value (Id : E; V : U);
......@@ -8564,6 +8573,7 @@ package Einfo is
pragma Inline (Returns_Limited_View);
pragma Inline (Reverse_Bit_Order);
pragma Inline (Reverse_Storage_Order);
pragma Inline (Rewritten_For_C);
pragma Inline (RM_Size);
pragma Inline (Scalar_Range);
pragma Inline (Scale_Value);
......@@ -9024,6 +9034,7 @@ package Einfo is
pragma Inline (Set_Returns_Limited_View);
pragma Inline (Set_Reverse_Bit_Order);
pragma Inline (Set_Reverse_Storage_Order);
pragma Inline (Set_Rewritten_For_C);
pragma Inline (Set_RM_Size);
pragma Inline (Set_Scalar_Range);
pragma Inline (Set_Scale_Value);
......
......@@ -785,7 +785,7 @@ package body Exp_Dbug is
if Is_Ignored_Ghost_Entity (E)
or else (Debug_Flag_Dot_5 and Is_Ghost_Entity (E))
then
Add_Str_To_Name_Buffer ("_ghost_");
Add_Str_To_Name_Buffer ("___ghost_");
end if;
-- Case of interface name being used
......
......@@ -76,9 +76,9 @@ package Exp_Dbug is
-- qualification for such entities. In particular this means that direct
-- local variables of a procedure are not qualified.
-- For ignored Ghost entities, the encoding adds a prefix "_ghost_" to aid
-- the detection of leaks in the "living" space. Ignored Ghost entities and
-- any code associated with them should be removed by the compiler in a
-- For ignored Ghost entities, the encoding adds a prefix "___ghost_" to
-- aid the detection of leaks in the "living" space. Ignored Ghost entities
-- and any code associated with them should be removed by the compiler in a
-- post-processing pass. As a result, object files should not contain any
-- occurrences of this prefix.
......
......@@ -801,9 +801,10 @@ package body Ghost is
Enables_Ghostness (First (Pragma_Argument_Associations (Decl)));
-- A source construct ends the region where pragma Ghost may appear,
-- stop the traversal.
-- stop the traversal. Check the original node as source constructs
-- may be rewritten into something else by expansion.
elsif Comes_From_Source (Decl) then
elsif Comes_From_Source (Original_Node (Decl)) then
exit;
end if;
......
......@@ -648,7 +648,7 @@ procedure Gnat1drv is
-- back end some day, it would not be true for this test, but it
-- would be non-GCC, so this is a bit troublesome ???
Front_End_Inlining := AAMP_On_Target;
Front_End_Inlining := AAMP_On_Target or Generate_C_Code;
end if;
-- Set back end inlining indication
......@@ -659,6 +659,10 @@ procedure Gnat1drv is
not AAMP_On_Target
-- No back end inlining available on C generation
and then not Generate_C_Code
-- No back end inlining in GNATprove mode, since it just confuses
-- the formal verification process.
......
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