summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/trampoline2.adb
blob: 26b42722ac7fa36b262784a3825fcdfd533c73c4 (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
-- { dg-do run }
-- { dg-options "-gnatws" }

with System; use System;

procedure Trampoline2 is

  A : Integer;

  type FuncPtr is access function (I : Integer) return Integer;

  function F (I : Integer) return Integer is
  begin
    return A + I;
  end F;

  P : FuncPtr := F'Access;
  CA : System.Address := F'Code_Address;
  I : Integer;

begin
  if CA = System.Null_Address then
    raise Program_Error;
  end if;

  I := P(0);
end;