aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2019-07-04 08:05:23 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-04 08:05:23 +0000
commita0766a8258f014ac2715d8c49fcaf83b3eb62a00 (patch)
tree7e29684bff87fdf983fa639ebe81a5831d7f2738 /gcc
parentcd93d2d89d3a59e034263b1d1d657286b1074ead (diff)
downloadgcc-a0766a8258f014ac2715d8c49fcaf83b3eb62a00.zip
gcc-a0766a8258f014ac2715d8c49fcaf83b3eb62a00.tar.gz
gcc-a0766a8258f014ac2715d8c49fcaf83b3eb62a00.tar.bz2
[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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/exp_ch4.adb31
2 files changed, 36 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 4de9db7..1a86a4d 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,11 @@
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
conversions.
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index b9aa4a5..7ba4283 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: