view gcc/testsuite/gnat.dg/ai12_0086_example.adb @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
line wrap: on
line source

--  { dg-do compile }
--  { dg-options "-gnatX" }

procedure AI12_0086_Example is
    type Enum is (Aa, Bb, Cc, Dd, Ee, Ff, Gg, Hh, Ii, Jj, Kk, Ll, MM,
                  Nn, Oo, Pp, Qq, Rr, Ss, Tt, Uu, Vv, Ww, Xx, Yy, Zz);
    subtype S is Enum range Dd .. Hh;

    type Rec (D : Enum) is record
      case D is
        when S => Foo, Bar : Integer;
        when others => null;
      end case;
    end record;

    function Make (D : S) return Rec is
    begin
      return (D => D, Foo => 123, Bar => 456); -- legal
    end;
begin
    if Make (Ff).Bar /= 456 then
       raise Program_Error;
    end if;
end AI12_0086_Example;