| 1 |
/* PR c/66970 - Add __has_builtin() macro |
| 2 |
Verify that errors are detected and handled gracefully. |
| 3 |
{ dg-do compile } */ |
| 4 |
|
| 5 |
#ifndef __has_builtin |
| 6 |
# error "__has_builtin is not defined" |
| 7 |
#endif |
| 8 |
|
| 9 |
#if __has_builtin // { dg-error "missing '\\\(' after '__has_builtin'" } |
| 10 |
#endif |
| 11 |
|
| 12 |
#if __has_builtin ( // { dg-error "macro '__has_builtin' requires an identifier" } |
| 13 |
#endif |
| 14 |
|
| 15 |
#if __has_builtin () // { dg-error "macro '__has_builtin' requires an identifier" } |
| 16 |
#endif |
| 17 |
|
| 18 |
#if __has_builtin (1) // { dg-error "macro '__has_builtin' requires an identifier" } |
| 19 |
#endif |
| 20 |
|
| 21 |
#if __has_builtin (1, 2) // { dg-error "macro '__has_builtin' requires an identifier" } |
| 22 |
#endif |
| 23 |
|
| 24 |
#if __has_builtin (1 + 2) // { dg-error "macro '__has_builtin' requires an identifier" } |
| 25 |
#endif |
| 26 |
|
| 27 |
#if __has_builtin (x, y) // { dg-error "expected '\\\)' after 'x'" } */ |
| 28 |
#endif |
| 29 |
|
| 30 |
#if __has_builtin (x + 1) // { dg-error "expected '\\\)' after 'x'" } */ |
| 31 |
#endif |
| 32 |
|
| 33 |
#if __has_builtin (p->i) // { dg-error "expected '\\\)' after 'p'" } */ |
| 34 |
#endif |
| 35 |
|
| 36 |
#if __has_builtin ((x)) // { dg-error "macro '__has_builtin' requires an identifier" } |
| 37 |
#endif |
| 38 |
|
| 39 |
#if __has_builtin ((y) // { dg-error "macro '__has_builtin' requires an identifier" } |
| 40 |
#endif |
| 41 |
|
| 42 |
#if __has_builtin ((((z) // { dg-error "macro '__has_builtin' requires an identifier" } |
| 43 |
#endif |
| 44 |
|
| 45 |
#if __has_builtin (x))) // { dg-error "missing '\\\('" }" |
| 46 |
#endif |
| 47 |
|
| 48 |
#if __has_builtin (f ()) // { dg-error "expected '\\\)' after 'f'" }" |
| 49 |
#endif |