<feed xmlns='http://www.w3.org/2005/Atom'>
<title>gcc.git/gcc/ada/exp_ch6.adb, branch master</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/'/>
<entry>
<title>ada: Fix memory leak for unconstrained limited arrays in anonymous contexts</title>
<updated>2025-11-21T08:29:37+00:00</updated>
<author>
<name>Eric Botcazou</name>
<email>ebotcazou@adacore.com</email>
</author>
<published>2025-11-11T09:35:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=0c8271742f32fcf08f0b5818aaad2daafff89b62'/>
<id>0c8271742f32fcf08f0b5818aaad2daafff89b62</id>
<content type='text'>
A change made a long time ago has introduced a leak of the secondary stack
at run time for unconstrained limited non-controlled arrays in anonymous
contexts, because of the lack of a transient scope in these contexts.

The large comment preceding the call to Establish_Transient_Scope in the
Resolve_Call procedure explains the strategy for build-in-place functions,
so the best course of action is probably to revert the commit and to fix
the original problem along the lines of the comment.

gcc/ada/ChangeLog:

	* exp_ch3.adb (Expand_N_Object_Declaration): Delete ancient comment.
	* exp_ch6.adb (Expand_Call_Helper): Do not establish a transient
	scope for build-in-place functions in anonymous contexts here...
	(Make_Build_In_Place_Call_In_Anonymous_Context): ...but here instead.
	* sem_attr.adb (Resolve_Attribute) &lt;Attribute_Range&gt;: Remove obsolete
	code dealing with transient scopes.
	* sem_res.adb (Resolve_Actuals): Likewise.
	(Resolve_Call): Adjust comment on the strategy for transient scopes.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A change made a long time ago has introduced a leak of the secondary stack
at run time for unconstrained limited non-controlled arrays in anonymous
contexts, because of the lack of a transient scope in these contexts.

The large comment preceding the call to Establish_Transient_Scope in the
Resolve_Call procedure explains the strategy for build-in-place functions,
so the best course of action is probably to revert the commit and to fix
the original problem along the lines of the comment.

gcc/ada/ChangeLog:

	* exp_ch3.adb (Expand_N_Object_Declaration): Delete ancient comment.
	* exp_ch6.adb (Expand_Call_Helper): Do not establish a transient
	scope for build-in-place functions in anonymous contexts here...
	(Make_Build_In_Place_Call_In_Anonymous_Context): ...but here instead.
	* sem_attr.adb (Resolve_Attribute) &lt;Attribute_Range&gt;: Remove obsolete
	code dealing with transient scopes.
	* sem_res.adb (Resolve_Actuals): Likewise.
	(Resolve_Call): Adjust comment on the strategy for transient scopes.
</pre>
</div>
</content>
</entry>
<entry>
<title>ada: Enforce checks on access to interface type conversions</title>
<updated>2025-11-18T15:05:10+00:00</updated>
<author>
<name>Javier Miranda</name>
<email>miranda@adacore.com</email>
</author>
<published>2025-10-02T06:41:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=fb97610cfdd26f08915fe083d3ab566c151ba320'/>
<id>fb97610cfdd26f08915fe083d3ab566c151ba320</id>
<content type='text'>
The patch enforces checks on access to interface type conversions
internally generated by the frontend to displace the pointer to
a tagged type object (pointer named "this" in the C++ terminology)
from a dispatch table to a another dispatch table.

