public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Refine type of a counter variable from Integer to Natural
@ 2021-05-04  9:52 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-05-04  9:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

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

A List_Name_Count variable is initialized with zero, then incremented
and decremented in a stack-like manner, so it should never become
negative.

This gives us extra confidence, but otherwise the behaviour is not
affected.

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

gcc/ada/

	* pprint.adb (List_Name_Count): Change type from Integer to
	Natural.

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

diff --git a/gcc/ada/pprint.adb b/gcc/ada/pprint.adb
--- a/gcc/ada/pprint.adb
+++ b/gcc/ada/pprint.adb
@@ -36,7 +36,7 @@ with Uintp;   use Uintp;
 
 package body Pprint is
 
-   List_Name_Count : Integer := 0;
+   List_Name_Count : Natural := 0;
    --  Counter used to prevent infinite recursion while computing name of
    --  complex expressions.
 



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

only message in thread, other threads:[~2021-05-04  9:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04  9:52 [Ada] Refine type of a counter variable from Integer to Natural 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).