einfo.adb einfo.ads (Get_Rep_Item): Removed.
authorVincent Pucci <pucci@adacore.com>
Thu, 14 Jun 2012 10:43:53 +0000 (10:43 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 14 Jun 2012 10:43:53 +0000 (12:43 +0200)
2012-06-14  Vincent Pucci  <pucci@adacore.com>

* einfo.adb einfo.ads (Get_Rep_Item): Removed.
(Get_Rep_Item_For_Entity): Removed.
(Get_Rep_Pragma): Removed.
(Get_Rep_Pragma_For_Entity): Removed.
(Has_Rep_Item): Removed.
(Has_Rep_Pragma): Removed.
(Has_Rep_Pragma_For_Entity): Removed.
* exp_ch9.adb (Expand_N_Task_Type_Declaration):
Has_Rep_Pragma_For_Entity replaced by Has_Rep_Pragma
and Get_Rep_Pragma_For_Entity replaced by Get_Rep_Pragma.
(Make_Task_Create_Call): Has_Rep_Pragma_For_Entity replaced
by Has_Rep_Pragma and Get_Rep_Pragma_For_Entity replaced by
Get_Rep_Pragma.
* exp_intr.adb: Dependency to Sem_Aux added for call to Get_Rep_Pragma.
* sem_aux.adb (Get_Rep_Item): New routine.
(Get_Rep_Pragma): New routine.
(Has_Rep_Item): New routine.
(Has_Rep_Pragma): New routine.
(Nearest_Ancestor): Minor reformatting.
* sem_aux.ads (Get_Rep_Item): New routine.
(Get_Rep_Pragma): New routine.
(Has_Rep_Item): New routine.
(Has_Rep_Pragma): New routine.
* sem_ch13.adb (Duplicate_Clause): Restore original error messages.
* sem_eval.adb (Subtypes_Statically_Match): Get_Rep_Item_For_Entity
replaced by Get_Rep_Item.
* sem_prag.adb (Analyze_Pragma): Restore original error messages.
(Check_Duplicate_Pragma): Restore original error messages.

From-SVN: r188607

gcc/ada/ChangeLog
gcc/ada/einfo.adb
gcc/ada/einfo.ads
gcc/ada/exp_ch9.adb
gcc/ada/exp_intr.adb
gcc/ada/sem_aux.adb
gcc/ada/sem_aux.ads
gcc/ada/sem_ch13.adb
gcc/ada/sem_eval.adb
gcc/ada/sem_prag.adb

index 6ced520d92b5e1c3998dd006b6874de4452cc0e4..4fa567771cbece9f59a0cd224ab114f7dbf285c3 100644 (file)
@@ -1,3 +1,34 @@
+2012-06-14  Vincent Pucci  <pucci@adacore.com>
+
+       * einfo.adb einfo.ads (Get_Rep_Item): Removed.
+       (Get_Rep_Item_For_Entity): Removed.
+       (Get_Rep_Pragma): Removed.
+       (Get_Rep_Pragma_For_Entity): Removed.
+       (Has_Rep_Item): Removed.
+       (Has_Rep_Pragma): Removed.
+       (Has_Rep_Pragma_For_Entity): Removed.
+       * exp_ch9.adb (Expand_N_Task_Type_Declaration):
+       Has_Rep_Pragma_For_Entity replaced by Has_Rep_Pragma
+       and Get_Rep_Pragma_For_Entity replaced by Get_Rep_Pragma.
+       (Make_Task_Create_Call): Has_Rep_Pragma_For_Entity replaced
+       by Has_Rep_Pragma and Get_Rep_Pragma_For_Entity replaced by
+       Get_Rep_Pragma.
+       * exp_intr.adb: Dependency to Sem_Aux added for call to Get_Rep_Pragma.
+       * sem_aux.adb (Get_Rep_Item): New routine.
+       (Get_Rep_Pragma): New routine.
+       (Has_Rep_Item): New routine.
+       (Has_Rep_Pragma): New routine.
+       (Nearest_Ancestor): Minor reformatting.
+       * sem_aux.ads (Get_Rep_Item): New routine.
+       (Get_Rep_Pragma): New routine.
+       (Has_Rep_Item): New routine.
+       (Has_Rep_Pragma): New routine.
+       * sem_ch13.adb (Duplicate_Clause): Restore original error messages.
+       * sem_eval.adb (Subtypes_Statically_Match): Get_Rep_Item_For_Entity
+       replaced by Get_Rep_Item.
+       * sem_prag.adb (Analyze_Pragma): Restore original error messages.
+       (Check_Duplicate_Pragma): Restore original error messages.
+
 2012-06-14  Ed Schonberg  <schonberg@adacore.com>
 
        * sem_util.adb (Is_Object_Reference): in Ada 2012, qualified
index eef6ef05cee6b64bc4e5777e9caf2447d4356163..d5fad3ecf548c4dd45dcf992f77231e63052484a 100644 (file)
 pragma Style_Checks (All_Checks);
 --  Turn off subprogram ordering, not used for this unit
 
-with Atree;    use Atree;
-with Nlists;   use Nlists;
-with Output;   use Output;
-with Sem_Aux;  use Sem_Aux;   -- wrong dependency ???
-with Sinfo;    use Sinfo;
-with Stand;    use Stand;
+with Atree;  use Atree;
+with Namet;  use Namet;
+with Nlists; use Nlists;
+with Output; use Output;
+with Sinfo;  use Sinfo;
+with Stand;  use Stand;
 
 package body Einfo is
 
@@ -5979,41 +5979,6 @@ package body Einfo is
       return Empty;
    end Get_Attribute_Definition_Clause;
 
-   ------------------
-   -- Get_Rep_Item --
-   ------------------
-
-   function Get_Rep_Item
-     (E   : Entity_Id;
-      Nam : Name_Id) return Node_Id
-   is
-      N     : Node_Id;
-      N_Nam : Name_Id := No_Name;
-
-   begin
-      N := First_Rep_Item (E);
-      while Present (N) loop
-         if Nkind (N) = N_Pragma then
-            N_Nam := Pragma_Name (N);
-         elsif Nkind (N) = N_Attribute_Definition_Clause then
-            N_Nam := Chars (N);
-         elsif Nkind (N) = N_Aspect_Specification then
-            N_Nam := Chars (Identifier (N));
-         end if;
-
-         if N_Nam = Nam
-           or else (Nam = Name_Priority
-                     and then N_Nam = Name_Interrupt_Priority)
-         then
-            return N;
-         end if;
-
-         Next_Rep_Item (N);
-      end loop;
-
-      return Empty;
-   end Get_Rep_Item;
-
    -------------------
    -- Get_Full_View --
    -------------------
@@ -6054,114 +6019,6 @@ package body Einfo is
       return Empty;
    end Get_Record_Representation_Clause;
 
-   -----------------------------
-   -- Get_Rep_Item_For_Entity --
-   -----------------------------
-
-   function Get_Rep_Item_For_Entity
-     (E   : Entity_Id;
-      Nam : Name_Id) return Node_Id
-   is
-      Par : constant Entity_Id := Nearest_Ancestor (E);
-      --  In case of a derived type or subtype, this node represents the parent
-      --  type of type E.
-
-      N   : Node_Id;
-
-   begin
-      N := First_Rep_Item (E);
-      while Present (N) loop
-         if Nkind (N) = N_Pragma
-           and then
-             (Pragma_Name (N) = Nam
-               or else (Nam = Name_Priority
-                         and then Pragma_Name (N) = Name_Interrupt_Priority))
-         then
-            --  Return N if the pragma doesn't appear in the Rep_Item chain of
-            --  the parent.
-
-            if No (Par) then
-               return N;
-
-            elsif not Present_In_Rep_Item (Par, N) then
-               return N;
-            end if;
-
-         elsif Nkind (N) = N_Attribute_Definition_Clause
-           and then Entity (N) = E
-           and then
-             (Chars (N) = Nam
-                or else (Nam = Name_Priority
-                          and then Chars (N) = Name_Interrupt_Priority))
-         then
-            return N;
-
-         elsif Nkind (N) = N_Aspect_Specification
-           and then Entity (N) = E
-           and then
-             (Chars (Identifier (N)) = Nam
-                or else (Nam = Name_Priority
-                          and then Chars (Identifier (N)) =
-                                     Name_Interrupt_Priority))
-         then
-            return N;
-         end if;
-
-         Next_Rep_Item (N);
-      end loop;
-
-      return Empty;
-   end Get_Rep_Item_For_Entity;
-
-   --------------------
-   -- Get_Rep_Pragma --
-   --------------------
-
-   function Get_Rep_Pragma (E : Entity_Id; Nam : Name_Id) return Node_Id is
-      N : Node_Id;
-
-   begin
-      N := First_Rep_Item (E);
-      while Present (N) loop
-         if Nkind (N) = N_Pragma
-           and then
-             (Pragma_Name (N) = Nam
-               or else (Nam = Name_Interrupt_Priority
-                         and then Pragma_Name (N) = Name_Priority))
-         then
-            return N;
-         end if;
-
-         Next_Rep_Item (N);
-      end loop;
-
-      return Empty;
-   end Get_Rep_Pragma;
-
-   -------------------------------
-   -- Get_Rep_Pragma_For_Entity --
-   -------------------------------
-
-   function Get_Rep_Pragma_For_Entity
-     (E : Entity_Id; Nam : Name_Id) return Node_Id
-   is
-      Par : constant Entity_Id := Nearest_Ancestor (E);
-      --  In case of a derived type or subtype, this node represents the parent
-      --  type of type E.
-
-      Prag : constant Node_Id := Get_Rep_Pragma (E, Nam);
-
-   begin
-      if No (Par) then
-         return Prag;
-
-      elsif not Present_In_Rep_Item (Par, Prag) then
-         return Prag;
-      end if;
-
-      return Empty;
-   end Get_Rep_Pragma_For_Entity;
-
    ------------------------
    -- Has_Attach_Handler --
    ------------------------
@@ -6247,35 +6104,6 @@ package body Einfo is
       return False;
    end Has_Interrupt_Handler;
 
-   ------------------
-   -- Has_Rep_Item --
-   ------------------
-
-   function Has_Rep_Item (E : Entity_Id; Nam : Name_Id) return Boolean is
-   begin
-      return Present (Get_Rep_Item (E, Nam));
-   end Has_Rep_Item;
-
-   --------------------
-   -- Has_Rep_Pragma --
-   --------------------
-
-   function Has_Rep_Pragma (E : Entity_Id; Nam : Name_Id) return Boolean is
-   begin
-      return Present (Get_Rep_Pragma (E, Nam));
-   end Has_Rep_Pragma;
-
-   -------------------------------
-   -- Has_Rep_Pragma_For_Entity --
-   -------------------------------
-
-   function Has_Rep_Pragma_For_Entity
-     (E : Entity_Id; Nam : Name_Id) return Boolean
-   is
-   begin
-      return Present (Get_Rep_Pragma_For_Entity (E, Nam));
-   end Has_Rep_Pragma_For_Entity;
-
    --------------------
    -- Has_Unmodified --
    --------------------
index c6c80ff93835afebde43e83295c5852bc0df0c72..0f8250ac7ab5bb097d9e3c66cf8a95aab8f863b0 100644 (file)
@@ -29,7 +29,6 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with Namet;  use Namet;
 with Snames; use Snames;
 with Types;  use Types;
 with Uintp;  use Uintp;
@@ -7189,67 +7188,11 @@ package Einfo is
    --  value returned is the N_Attribute_Definition_Clause node, otherwise
    --  Empty is returned.
 
-   --  What is difference between following two, and why are they named
-   --  the way they are ???
-
-   function Get_Rep_Item
-     (E   : Entity_Id;
-      Nam : Name_Id) return Node_Id;
-   --  Searches the Rep_Item chain for a given entity E, for the first
-   --  occurrence of a rep item (pragma, attribute definition clause, or aspect
-   --  specification) whose name matches the given name. If one is found, it is
-   --  returned, otherwise Empty is returned. A special case is that when Nam
-   --  is Name_Priority, the call will also find Interrupt_Priority.
-
-   function Get_Rep_Item_For_Entity
-     (E   : Entity_Id;
-      Nam : Name_Id) return Node_Id;
-   --  Searches the Rep_Item chain for a given entity E, for an instance of a
-   --  rep item (pragma, attribute definition clause, or aspect specification)
-   --  whose name matches the given name. If one is found, it is returned,
-   --  otherwise Empty is returned. This routine only returns items whose
-   --  entity matches E (it does not return items from the parent chain). A
-   --  special case is that when Nam is Name_Priority, the call will also find
-   --  Interrupt_Priority.
-
    function Get_Record_Representation_Clause (E : Entity_Id) return Node_Id;
    --  Searches the Rep_Item chain for a given entity E, for a record
    --  representation clause, and if found, returns it. Returns Empty
    --  if no such clause is found.
 
-   --  I still don't get it, if the first one returns stuff from the parent
-   --  it should say so, and it doesn't, and the names make no sense ???
-
-   function Get_Rep_Pragma (E : Entity_Id; Nam : Name_Id) return Node_Id;
-   --  Searches the Rep_Item chain for the given entity E, for an instance
-   --  a representation pragma with the given name Nam. If found then the
-   --  value returned is the N_Pragma node, otherwise Empty is returned. A
-   --  special case is that when Nam is Name_Priority, the call will also find
-   --  Interrupt_Priority.
-
-   function Get_Rep_Pragma_For_Entity
-     (E : Entity_Id; Nam : Name_Id) return Node_Id;
-   --  Same as Get_Rep_Pragma except that this routine returns a pragma that
-   --  doesn't appear in the Rep Item chain of the parent of E (if any).
-
-   function Has_Rep_Item (E : Entity_Id; Nam : Name_Id) return Boolean;
-   --  Searches the Rep_Item chain for the given entity E, for an instance
-   --  of rep item with the given name Nam. If found then True is returned,
-   --  otherwise False indicates that no matching entry was found.
-
-   --  Again, the following two have bizarre names, and unclear specs ???
-
-   function Has_Rep_Pragma (E : Entity_Id; Nam : Name_Id) return Boolean;
-   --  Searches the Rep_Item chain for the given entity E, for an instance
-   --  of representation pragma with the given name Nam. If found then True
-   --  is returned, otherwise False indicates that no matching entry was found.
-
-   function Has_Rep_Pragma_For_Entity
-     (E : Entity_Id; Nam : Name_Id) return Boolean;
-   --  Same as Has_Rep_Pragma except that this routine doesn't return True if
-   --  the representation pragma is also present in the Rep Item chain of the
-   --  parent of E (if any).
-
    function Present_In_Rep_Item (E : Entity_Id; N : Node_Id) return Boolean;
    --  Return True if N is present in the Rep_Item chain for a given entity E
 
index 2a533c93c3ef8d009a58dbf53bf8abd753f2a5f1..3f622beeac1400e5fd0220008c4deb92e8870082 100644 (file)
@@ -11604,7 +11604,7 @@ package body Exp_Ch9 is
 
       --  Add the _Task_Info component if a Task_Info pragma is present
 
-      if Has_Rep_Pragma_For_Entity (TaskId, Name_Task_Info) then
+      if Has_Rep_Pragma (TaskId, Name_Task_Info, Check_Parents => False) then
          Append_To (Cdecls,
            Make_Component_Declaration (Loc,
              Defining_Identifier =>
@@ -11619,7 +11619,8 @@ package body Exp_Ch9 is
              Expression => New_Copy (
                Expression (First (
                  Pragma_Argument_Associations (
-                   Get_Rep_Pragma_For_Entity (TaskId, Name_Task_Info)))))));
+                   Get_Rep_Pragma
+                     (TaskId, Name_Task_Info, Check_Parents => False)))))));
       end if;
 
       --  Add the _CPU component with no expression
