strub: enable conditional support
[official-gcc.git] / gcc / testsuite / gnat.dg / strub_disp.adb
blobf23d4675def381497267aa2ab9d93058789bffc9
1 -- { dg-do compile }
2 -- { dg-require-effective-target strub }
4 procedure Strub_Disp is
5 package Foo is
6 type A is tagged null record;
8 procedure P (I : Integer; X : A);
9 pragma Machine_Attribute (P, "strub", "at-calls");
11 function F (X : access A) return Integer;
13 type B is new A with null record;
15 overriding
16 procedure P (I : Integer; X : B); -- { dg-error "requires the same .strub. mode" }
18 overriding
19 function F (X : access B) return Integer;
20 pragma Machine_Attribute (F, "strub", "at-calls"); -- { dg-error "requires the same .strub. mode" }
22 end Foo;
24 package body Foo is
25 procedure P (I : Integer; X : A) is
26 begin
27 null;
28 end;
30 function F (X : access A) return Integer is (0);
32 overriding
33 procedure P (I : Integer; X : B) is
34 begin
35 P (I, A (X));
36 end;
38 overriding
39 function F (X : access B) return Integer is (1);
40 end Foo;
42 use Foo;
44 procedure Q (X : A'Class) is
45 begin
46 P (-1, X);
47 end;
49 XA : aliased A;
50 XB : aliased B;
51 I : Integer := 0;
52 XC : access A'Class;
53 begin
54 Q (XA);
55 Q (XB);
57 I := I + F (XA'Access);
58 I := I + F (XB'Access);
60 XC := XA'Access;
61 I := I + F (XC);
63 XC := XB'Access;
64 I := I + F (XC);
65 end Strub_Disp;