gcc/ada/ChangeLog:

	* exp_util.ads (Flag_Interface_Pointer_Displacement): New subprogram.
	* exp_util.adb (Flag_Interface_Pointer_Displacement): Ditto.
	* exp_attr.adb (Add_Implicit_Interface_Type_Conversion): Flag type
	conversions internally added to displace the pointer to the object.
	(Expand_N_Attribute_Reference): Ditto.
	* exp_ch4.adb (Displace_Allocator_Pointer): Ditto.
	* exp_ch6.adb (Expand_Simple_Function_Return): Ditto.
	(Make_Build_In_Place_Call_In_Allocator): Ditto.
	(Make_CPP_Constructor_Call_In_Allocator): Ditto.
	* exp_disp.adb (Expand_Interface_Actuals): Ditto.
	* exp_intr.adb (Expand_Dispatching_Constructor_Call): Ditto.
	* sem_ch6.adb (Analyze_Function_Return): Ditto.
	* sem_disp.adb (Propagate_Tag): Ditto.
	* sem_res.adb (Resolve_Actuals): Ditto.
	(Valid_Conversion): Rely on the new flag to handle the type conversion
	as a conversion added to displace the pointer to the object. Factorize
	code handling general and anonymous access types.
	* sem_type.adb (Interface_Present_In_Ancestor): For concurrent types
	add missing handling of class-wide types. Noticed working on this
	issue.
	* sinfo.ads (Is_Interface_Pointer_Displacement): Document this new flag.
	* gen_il-fields.ads (Is_Interface_Pointer_Displacement): New flag.
	* gen_il-gen-gen_nodes.adb (Is_Interface_Pointer_Displacement): New
	flag on N_Type_Conversion nodes.
	* gen_il-internals.adb (Image): Add Is_Interface_Pointer_Displacement
	flag image.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The patch enforces checks on access to interface type conversions
internally generated by the frontend to displace the pointer to
a tagged type object (pointer named "this" in the C++ terminology)
from a dispatch table to a another dispatch table.

gcc/ada/ChangeLog:

	* exp_util.ads (Flag_Interface_Pointer_Displacement): New subprogram.
	* exp_util.adb (Flag_Interface_Pointer_Displacement): Ditto.
	* exp_attr.adb (Add_Implicit_Interface_Type_Conversion): Flag type
	conversions internally added to displace the pointer to the object.
	(Expand_N_Attribute_Reference): Ditto.
	* exp_ch4.adb (Displace_Allocator_Pointer): Ditto.
	* exp_ch6.adb (Expand_Simple_Function_Return): Ditto.
	(Make_Build_In_Place_Call_In_Allocator): Ditto.
	(Make_CPP_Constructor_Call_In_Allocator): Ditto.
	* exp_disp.adb (Expand_Interface_Actuals): Ditto.
	* exp_intr.adb (Expand_Dispatching_Constructor_Call): Ditto.
	* sem_ch6.adb (Analyze_Function_Return): Ditto.
	* sem_disp.adb (Propagate_Tag): Ditto.
	* sem_res.adb (Resolve_Actuals): Ditto.
	(Valid_Conversion): Rely on the new flag to handle the type conversion
	as a conversion added to displace the pointer to the object. Factorize
	code handling general and anonymous access types.
	* sem_type.adb (Interface_Present_In_Ancestor): For concurrent types
	add missing handling of class-wide types. Noticed working on this
	issue.
	* sinfo.ads (Is_Interface_Pointer_Displacement): Document this new flag.
	* gen_il-fields.ads (Is_Interface_Pointer_Displacement): New flag.
	* gen_il-gen-gen_nodes.adb (Is_Interface_Pointer_Displacement): New
	flag on N_Type_Conversion nodes.
	* gen_il-internals.adb (Image): Add Is_Interface_Pointer_Displacement
	flag image.
</pre>
</div>
</content>
</entry>
<entry>
<title>ada: Reserve Is_Constructor for Ada constructors</title>
<updated>2025-11-18T15:05:09+00:00</updated>
<author>
<name>Denis Mazzucato</name>
<email>mazzucato@adacore.com</email>
</author>
<published>2025-10-30T11:56:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=3b5c0c0f3acf9cab725381484a7c2d0bf65c7456'/>
<id>3b5c0c0f3acf9cab725381484a7c2d0bf65c7456</id>
<content type='text'>
This patch renames old Is_Constructor to a new Is_CPP_Constructor and reserves
Is_Constructor for Ada constructors.

