From: Arnaud Charlet Date: Thu, 4 Jul 2019 08:05:23 +0000 (+0000) Subject: [Ada] CCG: restrict folding for boolean tests X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a0766a8258f014ac2715d8c49fcaf83b3eb62a00;p=gcc.git [Ada] CCG: restrict folding for boolean tests 2019-07-04 Arnaud Charlet gcc/ada/ * exp_ch4.adb (Expand_Short_Circuit_Operator): Strip N_Variable_Reference_Marker when checking for the presence of actions. From-SVN: r273047 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 4de9db792a9..1a86a4d439a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-07-04 Arnaud Charlet + + * exp_ch4.adb (Expand_Short_Circuit_Operator): Strip + N_Variable_Reference_Marker when checking for the presence of + actions. + 2019-07-04 Arnaud Charlet * exp_aggr.adb (Check_Component): Take into account type diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index b9aa4a5edf5..7ba4283897a 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -12391,6 +12391,10 @@ package body Exp_Ch4 is -- For Opnd a boolean expression, return a Boolean expression equivalent -- 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 -- -------------------- @@ -12404,6 +12408,31 @@ package body Exp_Ch4 is end if; 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 Op_Var : Entity_Id; @@ -12463,7 +12492,7 @@ package body Exp_Ch4 is -- must only be executed if the right operand of the short circuit is -- executed and not otherwise. - if Present (Actions (N)) then + if Useful (Actions (N)) then Actlist := Actions (N); -- The old approach is to expand: