When renaming a qualified expression with an operator, e.g.:

   Y : Boolean renames Boolean'(not X);

routine Evaluate_Name should handle operators just like it handles
function calls. This doesn't appear to matter for GNAT (where this
routine is called in very few cases, as described in the comment for
Evaluation_Required), but is critical for GNATprove (where the lack of a
forced evaluation triggers might cause a soundness bug).

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

2020-06-16  Piotr Trojanek  <troja...@adacore.com>

gcc/ada/

        * exp_util.adb (Evaluate_Name): Force evaluation of operators.
--- gcc/ada/exp_util.adb
+++ gcc/ada/exp_util.adb
@@ -4953,9 +4953,11 @@ package body Exp_Util is
          when N_Explicit_Dereference =>
             Force_Evaluation (Prefix (Nam));
 
-         --  For a function call, we evaluate the call
+         --  For a function call, we evaluate the call; same for an operator
 
-         when N_Function_Call =>
+         when N_Function_Call
+            | N_Op
+         =>
             Force_Evaluation (Nam);
 
          --  For a qualified expression, we evaluate the underlying object
@@ -4989,9 +4991,11 @@ package body Exp_Util is
          when N_Type_Conversion =>
             Evaluate_Name (Expression (Nam));
 
-         --  The remaining cases are direct name, operator symbol and character
-         --  literal. In all these cases, we do nothing, since we want to
-         --  reevaluate each time the renamed object is used.
+         --  The remaining cases are direct name and character literal. In all
+         --  these cases, we do nothing, since we want to reevaluate each time
+         --  the renamed object is used. ??? There are more remaining cases, at
+         --  least in the GNATprove_Mode, where this routine is called in more
+         --  contexts than in GNAT.
 
          when others =>
             null;

Reply via email to