xref: /llvm-project/clang/test/Preprocessor/has_attribute.c (revision 79f87be6888d13a94661be9d8908c83dd2229c9b)
1 // RUN: %clang_cc1 -triple arm-unknown-linux -verify -E %s -o - | FileCheck %s
2 
3 // CHECK: always_inline
4 #if __has_attribute(always_inline)
5 int always_inline();
6 #endif
7 
8 // CHECK: __always_inline__
9 #if __has_attribute(__always_inline__)
10 int __always_inline__();
11 #endif
12 
13 // CHECK: warn_unused_result
14 #if __has_attribute(warn_unused_result)
15 int warn_unused_result();
16 #endif
17 
18 // CHECK: no_dummy_attribute
19 #if !__has_attribute(dummy_attribute)
20 int no_dummy_attribute();
21 #endif
22 
23 // CHECK: has_has_attribute
24 #ifdef __has_attribute
25 int has_has_attribute();
26 #endif
27 
28 // CHECK: has_something_we_dont_have
29 #if !__has_attribute(something_we_dont_have)
30 int has_something_we_dont_have();
31 #endif
32 
33 #if __has_attribute(__const)
34  int fn3() __attribute__ ((__const));
35 #endif
36 
37 #if __has_attribute(const)
38  static int constFunction() __attribute__((const));
39 #endif
40 
41 // CHECK: has_no_volatile_attribute
42 #if !__has_attribute(volatile)
43 int has_no_volatile_attribute();
44 #endif
45 
46 // CHECK: has_arm_interrupt
47 #if __has_attribute(interrupt)
48   int has_arm_interrupt();
49 #endif
50 
51 // CHECK: does_not_have_dllexport
52 #if !__has_attribute(dllexport)
53   int does_not_have_dllexport();
54 #endif
55 
56 // CHECK: does_not_have_uuid
57 #if !__has_attribute(uuid)
58   int does_not_have_uuid
59 #endif
60 
61 #if __has_cpp_attribute(selectany) // expected-error {{function-like macro '__has_cpp_attribute' is not defined}}
62 #endif
63 
64 // Test that macro expansion of the builtin argument works.
65 #define F fallthrough
66 
67 #if __has_attribute(F)
68 int has_fallthrough;
69 #endif
70 // CHECK: int has_fallthrough;
71