| 1 |
/* Test __has_c_attribute. Test supported attributes. */ |
| 2 |
/* { dg-do preprocess } */ |
| 3 |
/* { dg-options "-std=c23 -pedantic-errors" } */ |
| 4 |
|
| 5 |
#if __has_c_attribute ( nodiscard ) != 202311L |
| 6 |
#error "bad result for nodiscard" |
| 7 |
#endif |
| 8 |
|
| 9 |
#if __has_c_attribute ( __nodiscard__ ) != 202311L |
| 10 |
#error "bad result for __nodiscard__" |
| 11 |
#endif |
| 12 |
|
| 13 |
#if __has_c_attribute(maybe_unused) != 202311L |
| 14 |
#error "bad result for maybe_unused" |
| 15 |
#endif |
| 16 |
|
| 17 |
#if __has_c_attribute(__maybe_unused__) != 202311L |
| 18 |
#error "bad result for __maybe_unused__" |
| 19 |
#endif |
| 20 |
|
| 21 |
#if __has_c_attribute (deprecated) != 202311L |
| 22 |
#error "bad result for deprecated" |
| 23 |
#endif |
| 24 |
|
| 25 |
#if __has_c_attribute (__deprecated__) != 202311L |
| 26 |
#error "bad result for __deprecated__" |
| 27 |
#endif |
| 28 |
|
| 29 |
#if __has_c_attribute (fallthrough) != 202311L |
| 30 |
#error "bad result for fallthrough" |
| 31 |
#endif |
| 32 |
|
| 33 |
#if __has_c_attribute (__fallthrough__) != 202311L |
| 34 |
#error "bad result for __fallthrough__" |
| 35 |
#endif |
| 36 |
|
| 37 |
#if __has_c_attribute (noreturn) != 202311L |
| 38 |
#error "bad result for noreturn" |
| 39 |
#endif |
| 40 |
|
| 41 |
#if __has_c_attribute (__noreturn__) != 202311L |
| 42 |
#error "bad result for __noreturn__" |
| 43 |
#endif |
| 44 |
|
| 45 |
#if __has_c_attribute (_Noreturn) != 202311L |
| 46 |
#error "bad result for _Noreturn" |
| 47 |
#endif |
| 48 |
|
| 49 |
#if __has_c_attribute (___Noreturn__) != 202311L |
| 50 |
#error "bad result for ___Noreturn__" |
| 51 |
#endif |
| 52 |
|
| 53 |
#if __has_c_attribute (unsequenced) != 202311L |
| 54 |
#error "bad result for unsequenced" |
| 55 |
#endif |
| 56 |
|
| 57 |
#if __has_c_attribute (__unsequenced__) != 202311L |
| 58 |
#error "bad result for __unsequenced__" |
| 59 |
#endif |
| 60 |
|
| 61 |
#if __has_c_attribute (reproducible) != 202311L |
| 62 |
#error "bad result for reproducible" |
| 63 |
#endif |
| 64 |
|
| 65 |
#if __has_c_attribute (__reproducible__) != 202311L |
| 66 |
#error "bad result for __reproducible__" |
| 67 |
#endif |
| 68 |
|
| 69 |
/* Macros in the attribute name are expanded. */ |
| 70 |
#define foo deprecated |
| 71 |
#if __has_c_attribute (foo) != 202311L |
| 72 |
#error "bad result for foo" |
| 73 |
#endif |