PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gnat.dg / derived_aggregate.adb
blob29dad78749354ba03f397a3c80bcd7433f6353da
1 -- { dg-do run }
2 -- { dg-options "-O2" }
4 procedure Derived_Aggregate is
5 type Int is range 1 .. 10;
6 type Str is array (Int range <>) of Character;
8 type Parent (D1, D2 : Int; B : Boolean) is
9 record
10 S : Str (D1 .. D2);
11 case B is
12 when False => C1 : Integer;
13 when True => C2 : Float;
14 end case;
15 end record;
17 for Parent'Alignment use 8;
19 type Derived (D : Int) is new Parent (D1 => D, D2 => D, B => False);
21 function Ident (I : Integer) return integer is
22 begin
23 return I;
24 end;
26 Y : Derived := (D => 7, S => "b", C1 => Ident (32));
28 begin
29 if Parent(Y).D1 /= 7 then
30 raise Program_Error;
31 end if;
32 end;