PR target/84336
[official-gcc.git] / gcc / testsuite / gnat.dg / prot_def.adb
blobd56195ea483e93f2f1dbe1cc5e0a75d873494781
1 -- { dg-do run }
2 procedure Prot_Def is
4 protected Prot is
5 procedure Inc;
6 function Get return Integer;
7 private
8 Data : Integer := 0;
9 end Prot;
11 protected body Prot is
12 procedure Inc is
13 begin
14 Data := Data + 1;
15 end Inc;
16 function Get return Integer is
17 begin
18 return Data;
19 end Get;
20 end Prot;
22 generic
23 with procedure Inc is Prot.Inc;
24 with function Get return Integer is Prot.Get;
25 package Gen is
26 function Add2_Get return Integer;
27 end Gen;
29 package body Gen is
30 function Add2_Get return Integer is
31 begin
32 Inc;
33 Inc;
34 return Get;
35 end Add2_Get;
36 end Gen;
38 package Inst is new Gen;
40 begin
41 if Inst.Add2_Get /= 2 then
42 raise Constraint_Error;
43 end if;
44 end Prot_Def;