[Ada] Fix spurious error on checking of null Abstract_State
authorYannick Moy <moy@adacore.com>
Wed, 11 Dec 2019 16:39:07 +0000 (17:39 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 25 May 2020 14:00:55 +0000 (10:00 -0400)
2020-05-25  Yannick Moy  <moy@adacore.com>

gcc/ada/

* sem_util.adb (Check_No_Hidden_State): Stop propagation at
first block/task/entry.

gcc/ada/ChangeLog
gcc/ada/sem_util.adb

index 7c8af5f..4e1b34d 100644 (file)
@@ -1,5 +1,10 @@
 2020-05-25  Yannick Moy  <moy@adacore.com>
 
+       * sem_util.adb (Check_No_Hidden_State): Stop propagation at
+       first block/task/entry.
+
+2020-05-25  Yannick Moy  <moy@adacore.com>
+
        * doc/gnat_rm/implementation_defined_pragmas.rst: Document
        changes to pragmas Compile_Time_Error/Compile_Time_Warning.
        * gnat_rm.texi: Regenerate.
index e1703e9..b980b4c 100644 (file)
@@ -3387,10 +3387,14 @@ package body Sem_Util is
             return;
 
          --  Objects and states that appear immediately within a subprogram or
-         --  inside a construct nested within a subprogram do not introduce a
-         --  hidden state. They behave as local variable declarations.
+         --  entry inside a construct nested within a subprogram do not
+         --  introduce a hidden state. They behave as local variable
+         --  declarations. The same is true for elaboration code inside a block
+         --  or a task.
 
-         elsif Is_Subprogram (Context) then
+         elsif Is_Subprogram_Or_Entry (Context)
+           or else Ekind_In (Context, E_Block, E_Task_Type)
+         then
             return;
 
          --  When examining a package body, use the entity of the spec as it