Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Lexer / keywords_test.c
blob466ed8235445a8b30f9df6e7e4ffba4fc8d7a4ed
1 // RUN: %clang_cc1 -std=c99 -E %s -o - | FileCheck --check-prefix=CHECK-NONE %s
3 // RUN: %clang_cc1 -std=gnu89 -E %s -o - \
4 // RUN: | FileCheck --check-prefix=CHECK-GNU-KEYWORDS %s
5 // RUN: %clang_cc1 -std=c99 -fgnu-keywords -E %s -o - \
6 // RUN: | FileCheck --check-prefix=CHECK-GNU-KEYWORDS %s
7 // RUN: %clang_cc1 -std=gnu89 -fno-gnu-keywords -E %s -o - \
8 // RUN: | FileCheck --check-prefix=CHECK-NONE %s
10 // RUN: %clang_cc1 -std=c99 -fms-extensions -fms-compatibility -E %s -o - \
11 // RUN: | FileCheck --check-prefix=CHECK-MS-KEYWORDS %s
12 // RUN: %clang_cc1 -std=c99 -fdeclspec -E %s -o - \
13 // RUN: | FileCheck --check-prefix=CHECK-DECLSPEC-KEYWORD %s
14 // RUN: %clang_cc1 -std=c99 -fms-extensions -fno-declspec -E %s -o - \
15 // RUN: | FileCheck --check-prefix=CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC %s
17 // RUN: %clang_cc1 -std=c99 -DC99 -fsyntax-only %s
18 // RUN: %clang_cc1 -std=c2x -DC99 -DC2x -fsyntax-only %s
20 // RUN: %clang_cc1 -fsyntax-only -std=c89 -DFutureKeyword -Wc2x-compat -Wc99-compat -verify=c89 %s
22 #define IS_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
23 #define NOT_KEYWORD(NAME) _Static_assert(__is_identifier(NAME), #NAME)
25 #if defined(C99)
26 #define C99_KEYWORD(NAME) IS_KEYWORD(NAME)
27 #else
28 #define C99_KEYWORD(NAME) NOT_KEYWORD(NAME)
29 #endif
31 #if defined(C2x)
32 #define C2x_KEYWORD(NAME) IS_KEYWORD(NAME)
33 #else
34 #define C2x_KEYWORD(NAME) NOT_KEYWORD(NAME)
35 #endif
37 // C99 Keywords.
38 C99_KEYWORD(restrict);
39 C99_KEYWORD(inline);
41 // C2x Keywords.
42 C2x_KEYWORD(bool);
43 C2x_KEYWORD(true);
44 C2x_KEYWORD(false);
45 C2x_KEYWORD(static_assert);
46 C2x_KEYWORD(typeof);
47 C2x_KEYWORD(typeof_unqual);
48 C2x_KEYWORD(thread_local);
49 C2x_KEYWORD(alignas);
50 C2x_KEYWORD(alignof);
52 void f() {
53 // CHECK-NONE: int asm
54 // CHECK-GNU-KEYWORDS: asm ("ret" : :)
55 #if __is_identifier(asm)
56 int asm;
57 #else
58 asm ("ret" : :);
59 #endif
62 // CHECK-NONE: no_ms_wchar
63 // CHECK-MS-KEYWORDS: has_ms_wchar
64 // CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC: has_ms_wchar
65 #if __is_identifier(__wchar_t)
66 void no_ms_wchar();
67 #else
68 void has_ms_wchar();
69 #endif
71 // CHECK-NONE: no_declspec
72 // CHECK-MS-KEYWORDS: has_declspec
73 // CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC: no_declspec
74 // CHECK-DECLSPEC-KEYWORD: has_declspec
75 #if __is_identifier(__declspec)
76 void no_declspec();
77 #else
78 void has_declspec();
79 #endif
81 // CHECK-NONE: no_static_assert
82 // CHECK-GNU-KEYWORDS: no_static_assert
83 // CHECK-MS-KEYWORDS: has_static_assert
84 // CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC: no_static_assert
85 #if __is_identifier(static_assert)
86 void no_static_assert();
87 #else
88 void has_static_assert();
89 #endif
91 #ifdef FutureKeyword
93 int restrict; // c89-warning {{'restrict' is a keyword in C99}}
94 int inline; // c89-warning {{'inline' is a keyword in C99}}
96 int bool; // c89-warning {{'bool' is a keyword in C23}}
97 char true; // c89-warning {{'true' is a keyword in C23}}
98 char false; // c89-warning {{'false' is a keyword in C23}}
99 float alignof; // c89-warning {{'alignof' is a keyword in C23}}
100 int typeof; // c89-warning {{'typeof' is a keyword in C23}}
101 int typeof_unqual; // c89-warning {{'typeof_unqual' is a keyword in C23}}
102 int alignas; // c89-warning {{'alignas' is a keyword in C23}}
103 int static_assert; // c89-warning {{'static_assert' is a keyword in C23}}
105 #endif