gcc/ada/ChangeLog:

	* sem_util.adb (Is_Constructor_Procedure): Replace by Is_Constructor.
	* sem_util.ads: Likewise.
	* sem_ch6.adb (Analyze_Direct_Attribute_Definition): Set Is_Constructor.
	* einfo.ads: Use Is_Constructor for Ada constructors, and
	Is_CPP_Constructor for CPP constructors.
	* exp_ch6.adb: Likewise.
	* exp_disp.adb: Likewise.
	* freeze.adb: Likewise.
	* gen_il-fields.ads: Likewise.
	* gen_il-gen-gen_entities.adb: Likewise.
	* gen_il-internals.adb: Likewise.
	* par-ch6.adb: Likewise.
	* sem_prag.adb: Likewise.
	* treepr.adb: Likewise.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch renames old Is_Constructor to a new Is_CPP_Constructor and reserves
Is_Constructor for Ada constructors.

gcc/ada/ChangeLog:

	* sem_util.adb (Is_Constructor_Procedure): Replace by Is_Constructor.
	* sem_util.ads: Likewise.
	* sem_ch6.adb (Analyze_Direct_Attribute_Definition): Set Is_Constructor.
	* einfo.ads: Use Is_Constructor for Ada constructors, and
	Is_CPP_Constructor for CPP constructors.
	* exp_ch6.adb: Likewise.
	* exp_disp.adb: Likewise.
	* freeze.adb: Likewise.
	* gen_il-fields.ads: Likewise.
	* gen_il-gen-gen_entities.adb: Likewise.
	* gen_il-internals.adb: Likewise.
	* par-ch6.adb: Likewise.
	* sem_prag.adb: Likewise.
	* treepr.adb: Likewise.
</pre>
</div>
</content>
</entry>
<entry>
<title>ada: Direct attribute definition for constructors</title>
<updated>2025-11-03T14:15:16+00:00</updated>
<author>
<name>Denis Mazzucato</name>
<email>mazzucato@adacore.com</email>
</author>
<published>2025-09-25T09:31:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=f5836f73b1021990e1ae448092cf6dc294eb7684'/>
<id>f5836f73b1021990e1ae448092cf6dc294eb7684</id>
<content type='text'>
This patch introduces the 'Constructor attribute and implements its direct
attribute definition syntax within subprogram specification. This new shorthand
avoids having to come up with an arbitrary subprogram name and to type out the
constructor aspect. Before, constructors where defined through the aspect
Constructor, which has been removed.

Furthermore, this patch prepares for the expansion of direct attribute
definitions to other attributes.