@@ -13337,11 +13338,11 @@ package body Exp_Ch9 is
              Attribute_Name => Name_Unchecked_Access));
 
          --  Priority parameter. Set to Unspecified_Priority unless there is a
-         --  priority clause, in which case we take the value from the
-         --  pragma/attribute definition clause, or there is an interrupt
-         --  clause and no priority clause, and we set the ceiling to
-         --  Interrupt_Priority'Last, an implementation defined value,
-         --  see D.3(10).
+         --  Priority rep item, in which case we take the value from the pragma
+         --  or attribute definition clause, or there is an Interrupt_Priority
+         --  rep item and no Priority rep item, and we set the ceiling to
+         --  Interrupt_Priority'Last, an implementation-defined value, see
+         --  D.3(10).
 
          if Has_Rep_Item (Ptyp, Name_Priority) then
             declare
@@ -13724,7 +13725,7 @@ package body Exp_Ch9 is
       --  Task_Info parameter. Set to Unspecified_Task_Info unless there is a
       --  Task_Info pragma, in which case we take the value from the pragma.
 
-      if Has_Rep_Pragma_For_Entity (Ttyp, Name_Task_Info) then
+      if Has_Rep_Pragma (Ttyp, Name_Task_Info, Check_Parents => False) then
          Append_To (Args,
            Make_Selected_Component (Loc,
              Prefix        => Make_Identifier (Loc, Name_uInit),
@@ -13907,7 +13908,7 @@ package body Exp_Ch9 is
       --  init call unless there is a Task_Name pragma, in which case we take
       --  the value from the pragma.
 
-      if Has_Rep_Pragma_For_Entity (Ttyp, Name_Task_Name) then
+      if Has_Rep_Pragma (Ttyp, Name_Task_Name, Check_Parents => False) then
          --  Copy expression in full, because it may be dynamic and have
          --  side effects.
 
@@ -13916,7 +13917,8 @@ package body Exp_Ch9 is
              (Expression
                (First
                  (Pragma_Argument_Associations
-                   (Get_Rep_Pragma_For_Entity (Ttyp, Name_Task_Name))))));
+                   (Get_Rep_Pragma
+                     (Ttyp, Name_Task_Name, Check_Parents => False))))));
 
       else
          Append_To (Args, Make_Identifier (Loc, Name_uTask_Name));
