Commit a0766a82 by Arnaud Charlet Committed by Pierre-Marie de Rodat

[Ada] CCG: restrict folding for boolean tests

2019-07-04  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* exp_ch4.adb (Expand_Short_Circuit_Operator): Strip
	N_Variable_Reference_Marker when checking for the presence of
	actions.

From-SVN: r273047
parent cd93d2d8
2019-07-04 Arnaud Charlet <charlet@adacore.com> 2019-07-04 Arnaud Charlet <charlet@adacore.com>
* exp_ch4.adb (Expand_Short_Circuit_Operator): Strip
N_Variable_Reference_Marker when checking for the presence of
actions.
2019-07-04 Arnaud Charlet <charlet@adacore.com>
* exp_aggr.adb (Check_Component): Take into account type * exp_aggr.adb (Check_Component): Take into account type
conversions. conversions.
......
...@@ -12391,6 +12391,10 @@ package body Exp_Ch4 is ...@@ -12391,6 +12391,10 @@ package body Exp_Ch4 is
-- For Opnd a boolean expression, return a Boolean expression equivalent -- For Opnd a boolean expression, return a Boolean expression equivalent
-- to Opnd /= Shortcut_Value. -- to Opnd /= Shortcut_Value.
function Useful (Actions : List_Id) return Boolean;
-- Return True if Actions is not empty and contains useful nodes to
-- process.
-------------------- --------------------
-- Make_Test_Expr -- -- Make_Test_Expr --
-------------------- --------------------
...@@ -12404,6 +12408,31 @@ package body Exp_Ch4 is ...@@ -12404,6 +12408,31 @@ package body Exp_Ch4 is
end if; end if;
end Make_Test_Expr; end Make_Test_Expr;
------------
-- Useful --
------------
function Useful (Actions : List_Id) return Boolean is
L : Node_Id;
begin
if Present (Actions) then
L := First (Actions);
-- For now "useful" means not N_Variable_Reference_Marker.
-- Consider stripping other nodes in the future.
while Present (L) loop
if Nkind (L) /= N_Variable_Reference_Marker then
return True;
end if;
Next (L);
end loop;
end if;
return False;
end Useful;
-- Local variables -- Local variables
Op_Var : Entity_Id; Op_Var : Entity_Id;
...@@ -12463,7 +12492,7 @@ package body Exp_Ch4 is ...@@ -12463,7 +12492,7 @@ package body Exp_Ch4 is
-- must only be executed if the right operand of the short circuit is -- must only be executed if the right operand of the short circuit is
-- executed and not otherwise. -- executed and not otherwise.
if Present (Actions (N)) then if Useful (Actions (N)) then
Actlist := Actions (N); Actlist := Actions (N);
-- The old approach is to expand: -- The old approach is to expand:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment