[Ada] Spurious error on address clause in task body

Message ID 20200605122338.GA56675@adacore.com
State New
Headers show
Series
  • [Ada] Spurious error on address clause in task body
Related show

Commit Message

Pierre-Marie de Rodat June 5, 2020, 12:23 p.m.
Compiler rejects an aspect specification for Address on a local variable
in a task body, when the expression for the address is the address of a
previous local object in the same task body.

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

2020-06-05  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch9.adb, (Analyze_Task_Body): After analying the task
	body, indicate that all local variables have no delayed aspects.
	This prevents improper later calls to
	Check_Aspect_At_End_Of_Declarations, that would happen when the
	constructed task_procedure body (generated during expansion) is
	analyzed. The legality of aspect specifications that may appear
	on local declarations has already been established, and it is in
	general not possible to recheck them properly during expansion,
	when visibility may not be fully established.

Patch

--- gcc/ada/sem_ch9.adb
+++ gcc/ada/sem_ch9.adb
@@ -2993,6 +2993,24 @@  package body Sem_Ch9 is
          else
             Set_First_Private_Entity (Spec_Id, First_Entity (Spec_Id));
          end if;
+
+         --  The entity list of the current scope now includes entities in
+         --  the spec as well as the body. Their declarations will become
+         --  part of the statement sequence of the task body procedure that
+         --  is built during expansion. Indicate that aspect specifications
+         --  for these entities need not be rechecked. The guards on
+         --  Check_Aspect_At_End_Of_Declarations are not sufficient to
+         --  suppress these checks, because the declarations come from source.
+
+         declare
+            Priv : Entity_Id := First_Private_Entity (Spec_Id);
+
+         begin
+            while Present (Priv) loop
+               Set_Has_Delayed_Aspects (Priv, False);
+               Next_Entity (Priv);
+            end loop;
+         end;
       end if;
 
       --  Mark all handlers as not suitable for local raise optimization,