index 6617cc0066ddf8d539f4bd65e3e9e1f7e440335f..dcf6b52650578fc87c7520e81e41e9f7486c47ad 100644 (file)
@@ -44,6 +44,7 @@ with Restrict; use Restrict;
 with Rident;   use Rident;
 with Rtsfind;  use Rtsfind;
 with Sem;      use Sem;
+with Sem_Aux;  use Sem_Aux;
 with Sem_Eval; use Sem_Eval;
 with Sem_Res;  use Sem_Res;
 with Sem_Type; use Sem_Type;
index 6499249d6d63eef4285c8aae45d31d5b8d492a6d..d08fa452d6452d4dd828b6d255b76c681f0532ee 100644 (file)
@@ -32,7 +32,6 @@
 
 with Atree;  use Atree;
 with Einfo;  use Einfo;
-with Namet;  use Namet;
 with Sinfo;  use Sinfo;
 with Snames; use Snames;
 with Stand;  use Stand;
@@ -418,6 +417,155 @@ package body Sem_Aux is
       return Empty;
    end First_Tag_Component;
 
+   ------------------
+   -- Get_Rep_Item --
+   ------------------
+
+   function Get_Rep_Item
+     (E             : Entity_Id;
+      Nam           : Name_Id;
+      Check_Parents : Boolean := True) return Node_Id
+   is
+      N : Node_Id;
+
+   begin
+      N := First_Rep_Item (E);
+      while Present (N) loop
+         if Nkind (N) = N_Pragma
+           and then
+             (Pragma_Name (N) = Nam
+               or else (Nam = Name_Priority
+                         and then Pragma_Name (N) = Name_Interrupt_Priority))
+         then
+            if Check_Parents then
+               return N;
+
+            --  If Check_Parents is False, return N if the pragma doesn't
+            --  appear in the Rep_Item chain of the parent.
+
+            else
+               declare
+                  Par : constant Entity_Id := Nearest_Ancestor (E);
+                  --  This node represents the parent type of type E (if any)
+
+               begin
+                  if No (Par) then
+                     return N;
+
+                  elsif not Present_In_Rep_Item (Par, N) then
+                     return N;
+                  end if;
+               end;
+            end if;
+
+         elsif Nkind (N) = N_Attribute_Definition_Clause
+           and then
+             (Chars (N) = Nam
+                or else (Nam = Name_Priority
+                          and then Chars (N) = Name_Interrupt_Priority))
+         then
+            if Check_Parents then
+               return N;
+
+            elsif Entity (N) = E then
+               return N;
+            end if;
+
+         elsif Nkind (N) = N_Aspect_Specification
+           and then
+             (Chars (Identifier (N)) = Nam
+                or else (Nam = Name_Priority
+                          and then Chars (Identifier (N)) =
+                                     Name_Interrupt_Priority))
+         then
+            if Check_Parents then
+               return N;
+
+            elsif Entity (N) = E then
+               return N;
+            end if;
+         end if;
+
+         Next_Rep_Item (N);
+      end loop;
+
+      return Empty;
+   end Get_Rep_Item;
+
+   --------------------
+   -- Get_Rep_Pragma --
+   --------------------
+
+   function Get_Rep_Pragma
+     (E             : Entity_Id;
+      Nam           : Name_Id;
+      Check_Parents : Boolean := True) return Node_Id
+   is
+      N : Node_Id;
+
+   begin
+      N := First_Rep_Item (E);
+      while Present (N) loop
+         if Nkind (N) = N_Pragma
+           and then
+             (Pragma_Name (N) = Nam
+               or else (Nam = Name_Interrupt_Priority
+                         and then Pragma_Name (N) = Name_Priority))
+         then
+            if Check_Parents then
+               return N;
+
+            --  If Check_Parents is False, return N if the pragma doesn't
+            --  appear in the Rep_Item chain of the parent.
+
+            else
+               declare
+                  Par : constant Entity_Id := Nearest_Ancestor (E);
+                  --  This node represents the parent type of type E (if any)
+
+               begin
+                  if No (Par) then
+                     return N;
+
+                  elsif not Present_In_Rep_Item (Par, N) then
+                     return N;
+                  end if;
+               end;
+            end if;
+         end if;
+
+         Next_Rep_Item (N);
+      end loop;
+
+      return Empty;
+   end Get_Rep_Pragma;
+
+   ------------------
+   -- Has_Rep_Item --
+   ------------------
+
+   function Has_Rep_Item
+     (E             : Entity_Id;
+      Nam           : Name_Id;
+      Check_Parents : Boolean := True) return Boolean
+   is
+   begin
+      return Present (Get_Rep_Item (E, Nam, Check_Parents));
+   end Has_Rep_Item;
+
+   --------------------
+   -- Has_Rep_Pragma --
+   --------------------
+
+   function Has_Rep_Pragma
+     (E             : Entity_Id;
+      Nam           : Name_Id;
+      Check_Parents : Boolean := True) return Boolean
+   is
+   begin
+      return Present (Get_Rep_Pragma (E, Nam, Check_Parents));
+   end Has_Rep_Pragma;
+
    -------------------------------
    -- Initialization_Suppressed --
    -------------------------------
