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