[Ada] Don't constant-fold renamed qualified expressions

Pierre-Marie de Rodat derodat@adacore.com
Wed Nov 25 13:27:24 GMT 2020


In a case like:

   X : Integer := 1;
   Y : Integer renames Integer'(X);

the value of Y is changed by any subsequent assignments to X. Thus,
replacing the use of X with a literal 1 would be a mistake.

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

gcc/ada/

	* exp_ch2.adb (Expand_Entity_Reference): A new local predicate
	Is_Object_Renaming_Name indicates whether a given expression
	occurs (after looking through qualified expressions and type
	conversions) as the name of an object renaming declaration. If
	Current_Value is available but this new predicate is True, then
	ignore the availability of Current_Value.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 2381 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201125/590bd5e8/attachment-0001.bin>


More information about the Gcc-patches mailing list