@@ -832,7 +980,7 @@ package body Sem_Aux is
    ----------------------
 
    function Nearest_Ancestor (Typ : Entity_Id) return Entity_Id is
-      D : constant Node_Id := Original_Node (Declaration_Node (Typ));
+      D : constant Node_Id := Declaration_Node (Typ);
 
    begin
       --  If we have a subtype declaration, get the ancestor subtype
index 9fd9c659a097a2ad075b3212e1c06776371ee57b..85c70f9137443cea1d30eba7727a4aabc63b86b4 100644 (file)
@@ -39,6 +39,7 @@
 --  require more than minimal semantic knowledge.
 
 with Alloc; use Alloc;
+with Namet; use Namet;
 with Table;
 with Types; use Types;
 
@@ -155,6 +156,52 @@ package Sem_Aux is
    --  Typ must be a tagged record type. This function returns the Entity for
    --  the first _Tag field in the record type.
 
+   function Get_Rep_Item
+     (E             : Entity_Id;
+      Nam           : Name_Id;
+      Check_Parents : Boolean := True) return Node_Id;
+   --  Searches the Rep_Item chain for a given entity E, for an instance of a
+   --  rep item (pragma, attribute definition clause, or aspect specification)
+   --  whose name matches the given name Nam. If Check_Parents is False then it
+   --  only returns rep item that has been directly specified to E (and not
+   --  inherited from its parents, if any). If one is found, it is returned,
+   --  otherwise Empty is returned. A special case is that when Nam is
+   --  Name_Priority, the call will also find Interrupt_Priority.
+
+   function Get_Rep_Pragma
+     (E             : Entity_Id;
+      Nam           : Name_Id;
+      Check_Parents : Boolean := True) return Node_Id;
+   --  Searches the Rep_Item chain for a given entity E, for an instance of a
+   --  representation pragma whose name matches the given name Nam. If
+   --  Check_Parents is False then it only returns representation pragma that
+   --  has been directly specified to E (and not inherited from its parents, if
+   --  any). If one is found, it is returned, otherwise Empty is returned. A
+   --  special case is that when Nam is Name_Priority, the call will also find
+   --  Interrupt_Priority.
+
+   function Has_Rep_Item
+     (E             : Entity_Id;
+      Nam           : Name_Id;
+      Check_Parents : Boolean := True) return Boolean;
+   --  Searches the Rep_Item chain for the given entity E, for an instance of a
+   --  rep item (pragma, attribute definition clause, or aspect specification)
+   --  with the given name Nam. If Check_Parents is False then it only returns
+   --  rep item that has been directly specified to E (and not inherited from
+   --  its parents, if any). If found then True is returned, otherwise False
+   --  indicates that no matching entry was found.
+
+   function Has_Rep_Pragma
+     (E             : Entity_Id;
+      Nam           : Name_Id;
+      Check_Parents : Boolean := True) return Boolean;
+   --  Searches the Rep_Item chain for the given entity E, for an instance of a
+   --  representation pragma with the given name Nam. If Check_Parents is False
+   --  then it only returns representation pragma that has been directly
+   --  specified to E (and not inherited from its parents, if any). If found
+   --  then True is returned, otherwise False indicates that no matching entry
+   --  was found.
+
    function In_Generic_Body (Id : Entity_Id) return Boolean;
    --  Determine whether entity Id appears inside a generic body
 
