strub: enable conditional support
[official-gcc.git] / gcc / testsuite / gnat.dg / strub_intf2.adb
blob7992b7344fb878ebba8132ed9aafcf885b43079b
1 -- { dg-do compile }
2 -- { dg-require-effective-target strub }
4 -- Check that strub mode mismatches between overrider and overridden
5 -- subprograms are reported even when the overriders for an
6 -- interface's subprograms are inherited from a type that is not a
7 -- descendent of the interface.
9 procedure Strub_Intf2 is
10 package Foo is
11 type A is tagged null record;
13 procedure P (I : Integer; X : A);
14 pragma Machine_Attribute (P, "strub", "at-calls"); -- { dg-error "requires the same .strub. mode" }
16 function F (X : access A) return Integer;
18 type TX is Interface;
20 procedure P (I : Integer; X : TX) is abstract;
22 function F (X : access TX) return Integer is abstract;
23 pragma Machine_Attribute (F, "strub", "at-calls");
25 type B is new A and TX with null record; -- { dg-error "requires the same .strub. mode" }
27 end Foo;
29 package body Foo is
30 procedure P (I : Integer; X : A) is
31 begin
32 null;
33 end;
35 function F (X : access A) return Integer is (0);
37 end Foo;
39 use Foo;
41 procedure Q (X : TX'Class) is
42 begin
43 P (-1, X);
44 end;
46 XB : aliased B;
47 I : Integer := 0;
48 XC : access TX'Class;
49 begin
50 Q (XB);
52 I := I + F (XB'Access);
54 XC := XB'Access;
55 I := I + F (XC);
56 end Strub_Intf2;