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)
26 #define C99_KEYWORD(NAME) IS_KEYWORD(NAME)
28 #define C99_KEYWORD(NAME) NOT_KEYWORD(NAME)
32 #define C2x_KEYWORD(NAME) IS_KEYWORD(NAME)
34 #define C2x_KEYWORD(NAME) NOT_KEYWORD(NAME)
38 C99_KEYWORD(restrict
);
45 C2x_KEYWORD(static_assert);
47 C2x_KEYWORD(typeof_unqual
);
48 C2x_KEYWORD(thread_local
);
53 // CHECK-NONE: int asm
54 // CHECK-GNU-KEYWORDS: asm ("ret" : :)
55 #if __is_identifier(asm)
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)
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)
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();
88 void has_static_assert();
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}}