Debian Codegraph @

gcc/testsuite/c-c++-common/torture/strub-ptrfn3.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fstrub=relaxed -Wpedantic -fpermissive" } */
3 /* { dg-prune-output "command-line option .-fpermissive." } */
4 /* { dg-require-effective-target strub } */
5
6 /* See strub-ptrfn2.c. */
7
8 extern int __attribute__ ((strub ("callable"))) bac (void);
9 extern int __attribute__ ((strub ("disabled"))) bad (void);
10 extern int __attribute__ ((strub ("internal"))) bar (void);
11 extern int __attribute__ ((strub ("at-calls"))) bal (void);
12
13 void __attribute__ ((strub))
14 bap (void)
15 {
16 int __attribute__ ((strub ("disabled"))) (*d_p) (void) = bad;
17 int __attribute__ ((strub ("callable"))) (*c_p) (void) = bac;
18 int __attribute__ ((strub ("at-calls"))) (*a_p) (void) = bal;
19
20 d_p = bac; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
21 c_p = bad; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
22 c_p = bar; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
23 c_p = bal; /* { dg-message "incompatible|invalid conversion" } */
24 a_p = bac; /* { dg-message "incompatible|invalid conversion" } */
25
26 d_p (); /* { dg-error "indirect non-.strub. call in .strub. context" } */
27 c_p ();
28 a_p ();
29 }
30
31 void __attribute__ ((strub))
32 baP (void)
33 {
34 typedef int __attribute__ ((strub ("disabled"))) d_fn_t (void);
35 typedef int __attribute__ ((strub ("callable"))) c_fn_t (void);
36 typedef int __attribute__ ((strub ("at-calls"))) a_fn_t (void);
37
38 d_fn_t *d_p = bad;
39 c_fn_t *c_p = bac;
40 a_fn_t *a_p = bal;
41
42 d_p = bac; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
43 c_p = bad; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
44 c_p = bar; /* { dg-warning "not quite compatible" "" { xfail c++ } } */
45 c_p = bal; /* { dg-message "incompatible|invalid conversion" } */
46 a_p = bac; /* { dg-message "incompatible|invalid conversion" } */
47
48 d_p (); /* { dg-error "indirect non-.strub. call in .strub. context" } */
49 c_p ();
50 a_p ();
51 }