| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-Wnonnull" } |
| 3 |
|
| 4 |
#define A(n) int *p##n |
| 5 |
#define B(n) A(n##0), A(n##1), A(n##2), A(n##3), A(n##4), A(n##5), A(n##6), A(n##7) |
| 6 |
#define C(n) B(n##0), B(n##1), B(n##2), B(n##3), B(n##4), B(n##5), B(n##6), B(n##7) |
| 7 |
#define D C(0), C(1), C(2), C(3) |
| 8 |
|
| 9 |
void foo (D) __attribute__((nonnull ( // { dg-message "in a call to function '\[^\n\r]*' declared 'nonnull'" } |
| 10 |
#embed __FILE__ limit (128) |
| 11 |
))); |
| 12 |
#if __cplusplus >= 201103L |
| 13 |
[[gnu::nonnull ( |
| 14 |
#embed __FILE__ limit (128) |
| 15 |
)]] void bar (D); // { dg-message "in a call to function '\[^\n\r]*' declared 'nonnull'" "" { target c++11 } } |
| 16 |
#else |
| 17 |
void bar (D) __attribute__((nonnull ( // { dg-message "in a call to function '\[^\n\r]*' declared 'nonnull'" "" { target c++98_only } } |
| 18 |
#embed __FILE__ limit (128) |
| 19 |
))); |
| 20 |
#endif |
| 21 |
|
| 22 |
#undef A |
| 23 |
#if __cplusplus >= 201103L |
| 24 |
#define A(n) nullptr |
| 25 |
#else |
| 26 |
#define A(n) 0 |
| 27 |
#endif |
| 28 |
|
| 29 |
void |
| 30 |
baz () |
| 31 |
{ |
| 32 |
foo (D); // { dg-warning "argument \[0-9]\+ null where non-null expected" } |
| 33 |
bar (D); // { dg-warning "argument \[0-9]\+ null where non-null expected" } |
| 34 |
} |