Debian Codegraph @

gcc/testsuite/gnat.dg/opt59.adb

raw
1 -- { dg-do run }
2 -- { dg-options "-O" }
3
4 with Opt59_Pkg; use Opt59_Pkg;
5
6 procedure Opt59 is
7
8 type Enum is (Zero, One, Two);
9
10 function Has_True (V : Boolean_Vector) return Boolean is
11 begin
12 for I in V'Range loop
13 if V (I) then
14 return True;
15 end if;
16 end loop;
17 return False;
18 end;
19
20 Data1 : constant Boolean_Vector := Get_BV1;
21 Data2 : constant Boolean_Vector := Get_BV2;
22 Result : Boolean_Vector;
23
24 function F return Enum is
25 Res : Enum := Zero;
26 Set1 : constant Boolean := Has_True (Data1);
27 Set2 : constant Boolean := Has_True (Data2);
28 begin
29 if Set1 then
30 Res := Two;
31 elsif Set2 then
32 Res := One;
33 end if;
34 return Res;
35 end;
36
37 Val : constant Enum := F;
38
39 begin
40
41 for I in Result'Range loop
42 Result (I) := Data1 (I) or Data2 (I);
43 end loop;
44
45 if Val /= Zero then
46 Test (Val = Two);
47 end if;
48
49 end;