index b4bbb2de9fbf73d49158b625529c786337d4e91c..63b29c10c7dc08d9b98183fd9e4ed2a6431b85d6 100644 (file)
@@ -2058,24 +2058,13 @@ package body Sem_Ch13 is
          --  previously given pragma or aspect specification for the same
          --  aspect.
 
-         A := Get_Rep_Item_For_Entity (U_Ent, Chars (N));
+         A := Get_Rep_Item (U_Ent, Chars (N), Check_Parents => False);
 
          if Present (A) then
             Error_Msg_Name_1 := Chars (N);
             Error_Msg_Sloc := Sloc (A);
 
-            if Nkind (A) = N_Aspect_Specification
-              or else From_Aspect_Specification (A)
-            then
-               Error_Msg_NE ("aspect% for & previously given#", N, U_Ent);
-
-            elsif Nkind (A) = N_Pragma then
-               Error_Msg_NE ("clause% for & duplicates pragma#", N, U_Ent);
-
-            else
-               Error_Msg_NE ("clause% for & duplicates clause#", N, U_Ent);
-            end if;
-
+            Error_Msg_NE ("aspect% for & previously given#", N, U_Ent);
             return True;
          end if;
 
index 2393f6fac9eb2a074b19c7f4f61706f4a5ce605c..cecdbef46ab78e623ff4d78417a77be5027787cb 100644 (file)
@@ -4685,8 +4685,12 @@ package body Sem_Eval is
             return False;
 
          else