gcc/ada/ChangeLog:

	* errout.adb (Set_Msg_Node): Support N_Attribute_Reference and
	nodes that denotes direct attribute definitions.
	* exp_dbug.ads: Description for the encoding of direct attribute
	definitions as tick are hard to deal in entity names.
	* erroutc.adb
	(Set_Msg_Insertion_Name): Replace underscore between prefix and
	attribute name in direct attribute definitions; at this point we
	lost the semantic information of node type and we resort to match
	the string name as described in exp_dbug.adb.
	* exp_aggr.adb (Convert_To_Positional): Use Needs_Construction and
	Has_Default_Constructor.
	* exp_ch3.adb (Build_Record_Init_Proc)
	(Expand_N_Object_Declaration): Likewise.
	* exp_attr.adb (Expand_N_Attribute_Reference): Likewise.
	* exp_ch4.adb (Expand_N_Allocator): Likewise.
	* exp_ch6.adb
	(Prepend_Constructor_Procedure_Prologue): Use
	Is_Constructor_Procedure.
	(Make_Parent_Constructor_Call): Use
	Direct_Attribute_Definition_Name.
	* gen_il-fields.ads: Remove Constructor_List and Constructor_Name.
	* gen_il-gen-gen_entities.adb: Likewise.
	* einfo.ads (Needs_Construction): Add description.
	(Has_Delayed_Aspects): Adjust indentation.
	* par-ch13.adb (P_Attribute_Designators): Parse attribute
	designators.
	(P_Representation_Clause): Use P_Attribute_Designators.
	* par-ch6.adb (P_Subprogram): Support attribute designators in
	subprogram name.
	(Rewrites_Entity_If_Direct_Attribute_Def): Fix the specification
	node in case of direct attribute definitions.
	* par-endh.adb (Check_End, Same_Label): Likewise.
	* par.adb (P_Attribute_Designators): Specification.
	* sem_attr.adb (Analyze_Attribute): Error when using 'Constructor
	outside procedure specification.
	(Analyze_Attribute): Add error handling code.
	* sem_ch3.adb (Analyze_Aspect_Specifications): Likewise.
	* sem_ch6.adb (Analyze_Direct_Attribute_Definition): Handle direct
	attribute definitions. Add error handling code for the
	'Construction attribute and set constructor flags when necessary.
	(Analyze_Subprogram_Specification): Use
	Analyze_Direct_Attribute_Definition.
	* sem_util.adb (Direct_Attribute_Definition_Name): Name of
	entities created for direct attribute definitions. We emit an
	error if multiple attributes.
	(Is_Direct_Attribute_Subp_Spec): Helper to check whether a
	subprogram specification is a direct attribute definition.
	(Is_Constructor_Procedure): Helper to check whether a subprogram
	is a constructor procedure.
	(Has_Default_Constructor): Check whether the default constructor
	exists.
	(Default_Constructor): Not used anymore.
	(Parameter_Count): Likewise.
	(Process_End_Label): Get_Attribute_Reference_Name_String encodes
	also direct attribute definition end labels.
	* sem_util.ads: Likewise.
	* snames.ads-tmpl: Support for 'Constructor attribute.
	* snames.adb-tmpl (Is_Direct_Attribute_Definition_Name): Helper to
	check attributes allowed in direct attribute definitions.
	* aspects.ads: Remove constructor aspect.
	* sem_ch13.adb: Likewise.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch introduces the 'Constructor attribute and implements its direct
attribute definition syntax within subprogram specification. This new shorthand
avoids having to come up with an arbitrary subprogram name and to type out the
constructor aspect. Before, constructors where defined through the aspect
Constructor, which has been removed.

Furthermore, this patch prepares for the expansion of direct attribute
definitions to other attributes.

gcc/ada/ChangeLog:

	* errout.adb (Set_Msg_Node): Support N_Attribute_Reference and
	nodes that denotes direct attribute definitions.
	* exp_dbug.ads: Description for the encoding of direct attribute
	definitions as tick are hard to deal in entity names.
	* erroutc.adb
	(Set_Msg_Insertion_Name): Replace underscore between prefix and
	attribute name in direct attribute definitions; at this point we
	lost the semantic information of node type and we resort to match
	the string name as described in exp_dbug.adb.
	* exp_aggr.adb (Convert_To_Positional): Use Needs_Construction and
	Has_Default_Constructor.
	* exp_ch3.adb (Build_Record_Init_Proc)
	(Expand_N_Object_Declaration): Likewise.
	* exp_attr.adb (Expand_N_Attribute_Reference): Likewise.
	* exp_ch4.adb (Expand_N_Allocator): Likewise.
	* exp_ch6.adb
	(Prepend_Constructor_Procedure_Prologue): Use
	Is_Constructor_Procedure.
	(Make_Parent_Constructor_Call): Use
	Direct_Attribute_Definition_Name.
	* gen_il-fields.ads: Remove Constructor_List and Constructor_Name.
	* gen_il-gen-gen_entities.adb: Likewise.
	* einfo.ads (Needs_Construction): Add description.
	(Has_Delayed_Aspects): Adjust indentation.
	* par-ch13.adb (P_Attribute_Designators): Parse attribute
	designators.
	(P_Representation_Clause): Use P_Attribute_Designators.
	* par-ch6.adb (P_Subprogram): Support attribute designators in
	subprogram name.
	(Rewrites_Entity_If_Direct_Attribute_Def): Fix the specification
	node in case of direct attribute definitions.
	* par-endh.adb (Check_End, Same_Label): Likewise.
	* par.adb (P_Attribute_Designators): Specification.
	* sem_attr.adb (Analyze_Attribute): Error when using 'Constructor
	outside procedure specification.
	(Analyze_Attribute): Add error handling code.
	* sem_ch3.adb (Analyze_Aspect_Specifications): Likewise.
	* sem_ch6.adb (Analyze_Direct_Attribute_Definition): Handle direct
	attribute definitions. Add error handling code for the
	'Construction attribute and set constructor flags when necessary.
	(Analyze_Subprogram_Specification): Use
	Analyze_Direct_Attribute_Definition.
	* sem_util.adb (Direct_Attribute_Definition_Name): Name of
	entities created for direct attribute definitions. We emit an
	error if multiple attributes.
	(Is_Direct_Attribute_Subp_Spec): Helper to check whether a
	subprogram specification is a direct attribute definition.
	(Is_Constructor_Procedure): Helper to check whether a subprogram
	is a constructor procedure.
	(Has_Default_Constructor): Check whether the default constructor
	exists.
	(Default_Constructor): Not used anymore.
	(Parameter_Count): Likewise.
	(Process_End_Label): Get_Attribute_Reference_Name_String encodes
	also direct attribute definition end labels.
	* sem_util.ads: Likewise.
	* snames.ads-tmpl: Support for 'Constructor attribute.
	* snames.adb-tmpl (Is_Direct_Attribute_Definition_Name): Helper to
	check attributes allowed in direct attribute definitions.
	* aspects.ads: Remove constructor aspect.
	* sem_ch13.adb: Likewise.
