public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Take full view of private type
@ 2022-05-17  8:27 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-17  8:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: Etienne Servais

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

This allows to resolve the following:

      type Rec (<>) is private;
      type Arr (<>) is private;
   private
      type Arr is array (Positive range <>) of Natural;
      type Rec (L : Natural) is record
         F1 : Integer;
         F2 : Arr (1 .. L);
      end record;

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

gcc/ada/

	* sem_ch3.adb (Analyze_Subtype_Declaration): Use underlying type
	of Indic_Typ.
	(Constrain_Array): Ditto for T.

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

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -5978,7 +5978,7 @@ package body Sem_Ch3 is
       if Nkind (Subtype_Indication (N)) = N_Subtype_Indication then
          declare
             Indic_Typ    : constant Entity_Id :=
-                             Etype (Subtype_Mark (Subtype_Indication (N)));
+              Underlying_Type (Etype (Subtype_Mark (Subtype_Indication (N))));
             Subt_Index   : Node_Id;
             Target_Index : Node_Id;
 
@@ -13595,6 +13595,8 @@ package body Sem_Ch3 is
          T := Designated_Type (T);
       end if;
 
+      T := Underlying_Type (T);
+
       --  If an index constraint follows a subtype mark in a subtype indication
       --  then the type or subtype denoted by the subtype mark must not already
       --  impose an index constraint. The subtype mark must denote either an



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

only message in thread, other threads:[~2022-05-17  8:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17  8:27 [Ada] Take full view of private type 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).