-            Pred1 := Get_Rep_Item_For_Entity (T1, Name_Static_Predicate);
-            Pred2 := Get_Rep_Item_For_Entity (T2, Name_Static_Predicate);
+            Pred1 :=
+              Get_Rep_Item
+                (T1, Name_Static_Predicate, Check_Parents => False);
+            Pred2 :=
+              Get_Rep_Item
+                (T2, Name_Static_Predicate, Check_Parents => False);
 
             --  Subtypes statically match if the predicate comes from the
             --  same declaration, which can only happen if one is a subtype
index 72fe18e52a22b80023b5df54177e7016f1e571c6..35e1f6404eed851f6a23cc2c8da4d2239f894bc3 100644 (file)
@@ -1613,7 +1613,7 @@ package body Sem_Prag is
          --  previously given aspect specification or attribute definition
          --  clause for the same pragma.
 
-         P := Get_Rep_Item_For_Entity (E, Pragma_Name (N));
+         P := Get_Rep_Item (E, Pragma_Name (N), Check_Parents => False);
 
          if Present (P) then
             Error_Msg_Name_1 := Pragma_Name (N);
@@ -1630,12 +1630,8 @@ package body Sem_Prag is
               or else From_Aspect_Specification (P)
             then
                Error_Msg_NE ("aspect% for & previously given#", N, Id);
