Skip to content
Snippets Groups Projects
Commit 0fe74112 authored by Eric Botcazou's avatar Eric Botcazou Committed by Marc Poulhiès
Browse files

ada: Elide copy for calls as default values of nonlimited by-reference components

This prevents a temporary from being created on the primary stack to hold
the result of the function calls before it is copied to the object being
elaborated in the nonlimited by-reference case.

That's already not done in the nonlimited non-by-reference case and there is
no reason to do it in the former case either.  The main issue are the calls
to Remove_Side_Effects in Expand_Ctrl_Function_Call (controlled case only)
and in Expand_N_Assignment_Statement, which serve various purposes including
very technical ones beside removing side effects.

The change is therefore very conservative and only removes the copy in the
case of a naked function call for the time being.

gcc/ada/ChangeLog:

	* einfo.ads (Returns_By_Ref): Fix description.
	* exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Do not
	adjust the component manually (if need be), set No_Finalize_Actions
	instead of No_Ctrl_Actions for this purpose.  Do not adjust when
	the expression is a naked function call.
	* exp_ch5.adb (Make_Tag_Ctrl_Assignment): Document the quirks of
	the function.  Assert that the LHS of the assignment does not have
	side effects and replace calls to Duplicate_Subexpr_No_Checks with
	calls to New_Copy_Tree.  Rename local variable Asn to New_N.
	(Expand_N_Assignment_Statement): In the tagged or controlled record
	case, do remove side effects from both operands on entry.  Remove
	them in the controlled record case, except if the RHS is a function
	call and the assignment has the No_Ctrl_Actions flag set.
	* exp_ch6.adb (Expand_Ctrl_Function_Call): Bail out when the parent
	node is an assignment statement with the No_Ctrl_Actions flag set.
	* sem_util.adb (Statically_Different): Return True for a function
	call that does not return its result by reference.
	* sinfo.ads (No_Ctrl_Actions): Adjust description and add a note for
	the code generator.
	(No_Finalize_Actions): Likewise.
parent 42c115ee
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment