The definition of constants can be nested inside declare expressions in
which case they cannot be considered as valid contexts for calls to
volatile functions and access to volatile variable.

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

2020-06-18  Claire Dross  <dr...@adacore.com>

gcc/ada/

        * sem_util.adb (Is_OK_Volatile_Context): Return False on
        definitions of constants declared in declare expressions.
--- gcc/ada/sem_util.adb
+++ gcc/ada/sem_util.adb
@@ -17298,6 +17298,7 @@ package body Sem_Util is
       elsif Nkind (Context) = N_Object_Declaration
         and then Present (Expression (Context))
         and then Expression (Context) = Obj_Ref
+        and then Nkind (Parent (Context)) /= N_Expression_With_Actions
       then
          Obj_Id := Defining_Entity (Context);
 

Reply via email to