xref: /llvm-project/clang/test/Lexer/has_extension.c (revision 12728e144994efe84715f4e5dbb8c3104e9f0b5a)
1 // RUN: %clang_cc1 -std=c99 -E %s -o - | FileCheck --check-prefix=CHECK-PED-NONE %s
2 // RUN: %clang_cc1 -std=c99 -pedantic-errors -E %s -o - | FileCheck --check-prefix=CHECK-PED-ERR %s
3 
4 // CHECK-PED-NONE: no_dummy_extension
5 #if !__has_extension(dummy_extension)
6 int no_dummy_extension();
7 #endif
8 
9 // Arbitrary feature to test that has_extension is a superset of has_feature
10 // CHECK-PED-NONE: attribute_overloadable
11 #if __has_extension(attribute_overloadable)
12 int attribute_overloadable();
13 #endif
14 
15 // CHECK-PED-NONE: has_c_static_assert
16 // CHECK-PED-ERR: no_c_static_assert
17 #if __has_extension(c_static_assert)
18 int has_c_static_assert();
19 #else
20 int no_c_static_assert();
21 #endif
22 
23 // CHECK-PED-NONE: has_c_generic_selections_with_controlling_type
24 // CHECK-PED-ERR: no_c_generic_selections_with_controlling_type
25 #if __has_extension(c_generic_selection_with_controlling_type)
26 int has_c_generic_selections_with_controlling_type();
27 #else
28 int no_c_generic_selections_with_controlling_type();
29 #endif
30 
31 // CHECK-PED-NONE: has_c_generic_selections
32 // CHECK-PED-ERR: no_c_generic_selections
33 #if __has_extension(c_generic_selections)
34 int has_c_generic_selections();
35 #else
36 int no_c_generic_selections();
37 #endif
38 
39 // CHECK-PED-NONE: has_c_alignas
40 // CHECK-PED-ERR: no_c_alignas
41 #if __has_extension(c_alignas)
42 int has_c_alignas();
43 #else
44 int no_c_alignas();
45 #endif
46 
47 // CHECK-PED-NONE: has_c_alignof
48 // CHECK-PED-ERR: no_c_alignof
49 #if __has_extension(c_alignof)
50 int has_c_alignof();
51 #else
52 int no_c_alignof();
53 #endif
54 
55 // Arbitrary feature to test that the extension name can be surrounded with
56 // double underscores.
57 // CHECK-PED-NONE: has_double_underscores
58 #if __has_extension(__c_alignas__)
59 int has_double_underscores();
60 #endif
61