[Ada] Fix internal error on extended return and fixed-point result

Pierre-Marie de Rodat derodat@adacore.com
Mon Nov 30 14:17:12 GMT 2020


This prevents the expander from creating an access before elaboration
issue for a temporary generated for a range check applied to the
expression of a degenerate extended return statement (an extended return
statement without an explicit do/end construct).

Expand_N_Extended_Return_Statement has got a fast track for this case,
but it does not do what it is supposed to do and ends up generating both
the declaration of the return object with the expresion and the direct
return of the expression, which is problematic if the direct return is
analyzed again and subject to a range check.

The patch reimplements the fast track as documented and makes sure that
it is used only when the declaration of the return object can be
dropped.  It also contains a fixlet for
Check_Type_Or_Object_External_Properties.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* contracts.adb (Check_Type_Or_Object_External_Properties): Make
	sure to exclude all return objects from the SPARK legality rule
	on effectively volatile variables.
	* exp_ch6.adb (Expand_N_Extended_Return_Statement): Use the fast
	track only when the declaration of the return object can be
	dropped.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 2768 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201130/44d48f1b/attachment.bin>


More information about the Gcc-patches mailing list