</pre>
</div>
</content>
</entry>
<entry>
<title>ada: Remove dependence on secondary stack for type with controlled component</title>
<updated>2025-11-03T14:15:15+00:00</updated>
<author>
<name>Gary Dismukes</name>
<email>dismukes@adacore.com</email>
</author>
<published>2025-10-06T19:23:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=64a6f143a1b2d8a8e24e5c2c302d0b3977592b57'/>
<id>64a6f143a1b2d8a8e24e5c2c302d0b3977592b57</id>
<content type='text'>
There are cases where GNAT introduces a dependence on the secondary stack
in a build-in-place function with a result subtype that is definite, when
this dependence could be avoided.  In particular this is done for record
types that requires finalization due to having a controlled component.

At one time such functions required the secondary stack in order to
properly handle cases where the function might raise an exception
(to avoid improper finalization in the caller), but that is no longer
necessary.  We remove the dependence of these functions on the SS,
along with the BIPalloc formal and the generation of the big if_statement
that uses that formal.

An additional small change is to revise the condition for determining when
to generate SS mark/release within functions.

gcc/ada/ChangeLog:

	* exp_ch6.ads (Make_Build_In_Place_Call_In_Allocator): Simplify comment.
	* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Remove obsolete
	comment about not being able to allocate fixed-size controlled results
	on the caller side, and replace another obsolete comment with a simpler
	comment. Call Build_Allocate_Deallocate_Proc when the function doesn't
	need a BIPalloc formal to ensure that function results with controlled
	parts allocated on the caller side will be chained for finalization.
	(Make_Build_In_Place_Call_In_Object_Declaration): Call Needs_BIP_Collection
	on the function's Entity_Id rather than the function call.
	(Needs_BIP_Collection): If a BIP function doesn't need a BIPalloc formal
	then it doesn't need a BIP collection either; return False in that case.
	(Needs_BIP_Alloc_Form): Remove test of Needs_BIP_Collection.
	* exp_ch7.adb (Expand_Cleanup_Actions): Move test of Uses_Sec_Stack
	to be the first conjunct in setting of Needs_Sec_Stack_Mark, and put
	the other tests in a disjunction subsidiary to that. Improve preceding
	comment.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There are cases where GNAT introduces a dependence on the secondary stack
in a build-in-place function with a result subtype that is definite, when
this dependence could be avoided.  In particular this is done for record
types that requires finalization due to having a controlled component.

