Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Lexer / keywords_test.cpp
blob62a2aef8ff66cb3c5176cefdc74a5827c30b577e
1 // RUN: %clang_cc1 -std=c++03 -fsyntax-only %s
2 // RUN: %clang_cc1 -std=c++11 -DCXX11 -fsyntax-only %s
3 // RUN: %clang_cc1 -std=c++20 -DCXX11 -DCXX20 -fsyntax-only %s
4 // RUN: %clang_cc1 -std=c++03 -fdeclspec -DDECLSPEC -fsyntax-only %s
5 // RUN: %clang_cc1 -std=c++03 -fms-extensions -DDECLSPEC -fsyntax-only %s
6 // RUN: %clang_cc1 -std=c++03 -fborland-extensions -DDECLSPEC -fsyntax-only %s
7 // RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fsyntax-only %s
8 // RUN: %clang_cc1 -std=c++03 -fborland-extensions -fno-declspec -fsyntax-only %s
9 // RUN: %clang_cc1 -std=c++03 -fno-declspec -fdeclspec -DDECLSPEC -fsyntax-only %s
10 // RUN: %clang_cc1 -std=c++03 -fdeclspec -fno-declspec -fsyntax-only %s
11 // RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fdeclspec -DDECLSPEC -fsyntax-only %s
12 // RUN: %clang_cc1 -std=c++03 -fms-extensions -fdeclspec -fno-declspec -fsyntax-only %s
13 // RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -DDECLSPEC -fsyntax-only %s
14 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -DDECLSPEC -fsyntax-only %s
15 // RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -fno-declspec -fsyntax-only %s
16 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -fno-declspec -fsyntax-only %s
18 // RUN: %clang_cc1 -std=c++98 -DFutureKeyword -fsyntax-only -Wc++11-compat -Wc++20-compat -verify=cxx98 %s
20 #define IS_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
21 #define NOT_KEYWORD(NAME) _Static_assert(__is_identifier(NAME), #NAME)
22 #define IS_TYPE(NAME) void is_##NAME##_type() { int f(NAME); }
24 #if defined(CXX20)
25 #define CXX20_KEYWORD(NAME) IS_KEYWORD(NAME)
26 #else
27 #define CXX20_KEYWORD(NAME) NOT_KEYWORD(NAME)
28 #endif
30 #ifdef DECLSPEC
31 #define DECLSPEC_KEYWORD(NAME) IS_KEYWORD(NAME)
32 #else
33 #define DECLSPEC_KEYWORD(NAME) NOT_KEYWORD(NAME)
34 #endif
36 #ifdef CXX11
37 #define CXX11_KEYWORD(NAME) IS_KEYWORD(NAME)
38 #define CXX11_TYPE(NAME) IS_TYPE(NAME)
39 #else
40 #define CXX11_KEYWORD(NAME) NOT_KEYWORD(NAME)
41 #define CXX11_TYPE(NAME)
42 #endif
44 // C++11 keywords
45 CXX11_KEYWORD(nullptr);
46 CXX11_KEYWORD(decltype);
47 CXX11_KEYWORD(alignof);
48 CXX11_KEYWORD(alignas);
49 CXX11_KEYWORD(char16_t);
50 CXX11_TYPE(char16_t);
51 CXX11_KEYWORD(char32_t);
52 CXX11_TYPE(char32_t);
53 CXX11_KEYWORD(constexpr);
54 CXX11_KEYWORD(noexcept);
56 #ifndef MS
57 CXX11_KEYWORD(static_assert);
58 #else
59 // MS compiler recognizes static_assert in all modes. So should we.
60 IS_KEYWORD(static_assert);
61 #endif
63 CXX11_KEYWORD(thread_local);
65 // Concepts keywords
66 CXX20_KEYWORD(concept);
67 CXX20_KEYWORD(requires);
68 CXX20_KEYWORD(consteval);
69 CXX20_KEYWORD(constinit);
70 CXX20_KEYWORD(co_await);
71 CXX20_KEYWORD(co_return);
72 CXX20_KEYWORD(co_yield);
74 // __declspec extension
75 DECLSPEC_KEYWORD(__declspec);
77 // Clang extension
78 IS_KEYWORD(__char16_t);
79 IS_TYPE(__char16_t);
80 IS_KEYWORD(__char32_t);
81 IS_TYPE(__char32_t);
83 #ifdef FutureKeyword
85 int nullptr; // cxx98-warning {{'nullptr' is a keyword in C++11}}
86 int decltype; // cxx98-warning {{'decltype' is a keyword in C++11}}
87 int alignof; // cxx98-warning {{'alignof' is a keyword in C++11}}
88 int alignas; // cxx98-warning {{'alignas' is a keyword in C++11}}
89 int char16_t; // cxx98-warning {{'char16_t' is a keyword in C++11}}
90 int char32_t; // cxx98-warning {{'char32_t' is a keyword in C++11}}
91 int constexpr; // cxx98-warning {{'constexpr' is a keyword in C++11}}
92 int noexcept; // cxx98-warning {{'noexcept' is a keyword in C++11}}
93 int static_assert; // cxx98-warning {{'static_assert' is a keyword in C++11}}
94 char thread_local; // cxx98-warning {{'thread_local' is a keyword in C++11}}
96 int co_await; // cxx98-warning {{'co_await' is a keyword in C++20}}
97 char co_return; // cxx98-warning {{'co_return' is a keyword in C++20}}
98 char co_yield; // cxx98-warning {{'co_yield' is a keyword in C++20}}
99 int constinit; // cxx98-warning {{'constinit' is a keyword in C++20}}
100 int consteval; // cxx98-warning {{'consteval' is a keyword in C++20}}
101 int requires; // cxx98-warning {{'requires' is a keyword in C++20}}
102 int concept; // cxx98-warning {{'concept' is a keyword in C++20}}
104 #endif