summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/return2.adb
blob: 65b7bf045acad023423321498b826de495e5a1ab (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
29
30
31
32
33
-- { dg-do compile }
-- { dg-options "-O" }

with Return2_Pkg; use Return2_Pkg;

package body Return2 is

  function Value_Internal (Image : String) return Result_Internal_T is
  begin
    return (Member => False);
  end;

  type Result_T is array (1 .. 2) of Result_Internal_T;

  function Value (Img : String) return T is
    My_F : constant String := F;
    Result : Result_T;
    Value : T;
  begin
    for I in Result'Range loop
      if G (My_F, I) /= "" then
        Result (I) := Value_Internal (G (My_F, I));
        if Result (I).Member then
          Value (Result (I).Data) := True;
        else
          raise Program_Error;
        end if;
      end if;
    end loop;
    return Value;
  end;

end Return2;