aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/opt95.adb
blob: 2c72582b3f179cfc4335ebc263e7446939468e99 (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
34
35
36
37
38
39
40
-- { dg-do run }
-- { dg-options "-O2 -gnatp" }

procedure Opt95 is

  function Foo (J : Integer) return Integer;
  pragma Pure_Function (Foo);
  pragma Machine_Attribute (Foo, "noipa");

  function Foo (J : Integer) return Integer is
  begin
    if J /= 0 then
      raise Constraint_Error;
    end if;
    return 0;
  end;

  function Bar (A : access Integer; N : Integer) return Integer;
  pragma Machine_Attribute (Bar, "noipa");

  function Bar (A : access Integer; N : Integer) return Integer is
    Ret : Integer := 0;
    Ret2 : Integer := 0;
  begin
    if N /= 0 then
      Ret2 := Foo (N);
      Ret := A.all;
    end if;
    Ret := Ret + A.all;
    return Ret + Ret2;
  end;

  V : Integer;
  pragma Volatile (V);

begin
  V := Bar (null, 1);
exception
  when Constraint_Error => null;
end;