public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Refine type of Get_Homonym_Number result
@ 2019-09-18  8:40 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2019-09-18  8:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

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

Routine Get_Homonym_Number always returns a positive number. This is
explained in its comment and is evident from its body. No test attached,
because semantics is unaffected.

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

2019-09-18  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* exp_dbug.ads, exp_dbug.adb (Get_Homonym_Number): Refine type
	from Nat to Pos.
	* sem_util.adb (Add_Homonym_Suffix): Refine type of a local
	variable.

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

--- gcc/ada/exp_dbug.adb
+++ gcc/ada/exp_dbug.adb
@@ -1058,9 +1058,9 @@ package body Exp_Dbug is
    -- Get_Homonym_Number --
    ------------------------
 
-   function Get_Homonym_Number (E : Entity_Id) return Nat is
+   function Get_Homonym_Number (E : Entity_Id) return Pos is
       H  : Entity_Id := Homonym (E);
-      Nr : Nat := 1;
+      Nr : Pos := 1;
 
    begin
       while Present (H) loop

--- gcc/ada/exp_dbug.ads
+++ gcc/ada/exp_dbug.ads
@@ -460,7 +460,7 @@ package Exp_Dbug is
    -- Subprograms for Handling Qualification --
    --------------------------------------------
 
-   function Get_Homonym_Number (E : Entity_Id) return Nat;
+   function Get_Homonym_Number (E : Entity_Id) return Pos;
    --  Return the homonym number for E, which is its position in the homonym
    --  chain starting at 1. This is exported for use in GNATprove.
 

--- gcc/ada/sem_util.adb
+++ gcc/ada/sem_util.adb
@@ -26183,7 +26183,7 @@ package body Sem_Util is
 
          if Has_Homonym (U) then
             declare
-               N : constant Nat := Get_Homonym_Number (U);
+               N : constant Pos := Get_Homonym_Number (U);
                S : constant String := N'Img;
             begin
                if N > 1 then


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

only message in thread, other threads:[~2019-09-18  8:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18  8:40 [Ada] Refine type of Get_Homonym_Number result 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).