summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/discr17.adb
blob: d7b480c07d940cde43b504464a0a8d87f982c8c7 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
-- { dg-do compile }
-- { dg-options "-gnatws" }

procedure Discr17 is

  F1_Poe : Integer := 18;

  function F1 return Integer is
  begin
    F1_Poe := F1_Poe - 1;
    return F1_Poe;
 end F1;

  generic
    type T is limited private;
    with function Is_Ok (X : T) return Boolean;
  procedure Check;

  procedure Check is
  begin

    declare
      type Poe is new T;
      X : Poe;
      Y : Poe;
    begin
      null;
    end;

    declare
      type Poe is new T;
      type Arr is array (1 .. 2) of Poe;
      X : Arr;
      B : Boolean := Is_Ok (T (X (1)));
    begin
      null;
    end;

 end;

  protected type Poe (D3 : Integer := F1) is
    entry E (D3 .. F1);    -- F1 evaluated
    function Is_Ok return Boolean;
  end Poe;

  protected body Poe is
    entry E (for I in D3 .. F1) when True is
    begin
      null;
    end E;
    function Is_Ok return Boolean is
    begin
      return False;
    end Is_Ok;
  end Poe;

  function Is_Ok (C : Poe) return Boolean is
  begin
    return C.Is_Ok;
  end Is_Ok;

  procedure Chk is new Check (Poe, Is_Ok);

begin
   Chk;
end;