aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/default_variants.adb
blob: 2a8257e4aebebfc12ff95d65e3fba5c66a5710f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--  { dg-do compile }

procedure Default_Variants is

   type Variant_Kind is (A, B);

   function Get_Default_Value (Kind : in Variant_Kind) return Natural is (10);

   type Variant_Type (Kind : Variant_Kind := A) is
      record
         Common : Natural := Get_Default_Value (Kind);
         case Kind is
            when A =>
               A_Value : Integer := Integer'First;
            when B =>
               B_Value : Natural := Natural'First;
         end case;
      end record;

   type Containing_Type is tagged
      record
         Variant_Data : Variant_Type :=
               (Kind => B, Common => <>, B_Value => 1);
      end record;

begin
    null;
end Default_Variants;