This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Support for Priority aspect


Priority may be specified for protected and task types and objects using the
standard aspect notation. This patch makes the analysis of the aspect
argument earlier, so it is taken into account when the task or protected
object is been created.

The following must compile quietly in Ada2012 mode and execute without
producing any output.

with Priority_Aspect;

procedure Test_Priority_Aspect is
begin
   null;
end Test_Priority_Aspect;

with System;

package Priority_Aspect is

   Prio : constant System.Priority := System.Priority'First;

   task type Aspect_Type with Priority => Prio;

   T : Aspect_Type;

   task Aspect_Task with Priority => Prio;

   protected type Pr_Type
      with Priority => Prio
   is
      procedure Proc;
   end Pr_Type;

   P : Pr_Type;

   protected Pr_Obj
      with Priority => Prio
   is
      procedure Proc;
   end Pr_Obj;

end Priority_Aspect;

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Dynamic_Priorities; use Ada.Dynamic_Priorities;

package body Priority_Aspect is

   protected body Pr_Type is
      procedure Proc is
      begin
         if Pr_Type'Priority /= Prio then
            Put_Line
              ("Unexpected priority when using aspect in protected type");
         end if;
      end Proc;
   end Pr_Type;

   protected body Pr_Obj is
      procedure Proc is
      begin
         if Pr_Obj'Priority /= Prio then
            Put_Line
              ("Unexpected priority when using aspect in protected object");
         end if;
      end Proc;
   end Pr_Obj;

   task body Aspect_Type is
   begin
      if Get_Priority /= Prio then
         Put_Line ("Unexpected priority when using aspect in task type");
      end if;

      P.Proc;
   end Aspect_Type;

   task body Aspect_Task is
   begin
      if Get_Priority /= Prio then
         Put_Line ("Unexpected priority when using aspect in task object");
      end if;

      Pr_Obj.Proc;
   end Aspect_Task;

end Priority_Aspect;

Command: gnatmake -q -gnat12 test_priority_aspect; test_priority_aspect

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

2011-08-31  Jose Ruiz  <ruiz@adacore.com>

	* sem_ch13.adb (Analyze_Aspect_Specifications): For the Priority and
	Interrupt_Priority aspects, force the analysis of the aspect expression
	(when building the equivalent pragma). Otherwise, its analysis is done
	too late, after the task or protected object has been created.
	* sem_ch9.adb (Analyze_Single_Protected_Declaration,
	Analyze_Single_Task_Declaration): Remove the code to move the aspects
	to the object declaration because they are needed in the type
	declaration.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]