The counter variable in routine Formal_Is_Used_Once is initialized with
0, then is possibly incremented to 1, and when incremented again, the
traversal is abandoned. This second increment can only make the counter
equal 2; there is no need to explicitly re-assign it.

Code cleanup only; semantics is unaffected.

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

gcc/ada/

        * inline.adb (Formal_Is_Used_Once): Refine type of the counter
        variable; remove redundant assignment.
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb
--- a/gcc/ada/inline.adb
+++ b/gcc/ada/inline.adb
@@ -2827,7 +2827,7 @@ package body Inline is
       -------------------------
 
       function Formal_Is_Used_Once (Formal : Entity_Id) return Boolean is
-         Use_Counter : Int := 0;
+         Use_Counter : Nat := 0;
 
          function Count_Uses (N : Node_Id) return Traverse_Result;
          --  Traverse the tree and count the uses of the formal parameter.
@@ -2856,13 +2856,10 @@ package body Inline is
             then
                Use_Counter := Use_Counter + 1;
 
-               if Use_Counter > 1 then
-
-                  --  Denote more than one use and abandon the traversal
+               --  If this is a second use then abandon the traversal
 
-                  Use_Counter := 2;
+               if Use_Counter > 1 then
                   return Abandon;
-
                end if;
             end if;
 


Reply via email to