Side_Effect_Free was always assuming an aggregate isn't side effects
free, but we can do better by taking advantage of the
Compile_Time_Known_Aggregate flag.

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

2020-06-09  Arnaud Charlet  <char...@adacore.com>

gcc/ada/

        * exp_util.adb (Side_Effect_Free): Improve handling of
        N_Aggregate.
--- gcc/ada/exp_util.adb
+++ gcc/ada/exp_util.adb
@@ -13357,6 +13357,12 @@ package body Exp_Util is
          =>
             return True;
 
+         --  An aggregate is side effect free if all its values are compile
+         --  time known.
+
+         when N_Aggregate =>
+            return Compile_Time_Known_Aggregate (N);
+
          --  We consider that anything else has side effects. This is a bit
          --  crude, but we are pretty close for most common cases, and we
          --  are certainly correct (i.e. we never return True when the

Reply via email to