Debian Codegraph @

gcc/testsuite/gnat.dg/strub_ind2.adb

raw
1 -- { dg-do compile }
2 -- { dg-options "-fstrub=strict" }
3 -- { dg-require-effective-target strub }
4
5 -- This is essentially the same test as strub_attr.adb,
6 -- but with an explicit conversion.
7
8 package body Strub_Ind2 is
9 E : exception;
10
11 function G return Integer;
12 pragma Machine_Attribute (G, "strub", "callable");
13
14 procedure P (X : Integer) is
15 begin
16 raise E;
17 end;
18
19 function G return Integer is (FP (X));
20
21 type GT is access function return Integer;
22 pragma Machine_Attribute (GT, "strub", "callable");
23
24 type GT_SD is access function return Integer;
25 pragma Machine_Attribute (GT_SD, "strub", "disabled");
26
27 GP : GT_SD := GT_SD (GT'(G'Access));
28 -- pragma Machine_Attribute (GP, "strub", "disabled"); -- not needed.
29
30 function F (X : Integer) return Integer is
31 begin
32 return X * GP.all; -- { dg-error "using non-.strub. type" }
33 end;
34
35 end Strub_Ind2;