| 1 |
// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -E %s | FileCheck %s |
| 2 |
// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -E %s -x c | FileCheck %s |
| 3 |
// REQUIRES: plugins, examples |
| 4 |
|
| 5 |
#ifdef __cplusplus |
| 6 |
# define HAS_ATTR(a) __has_cpp_attribute (a) |
| 7 |
#else |
| 8 |
# define HAS_ATTR(a) __has_c_attribute (a) |
| 9 |
#endif |
| 10 |
|
| 11 |
#if __has_attribute(example) |
| 12 |
// CHECK: has_attribute(example) was true |
| 13 |
has_attribute(example) was true |
| 14 |
#endif |
| 15 |
#if HAS_ATTR(example) |
| 16 |
// CHECK: has_$LANG_attribute(example) was true |
| 17 |
has_$LANG_attribute(example) was true |
| 18 |
#endif |
| 19 |
|
| 20 |
#if __has_attribute(doesnt_exist) |
| 21 |
// CHECK-NOT: has_attribute(doesnt_exist) unexpectedly was true |
| 22 |
has_attribute(doesnt_exist) unexpectedly was true |
| 23 |
#endif |
| 24 |
|
| 25 |
#if HAS_ATTR(doesnt_exist) |
| 26 |
// CHECK-NOT: has_$LANG_attribute(doesnt_exist) unexpectedly was true |
| 27 |
has_$LANG_attribute(doesnt_exist) unexpectedly was true |
| 28 |
#endif |