gcc-patches@gcc.gnu.org
[Top] [All Lists]

[Ada] Pragma Task_Name, generic units, and task discriminants

Subject: [Ada] Pragma Task_Name, generic units, and task discriminants
From: Arnaud Charlet
Date: Fri, 10 Jul 2009 11:11:41 +0200
The pragma Task_Name appears in a task declaration, but its argument is
used as an actual in the call to Create_Task, within the initializastion
procedure of the corresponding record. As a result, the argument must be
expanded in the context of the call, not the original task declaration.
However, in a generic context, the argument must be analyzed to capture
any possible global references. The retrieval of the correct discriminal
must be treated specially in this case.

The following must compile quietly;

with Gen;
procedure Main is
   package G is new Gen;
begin
   null;
end;
---
generic
package Gen is
   pragma Elaborate_Body;
end;
---
with Log;
with Gnat.Source_Info;
package body Gen is
   function Name return String renames
Gnat.Source_Info.Source_Location;
   task Go1 is
     pragma Task_Name (Name);
   end Go1;
   task body Go1 is
   begin
      null;
   end Go1;

   task Go2 is
     pragma Task_Name (Log.Name);
   end Go2;
   task body Go2 is
   begin
      null;
   end Go2;
end;
---
with Gnat.Source_Info;
package Log is
   function Name return String renames
Gnat.Source_Info.Source_Location;
end Log;

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

2009-07-10  Ed Schonberg  <schonberg@xxxxxxxxxxx>

        * sem_prag.adb (Analyze pragma, case Task_Name): Analyze argument of
        pragma, to capture global references if the context is generic.

        * exp_ch2.adb (Expand_Discriminant): If a task type discriminant
        appears within the initialization procedure for the corresponding
        record, replace it with the proper discriminal.

Attachment: difs
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>
  • [Ada] Pragma Task_Name, generic units, and task discriminants, Arnaud Charlet <=