PR target/84336
[official-gcc.git] / gcc / testsuite / gnat.dg / opt32.adb
blob93f31c2ca5294c9f6b8d74a9b56f8627fb1034b4
1 -- { dg-do compile }
2 -- { dg-options "-O2" }
4 with Ada.Containers; use Ada.Containers;
5 with Ada.Containers.Vectors;
7 function Opt32 return Natural is
9 package My_Vectors
10 is new Vectors (Index_Type => Natural, Element_Type => Integer);
11 use My_Vectors;
13 V : Vector;
15 function Sign_Changes return Natural is
16 Cur : Cursor := To_Cursor (V, 0);
17 R : Natural := 0;
18 Negative : Boolean;
19 begin
20 Negative := Element (Cur) < 0;
22 loop
23 Cur := Next (Cur);
24 exit when R > 100;
26 if (Element (Cur) < 0) /= Negative then
27 Negative := not Negative;
28 R := R + 1;
29 end if;
30 end loop;
32 return R;
33 end;
35 begin
36 return Sign_Changes;
37 end;