[Ada] Enable current value propagation within pragma expressions
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 16 Mar 2022 20:50:08 +0000 (21:50 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 17 May 2022 08:25:40 +0000 (08:25 +0000)
commitbc17882341b506a7e1052fa5be7ddbb3220cb2b1
tree8569c4769e1a1c24bce85ede1b45d1d05f0a3b19
parentbc9aa450eb47e440a4b909a10a271fe074e896eb
[Ada] Enable current value propagation within pragma expressions

This patch fixes an odd incomplete optimization within pragma
expressions. For example, in this code:

   X := True;
   pragma Assert (X = True);
   pragma Assert (X);

the first assertion was eliminated by the frontend (regardless of the
optimization switches), while the second assertion was only eliminated
by the backend and only with switch -O1 or similar.

The problem was that the current value propagation was disabled for
references immediately within pragma argument associations. This was
meant to avoid a crash when such a reference appears in pragma
Inspection_Point, but this wasn't a proper fix. The proper solution is
rather to not expand references in pragma Inspection_Point at all.

Actually, this expansion was enabled to avoid a yet another crash, when
the parameter of pragma Inspection_Point is a prival (i.e. a renaming of
private protected component). It turns out that none of these suspicious
problematic fixes is no longer necessary.

Cleanup related to fixes of current value propagation in expansion of
attribute Loop_Entry.

gcc/ada/

* exp_ch2.adb (Expand_Current_Value): Remove special case for
references immediately within pragma argument associations.
* exp_prag.adb (Expand_Pragma_Inspection_Point): Remove special
case for privals.
gcc/ada/exp_ch2.adb
gcc/ada/exp_prag.adb