[Ada] Fix ICEs with function returning variable-sized type

Eric Botcazou ebotcazou@adacore.com
Thu May 28 15:38:00 GMT 2015


This fixes various cases of a common pattern that would result in an ICE in 
the gimplifier because it is trying to create a temporary of variable size.

Tested on x86_64-suse-linux, applied on the mainline.


2015-05-28  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/gigi.h (gnat_stabilize_reference): Adjust.
	(rewrite_fn): Remove third parameter.
	(type_is_padding_self_referential): New inline predicate.
	(return_type_with_variable_size_p): Likewise.
	* gcc-interface/decl.c (allocatable_size_p): More around.
	(cannot_be_superflat_p): Rename into...
	(cannot_be_superflat ): ...this.
	(initial_value_needs_conversion): New predicate.
	(gnat_to_gnu_entity): Invoke type_is_padding_self_referential,
	initial_value_needs_conversion and adjust to above renaming.
	For a renaming, force the materialization if the inner expression
	is compound.  Adjust calls to elaborate_reference and build a
	compound expression if needed.
	(struct er_dat): Add N field.
	(elaborate_reference_1): Remove N parameter and adjust.
	(elaborate_reference): Add INIT parameter and pass it in the call to
	gnat_rewrite_reference.  Adjust initial expression.
	* gcc-interface/trans.c (Call_to_gnu): Treat renamings the same way as
	regular object declarations when it comes to creating a temporary.
	Adjust call to gnat_stabilize_reference and build a compound expression
 	if needed.  Invoke return_type_with_variable_size_p.
	(gnat_to_gnu): Invoke type_is_padding_self_referential.  In case #4,
	return a call to a function unmodified if it returns with variable size
 	and is also the initial expression in an object declaration.
	* gcc-interface/utils2.c (build_binary_op) <INIT_EXPR>: Use the RHS'
	type if it is a call to a function that returns with variable size.
	(build_unary_op): Invoke type_is_padding_self_referential.
	(gnat_stabilize_reference_1): Remove N parameter and adjust.
	(gnat_stabilize_reference): Add INIT parameter and pass it in the call
	to gnat_rewrite_reference.
	(gnat_rewrite_reference):  Remove N, add INIT parameter and adjust.
	<COMPOUND_EXPR>: New case.


2015-05-28  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/varsize_temp.adb: Rename into...
	* gnat.dg/varsize1.adb: ...this.
	* gnat.dg/varsize_copy.ad[sb]: Rename into...
	* gnat.dg/varsize2.ad[sb]: ...this.
	* gnat.dg/varsize3_1.adb: New test.
	* gnat.dg/varsize3_2.adb: Likewise.
	* gnat.dg/varsize3_3.adb: Likewise.
	* gnat.dg/varsize3_4.adb: Likewise.
	* gnat.dg/varsize3_5.adb: Likewise.
	* gnat.dg/varsize3_6.adb: Likewise.
	* gnat.dg/varsize3_pkg1.ads: New helper.
	* gnat.dg/varsize3_pkg2.ads: Likewise.
	* gnat.dg/varsize3_pkg3.ads: Likewise.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-patch
Size: 27968 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/cb1d7354/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varsize3_1.adb
Type: text/x-adasrc
Size: 66 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/cb1d7354/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varsize3_1.ads
Type: text/x-adasrc
Size: 142 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/cb1d7354/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varsize3_2.adb
Type: text/x-adasrc
Size: 143 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/cb1d7354/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varsize3_5.adb
Type: text/x-adasrc
Size: 142 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/cb1d7354/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varsize3_3.adb
Type: text/x-adasrc
Size: 136 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/cb1d7354/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varsize3_6.adb
Type: text/x-adasrc
Size: 138 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/cb1d7354/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varsize3_4.adb
Type: text/x-adasrc
Size: 139 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/cb1d7354/attachment-0007.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varsize3_pkg1.ads
Type: text/x-adasrc
Size: 248 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/cb1d7354/attachment-0008.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varsize3_pkg2.ads
Type: text/x-adasrc
Size: 86 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/cb1d7354/attachment-0009.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varsize3_pkg3.ads
Type: text/x-adasrc
Size: 164 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150528/cb1d7354/attachment-0010.bin>


More information about the Gcc-patches mailing list