At one time such functions required the secondary stack in order to
properly handle cases where the function might raise an exception
(to avoid improper finalization in the caller), but that is no longer
necessary.  We remove the dependence of these functions on the SS,
along with the BIPalloc formal and the generation of the big if_statement
that uses that formal.

An additional small change is to revise the condition for determining when
to generate SS mark/release within functions.

gcc/ada/ChangeLog:

	* exp_ch6.ads (Make_Build_In_Place_Call_In_Allocator): Simplify comment.
	* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Remove obsolete
	comment about not being able to allocate fixed-size controlled results
	on the caller side, and replace another obsolete comment with a simpler
	comment. Call Build_Allocate_Deallocate_Proc when the function doesn't
	need a BIPalloc formal to ensure that function results with controlled
	parts allocated on the caller side will be chained for finalization.
	(Make_Build_In_Place_Call_In_Object_Declaration): Call Needs_BIP_Collection
	on the function's Entity_Id rather than the function call.
	(Needs_BIP_Collection): If a BIP function doesn't need a BIPalloc formal
	then it doesn't need a BIP collection either; return False in that case.
	(Needs_BIP_Alloc_Form): Remove test of Needs_BIP_Collection.
	* exp_ch7.adb (Expand_Cleanup_Actions): Move test of Uses_Sec_Stack
	to be the first conjunct in setting of Needs_Sec_Stack_Mark, and put
	the other tests in a disjunction subsidiary to that. Improve preceding
	comment.
</pre>
</div>
</content>
</entry>
<entry>
<title>ada: exp_ch6.adb: entirely disable call validation in CodePeer_Mode</title>
<updated>2025-09-29T09:43:38+00:00</updated>
<author>
<name>Ghjuvan Lacambre</name>
<email>lacambre@adacore.com</email>
</author>
<published>2025-09-16T10:11:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=405adc4e40e8d9181e64804c53f155947ef73c37'/>
<id>405adc4e40e8d9181e64804c53f155947ef73c37</id>
<content type='text'>
This call validation was introduced a couple of months ago and caused
GNAT2SCIL to fail a lot. It was determined that while being invalid for
GCC, the tree was valid for GNAT2SCIL. Since it was thought that only
the checking of the return type caused issue for CodePeer_Mode, this is
the only part that disabled. Recent changes revealed that there also
exists differences in the AST expected by GCC and GNAT2SCIL, and that
checking the actuals also causes issues for GNAT2SCIL. We hence entirely
disable the checking of calls in CodePeer_Mode instead of just the
checking of return values.

gcc/ada/ChangeLog:

	* exp_ch6.adb (Validate_Subprogram_Calls): Do not Check_Calls in CodePeer_Mode.
	(Check_Calls): Remove CodePeer_Mode special case.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This call validation was introduced a couple of months ago and caused
GNAT2SCIL to fail a lot. It was determined that while being invalid for
GCC, the tree was valid for GNAT2SCIL. Since it was thought that only
the checking of the return type caused issue for CodePeer_Mode, this is
the only part that disabled. Recent changes revealed that there also
exists differences in the AST expected by GCC and GNAT2SCIL, and that
checking the actuals also causes issues for GNAT2SCIL. We hence entirely
disable the checking of calls in CodePeer_Mode instead of just the
checking of return values.

gcc/ada/ChangeLog:

	* exp_ch6.adb (Validate_Subprogram_Calls): Do not Check_Calls in CodePeer_Mode.
	(Check_Calls): Remove CodePeer_Mode special case.
</pre>
</div>
</content>
</entry>
<entry>
<title>ada: Fix unnesting problem related to constructors</title>
<updated>2025-09-23T13:01:13+00:00</updated>
<author>
<name>Bob Duff</name>
<email>duff@adacore.com</email>
</author>
<published>2025-09-15T12:26:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=54c1b58486037fc18ade54cefff7410cfbee2267'/>
<id>54c1b58486037fc18ade54cefff7410cfbee2267</id>
<content type='text'>
This patch fixes a bug in unnesting, which is used by the llvm back end.

