strub: enable conditional support
[official-gcc.git] / gcc / testsuite / c-c++-common / torture / strub-ptrfn2.c
blob1148c246f20599a1e75ad23a3879452f3d0642ef
1 /* { dg-do compile } */
2 /* { dg-options "-fstrub=relaxed -Wpedantic" } */
3 /* { dg-require-effective-target strub } */
5 /* C++ does not warn about the partial incompatibilities.
7 The d_p () calls are actually rejected, even in C++, but they are XFAILed
8 here because we don't get far enough in the compilation as to observe them,
9 because the incompatibilities are errors without -fpermissive.
10 strub-ptrfn3.c uses -fpermissive to check those.
13 extern int __attribute__ ((strub ("callable"))) bac (void);
14 extern int __attribute__ ((strub ("disabled"))) bad (void);
15 extern int __attribute__ ((strub ("internal"))) bar (void);
16 extern int __attribute__ ((strub ("at-calls"))) bal (void);
18 void __attribute__ ((strub))
19 bap (void)
21 int __attribute__ ((strub ("disabled"))) (*d_p) (void) = bad;
22 int __attribute__ ((strub ("callable"))) (*c_p) (void) = bac;
23 int __attribute__ ((strub ("at-calls"))) (*a_p) (void) = bal;
25 d_p = bac; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
26 c_p = bad; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
27 c_p = bar; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
28 c_p = bal; /* { dg-message "incompatible|invalid conversion" } */
29 a_p = bac; /* { dg-message "incompatible|invalid conversion" } */
31 d_p (); /* { dg-error "indirect non-.strub. call in .strub. context" "" { xfail *-*-* } } */
32 c_p ();
33 a_p ();
36 void __attribute__ ((strub))
37 baP (void)
39 typedef int __attribute__ ((strub ("disabled"))) d_fn_t (void);
40 typedef int __attribute__ ((strub ("callable"))) c_fn_t (void);
41 typedef int __attribute__ ((strub ("at-calls"))) a_fn_t (void);
43 d_fn_t *d_p = bad;
44 c_fn_t *c_p = bac;
45 a_fn_t *a_p = bal;
47 d_p = bac; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
48 c_p = bad; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
49 c_p = bar; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
50 c_p = bal; /* { dg-message "incompatible|invalid conversion" } */
51 a_p = bac; /* { dg-message "incompatible|invalid conversion" } */
53 d_p (); /* { dg-error "indirect non-.strub. call in .strub. context" "" { xfail *-*-* } } */
54 c_p ();
55 a_p ();