[Ada] Fix spurious error on renaming of component of return value

Eric Botcazou ebotcazou@adacore.com
Mon Feb 29 09:03:00 GMT 2016


This is a long-standing regression present in the compiler: it issues an 
unexpected error on the renaming of a component of the return value of a 
function call, when the return type has dynamic size and the renaming is 
declared at library level.

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


2016-02-29  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/ada-tree.h (DECL_RETURN_VALUE_P): New macro.
	* gcc-interface/gigi.h (gigi): Remove useless attribute.
	(gnat_gimplify_expr): Likewise.
	(gnat_to_gnu_external): Declare.
	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: Factor out
	code dealing with the expression of external constants into...
	Invoke gnat_to_gnu_external instead.
	<E_Variable>: Invoke gnat_to_gnu_external to translate renamed objects
	when not for a definition.  Deal with COMPOUND_EXPR and variables with
	DECL_RETURN_VALUE_P set for renamings and with the case of a dangling
	'reference to a function call in a renaming.  Remove obsolete test and
	adjust associated comment.
	* gcc-interface/trans.c (Call_to_gnu): Set DECL_RETURN_VALUE_P on the
	temporaries created to hold the return value, if any.
	(gnat_to_gnu_external): ...this.  New function.
	* gcc-interface/utils.c (create_var_decl): Detect a constant created
	to hold 'reference to function call.
	* gcc-interface/utils2.c (build_unary_op) <ADDR_EXPR>: Add folding
	for COMPOUND_EXPR in the DECL_RETURN_VALUE_P case.


2016-02-29  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/renaming8.adb: New test.
	* gnat.dg/renaming8_pkg1.ads: New helper.
	* gnat.dg/renaming8_pkg2.ad[sb]: Likewise.
	* gnat.dg/renaming8_pkg3.ad[sb]: Likewise.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-patch
Size: 11980 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160229/27e94c72/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: renaming8.adb
Type: text/x-adasrc
Size: 172 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160229/27e94c72/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: renaming8_pkg1.ads
Type: text/x-adasrc
Size: 119 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160229/27e94c72/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: renaming8_pkg3.ads
Type: text/x-adasrc
Size: 86 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160229/27e94c72/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: renaming8_pkg2.adb
Type: text/x-adasrc
Size: 131 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160229/27e94c72/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: renaming8_pkg2.ads
Type: text/x-adasrc
Size: 231 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160229/27e94c72/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: renaming8_pkg3.adb
Type: text/x-adasrc
Size: 123 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160229/27e94c72/attachment-0006.bin>


More information about the Gcc-patches mailing list