| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fstrub=relaxed -Wpedantic" } */ |
| 3 |
/* { dg-require-effective-target strub } */ |
| 4 |
|
| 5 |
/* C++ does not warn about the partial incompatibilities. |
| 6 |
|
| 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. |
| 11 |
*/ |
| 12 |
|
| 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); |
| 17 |
|
| 18 |
void __attribute__ ((strub)) |
| 19 |
bap (void) |
| 20 |
{ |
| 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; |
| 24 |
|
| 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" } */ |
| 30 |
|
| 31 |
d_p (); /* { dg-error "indirect non-.strub. call in .strub. context" "" { xfail *-*-* } } */ |
| 32 |
c_p (); |
| 33 |
a_p (); |
| 34 |
} |
| 35 |
|
| 36 |
void __attribute__ ((strub)) |
| 37 |
baP (void) |
| 38 |
{ |
| 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); |
| 42 |
|
| 43 |
d_fn_t *d_p = bad; |
| 44 |
c_fn_t *c_p = bac; |
| 45 |
a_fn_t *a_p = bal; |
| 46 |
|
| 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" } */ |
| 52 |
|
| 53 |
d_p (); /* { dg-error "indirect non-.strub. call in .strub. context" "" { xfail *-*-* } } */ |
| 54 |
c_p (); |
| 55 |
a_p (); |
| 56 |
} |