diff mbox series

[Ada] Refine type of a counter variable from Integer to Natural

Message ID 20210504095223.GA90544@adacore.com
State New
Headers show
Series [Ada] Refine type of a counter variable from Integer to Natural | expand

Commit Message

Pierre-Marie de Rodat May 4, 2021, 9:52 a.m. UTC
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.
diff mbox series

Patch

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.