public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix inheritance of representation items defined as aspects
@ 2018-09-26 10:54 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2018-09-26 10:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: Thomas Quinot

[-- Attachment #1: Type: text/plain, Size: 743 bytes --]

When a representation item is defined by a pragma or attribute
definition clause, the entity it applies to is that of the Name of the
representation item. But when it is defined by an aspect definition, the
entity is directly denoted by the Entity attribute of the represenation
item. The circuitry that inherits representation items for derived types
or subtypes must account for these two possible cases.

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

2018-09-26  Thomas Quinot  <quinot@adacore.com>

gcc/ada/

	* sem_ch13.adb (Inherit_Aspects_At_Freeze_Point): For a
	representation item that is an N_Aspect_Definition, retrieve the
	entity it applies to using the Entity attribute.

gcc/testsuite/

	* gnat.dg/sso13.adb: New testcase.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2657 bytes --]

--- gcc/ada/sem_ch13.adb
+++ gcc/ada/sem_ch13.adb
@@ -11446,6 +11446,26 @@ package body Sem_Ch13 is
       --  specification node whose correponding pragma (if any) is present in
       --  the Rep Item chain of the entity it has been specified to.
 
+      function Rep_Item_Entity (Rep_Item : Node_Id) return Entity_Id;
+      --  Return the entity for which Rep_Item is specified
+
+      ---------------------
+      -- Rep_Item_Entity --
+      ---------------------
+
+      function Rep_Item_Entity (Rep_Item : Node_Id) return Entity_Id is
+      begin
+         if Nkind (Rep_Item) = N_Aspect_Specification then
+            return Entity (Rep_Item);
+
+         else
+            pragma Assert (Nkind_In (Rep_Item,
+                                     N_Pragma,
+                                     N_Attribute_Definition_Clause));
+            return Entity (Name (Rep_Item));
+         end if;
+      end Rep_Item_Entity;
+
       --------------------------------------------------
       -- Is_Pragma_Or_Corr_Pragma_Present_In_Rep_Item --
       --------------------------------------------------
@@ -11650,8 +11670,8 @@ package body Sem_Ch13 is
                  and then Has_Rep_Item (Typ, Name_Bit_Order)
                then
                   Set_Reverse_Bit_Order (Bas_Typ,
-                    Reverse_Bit_Order (Entity (Name
-                      (Get_Rep_Item (Typ, Name_Bit_Order)))));
+                    Reverse_Bit_Order (Rep_Item_Entity
+                      (Get_Rep_Item (Typ, Name_Bit_Order))));
                end if;
             end if;
 

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/sso13.adb
@@ -0,0 +1,24 @@
+--  { dg-do compile }
+
+with System;
+
+procedure SSO13 is
+   type Pulse_Buffer_Type is abstract tagged null record
+    with Bit_Order => System.High_Order_First,
+         Scalar_Storage_order =>System.High_order_First;  --  { dg-warning "scalar storage order specified but no component clause" }
+   type Pulse_Train_Type is abstract new Pulse_Buffer_Type with null record;
+   type WO_Pulse_Train_Type is new Pulse_Train_Type with null record;
+   type WO_Confirmation_Pulse_Train_Type is new WO_Pulse_Train_Type with record
+      null;
+   end record;
+
+   type Update_Dwell_Type is abstract tagged null record
+     with Bit_Order => System.High_Order_First,
+          Scalar_Storage_order =>System.High_order_First;  --  { dg-warning "scalar storage order specified but no component clause" }
+   type Confirmation_Dwell_Type is new Update_Dwell_Type with
+   record
+      Pulses : aliased WO_Pulse_Train_Type; -- (Location of Error #1)
+   end record;
+begin
+   null;
+end;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-09-26  9:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-26 10:54 [Ada] Fix inheritance of representation items defined as aspects Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).