-
-            elsif Nkind (P) = N_Pragma then
-               Error_Msg_NE ("pragma% for & duplicates pragma#", N, Id);
-
             else
-               Error_Msg_NE ("pragma% for & duplicates clause#", N, Id);
+               Error_Msg_NE ("pragma% for & duplicates pragma#", N, Id);
             end if;
 
             raise Pragma_Exit;
@@ -8024,7 +8020,6 @@ package body Sem_Prag is
             --  Item chain of Ent.
 
             Check_Duplicate_Pragma (Ent);
-
             Record_Rep_Item (Ent, N);
          end CPU;
 
@@ -8317,7 +8312,6 @@ package body Sem_Prag is
                --  Item chain of Ent.
 
                Check_Duplicate_Pragma (Ent);
-
                Record_Rep_Item (Ent, N);
 
             --  Anything else is incorrect
@@ -10284,7 +10278,6 @@ package body Sem_Prag is
                --  Item chain of Ent.
 
                Check_Duplicate_Pragma (Ent);
-
                Record_Rep_Item (Ent, N);
             end if;
          end Interrupt_Priority;
@@ -12410,7 +12403,6 @@ package body Sem_Prag is
             --  Item chain of Ent.
 
             Check_Duplicate_Pragma (Ent);
-
             Record_Rep_Item (Ent, N);
          end Priority;
 
@@ -13928,7 +13920,12 @@ package body Sem_Prag is
             --  Check duplicate pragma before we chain the pragma in the Rep
             --  Item chain of Ent.
 
-            Check_Duplicate_Pragma (Ent);
+            if Has_Rep_Pragma
+                 (Ent, Name_Task_Info, Check_Parents => False)
+            then
+               Error_Pragma ("duplicate pragma% not allowed");
+            end if;
+
             Record_Rep_Item (Ent, N);
          end Task_Info;
 
@@ -13965,7 +13962,12 @@ package body Sem_Prag is
             --  Check duplicate pragma before we chain the pragma in the Rep
             --  Item chain of Ent.
 
-            Check_Duplicate_Pragma (Ent);
+            if Has_Rep_Pragma
+                 (Ent, Name_Task_Name, Check_Parents => False)
+            then
+               Error_Pragma ("duplicate pragma% not allowed");
+            end if;
+
             Record_Rep_Item (Ent, N);
          end Task_Name;