public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Refine type from Nat to Pos in Make_Index
@ 2020-10-15  9:40 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-10-15  9:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

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

Refine types to make the code easier to understand. Semantics is not
affected; all the callers have been already respecting the more
restrictive type of parameter anyway.

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

gcc/ada/

	* sem_ch3.ads, sem_ch3.adb (Make_Index): Refined type of
	parameter.
	(Constrain_Index): Likewise.
	(Array_Type_Declaration): Refine type of a local counter
	variable; remove a trivially useless initialization.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2047 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
@@ -440,7 +440,7 @@ package body Sem_Ch3 is
       Related_Nod  : Node_Id;
       Related_Id   : Entity_Id;
       Suffix       : Character;
-      Suffix_Index : Nat);
+      Suffix_Index : Pos);
    --  Process an index constraint S in a constrained array declaration. The
    --  constraint can be a subtype name, or a range with or without an explicit
    --  subtype mark. The index is the corresponding index of the unconstrained
@@ -5987,9 +5987,9 @@ package body Sem_Ch3 is
       Element_Type  : Entity_Id;
       Implicit_Base : Entity_Id;
       Index         : Node_Id;
-      Nb_Index      : Nat;
+      Nb_Index      : Pos;
       Priv          : Entity_Id;
-      Related_Id    : Entity_Id := Empty;
+      Related_Id    : Entity_Id;
 
    begin
       if Nkind (Def) = N_Constrained_Array_Definition then
@@ -14100,7 +14100,7 @@ package body Sem_Ch3 is
       Related_Nod  : Node_Id;
       Related_Id   : Entity_Id;
       Suffix       : Character;
-      Suffix_Index : Nat)
+      Suffix_Index : Pos)
    is
       Def_Id : Entity_Id;
       R      : Node_Id := Empty;
@@ -19120,7 +19120,7 @@ package body Sem_Ch3 is
      (N            : Node_Id;
       Related_Nod  : Node_Id;
       Related_Id   : Entity_Id := Empty;
-      Suffix_Index : Nat       := 1)
+      Suffix_Index : Pos       := 1)
    is
       R      : Node_Id;
       T      : Entity_Id;


diff --git a/gcc/ada/sem_ch3.ads b/gcc/ada/sem_ch3.ads
--- a/gcc/ada/sem_ch3.ads
+++ b/gcc/ada/sem_ch3.ads
@@ -195,7 +195,7 @@ package Sem_Ch3 is
      (N            : Node_Id;
       Related_Nod  : Node_Id;
       Related_Id   : Entity_Id := Empty;
-      Suffix_Index : Nat       := 1);
+      Suffix_Index : Pos       := 1);
    --  Process an index that is given in an array declaration, an entry
    --  family declaration or a loop iteration. The index is given by an index
    --  declaration (a 'box'), or by a discrete range. The later can be the name



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

only message in thread, other threads:[~2020-10-15  9:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-15  9:40 [Ada] Refine type from Nat to Pos in Make_Index 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).