Exp_Unst relies on the Scope field of nodes to detect up-level
references. Temps created by Prepend_Constructor_Procedure_Prologue
could have an incorrect Scope, causing Exp_Unst to use an up-level
reference to an activation record to implement up-level references. That
won't work; Exp_Unst is supposed to REMOVE up-level references.
This patch corrects the Scope of such temps.

gcc/ada/ChangeLog:

	* exp_ch6.adb (Prepend_Constructor_Procedure_Prologue):
	Push/Pop the procedure scope, so that temps created herein
	get the right Scope.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch fixes a bug in unnesting, which is used by the llvm back end.

Exp_Unst relies on the Scope field of nodes to detect up-level
references. Temps created by Prepend_Constructor_Procedure_Prologue
could have an incorrect Scope, causing Exp_Unst to use an up-level
reference to an activation record to implement up-level references. That
won't work; Exp_Unst is supposed to REMOVE up-level references.
This patch corrects the Scope of such temps.

gcc/ada/ChangeLog:

	* exp_ch6.adb (Prepend_Constructor_Procedure_Prologue):
	Push/Pop the procedure scope, so that temps created herein
	get the right Scope.
</pre>
</div>
</content>
</entry>
<entry>
<title>ada: Revert "Remove dependence on secondary stack for type with controlled component"</title>
<updated>2025-09-16T08:18:51+00:00</updated>
<author>
<name>Gary Dismukes</name>
<email>dismukes@adacore.com</email>
</author>
<published>2025-09-04T00:46:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=bc4d53dadb481f1b307e4b10e7dc3d7d3c11b3ee'/>
<id>bc4d53dadb481f1b307e4b10e7dc3d7d3c11b3ee</id>
<content type='text'>
This reverts commit 91b51fc42b167eedaaded6360c490a4306bc5c55.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 91b51fc42b167eedaaded6360c490a4306bc5c55.
</pre>
</div>
</content>
</entry>
<entry>
<title>ada: Remove dependence on secondary stack for type with controlled component</title>
<updated>2025-09-15T12:59:34+00:00</updated>
<author>
<name>Gary Dismukes</name>
<email>dismukes@adacore.com</email>
</author>
<published>2025-08-25T23:44:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=91b51fc42b167eedaaded6360c490a4306bc5c55'/>
<id>91b51fc42b167eedaaded6360c490a4306bc5c55</id>
<content type='text'>
There are cases where GNAT introduces a dependence on the secondary stack
in a build-in-place function with a result subtype that is definite, when
this dependence could be avoided.  In particular this is done for record
types that requires finalization due to having a controlled component.

At one time such functions required the secondary stack in order to
properly handle cases where the function might raise an exception
(to avoid improper finalization in the caller), but that is no longer
necessary.  We remove the dependence of these functions on the SS,
along with the BIPalloc formal and the generation of the big if_statement
that uses that formal.

An additional small change is to revise the condition for determining when
to generate SS mark/release within functions.

gcc/ada/ChangeLog:

	* exp_ch6.ads (Make_Build_In_Place_Call_In_Allocator): Simplify comment.
	* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Remove obsolete
	comment about not being able to allocate fixed-size controlled results
	on the caller side, and replace another obsolete comment with a simpler
	comment. Call Build_Allocate_Deallocate_Proc when the function doesn't
	need a BIPalloc formal to ensure that function results with controlled
	parts allocated on the caller side will be chained for finalization.
	(Make_Build_In_Place_Call_In_Object_Declaration): Call Needs_BIP_Collection
	on the function's Entity_Id rather than the function call.
	(Needs_BIP_Collection): If a BIP function doesn't need a BIPalloc formal
	then it doesn't need a BIP collection either; return False in that case.
	(Needs_BIP_Alloc_Form): Remove test of Needs_BIP_Collection.
	* exp_ch7.adb (Expand_Cleanup_Actions): Move test of Uses_Sec_Stack
	to be the first conjunct in setting of Needs_Sec_Stack_Mark, and put
	the other tests in a disjunction subsidiary to that. Improve preceding
	comment.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There are cases where GNAT introduces a dependence on the secondary stack
in a build-in-place function with a result subtype that is definite, when
this dependence could be avoided.  In particular this is done for record
types that requires finalization due to having a controlled component.

At one time such functions required the secondary stack in order to
properly handle cases where the function might raise an exception
(to avoid improper finalization in the caller), but that is no longer
necessary.  We remove the dependence of these functions on the SS,
along with the BIPalloc formal and the generation of the big if_statement
that uses that formal.

An additional small change is to revise the condition for determining when
to generate SS mark/release within functions.

gcc/ada/ChangeLog:

	* exp_ch6.ads (Make_Build_In_Place_Call_In_Allocator): Simplify comment.
	* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Remove obsolete
	comment about not being able to allocate fixed-size controlled results
	on the caller side, and replace another obsolete comment with a simpler
	comment. Call Build_Allocate_Deallocate_Proc when the function doesn't
	need a BIPalloc formal to ensure that function results with controlled
	parts allocated on the caller side will be chained for finalization.
	(Make_Build_In_Place_Call_In_Object_Declaration): Call Needs_BIP_Collection
	on the function's Entity_Id rather than the function call.
	(Needs_BIP_Collection): If a BIP function doesn't need a BIPalloc formal
	then it doesn't need a BIP collection either; return False in that case.
	(Needs_BIP_Alloc_Form): Remove test of Needs_BIP_Collection.
	* exp_ch7.adb (Expand_Cleanup_Actions): Move test of Uses_Sec_Stack
	to be the first conjunct in setting of Needs_Sec_Stack_Mark, and put
	the other tests in a disjunction subsidiary to that. Improve preceding
	comment.
</pre>
</div>
</content>
</entry>
<entry>
<title>ada: Fix missing finalization for qualified expression in conditional expression</title>
<updated>2025-09-15T12:59:29+00:00</updated>
<author>
<name>Eric Botcazou</name>
<email>ebotcazou@adacore.com</email>
</author>
<published>2025-08-26T22:16:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=c7ef48f2be5aa75ba9108ef1f6ac3a3206a14c9f'/>
<id>c7ef48f2be5aa75ba9108ef1f6ac3a3206a14c9f</id>
<content type='text'>
A qualified expression around a function call may cause a temporary to be
created and, therefore, cannot be bypassed in Expand_Ctrl_Function_Call.

gcc/ada/ChangeLog:

	* exp_util.ads (Unqualified_Unconditional_Parent): New function.
	* exp_util.adb (Unconditional_Parent): Do not look through qualified
	expressions.
	(Unqualified_Unconditional_Parent): New function identical to the
	original Unconditional_Parent.
	* exp_aggr.adb (Convert_To_Assignments): Replace Unconditional_Parent
	with Unqualified_Unconditional_Parent.
	(Expand_Array_Aggregate): Likewse.
	* exp_ch4.adb (Expand_N_Case_Expression): Likewise.
	(Expand_N_If_Expression): Likewise.
	* exp_ch6.adb (Expand_Ctrl_Function_Call): Do not bypass an enclosing
	qualified expression in the parent chain.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A qualified expression around a function call may cause a temporary to be
created and, therefore, cannot be bypassed in Expand_Ctrl_Function_Call.

gcc/ada/ChangeLog:

	* exp_util.ads (Unqualified_Unconditional_Parent): New function.
	* exp_util.adb (Unconditional_Parent): Do not look through qualified
	expressions.
	(Unqualified_Unconditional_Parent): New function identical to the
	original Unconditional_Parent.
	* exp_aggr.adb (Convert_To_Assignments): Replace Unconditional_Parent
	with Unqualified_Unconditional_Parent.
	(Expand_Array_Aggregate): Likewse.
	* exp_ch4.adb (Expand_N_Case_Expression): Likewise.
	(Expand_N_If_Expression): Likewise.
	* exp_ch6.adb (Expand_Ctrl_Function_Call): Do not bypass an enclosing
	qualified expression in the parent chain.
</pre>
</div>
</content>
</entry>
</feed>
