``-f[no-]sanitize-recover=undefined,integer`` and is no longer deprecated.
- The argument to ``-f[no-]sanitize-trap=...`` is now optional and defaults to
``all``.
+- ``-fno-char8_t`` now disables the ``char8_t`` keyword, not just the use of
+ ``char8_t`` as the character type of ``u8`` literals. This restores the
+ Clang 8 behavior that regressed in Clang 9 and 10.
New Pragmas in Clang
--------------------
MODULES_KEYWORD(import)
// C++20 keywords.
-CXX20_KEYWORD(char8_t , CHAR8SUPPORT)
CXX20_KEYWORD(consteval , 0)
CXX20_KEYWORD(constinit , 0)
+// Not a CXX20_KEYWORD because it is disabled by -fno-char8_t.
+KEYWORD(char8_t , CHAR8SUPPORT)
// C11 Extension
KEYWORD(_Float16 , KEYALL)
if (LangOpts.Coroutines && (Flags & KEYCOROUTINES)) return KS_Enabled;
if (LangOpts.ModulesTS && (Flags & KEYMODULES)) return KS_Enabled;
if (LangOpts.CPlusPlus && (Flags & KEYALLCXX)) return KS_Future;
+ if (LangOpts.CPlusPlus && !LangOpts.CPlusPlus20 && (Flags & CHAR8SUPPORT))
+ return KS_Future;
return KS_Disabled;
}
LangOpts.CPlusPlus14 = LexingStd >= FormatStyle::LS_Cpp14;
LangOpts.CPlusPlus17 = LexingStd >= FormatStyle::LS_Cpp17;
LangOpts.CPlusPlus20 = LexingStd >= FormatStyle::LS_Cpp20;
+ LangOpts.Char8 = LexingStd >= FormatStyle::LS_Cpp20;
LangOpts.LineComment = 1;
bool AlternativeOperators = Style.isCpp();
#define CXX20_KEYWORD(NAME, FLAGS) \
.Case(#NAME, diag::warn_cxx20_keyword)
#include "clang/Basic/TokenKinds.def"
+ // char8_t is not modeled as a CXX20_KEYWORD because it's not
+ // unconditionally enabled in C++20 mode. (It can be disabled
+ // by -fno-char8_t.)
+ .Case("char8_t", diag::warn_cxx20_keyword)
;
llvm_unreachable(
-// RUN: %clang_cc1 -std=c++2a -verify %s
-// RUN: %clang_cc1 -std=c++2a -verify %s -fchar8_t
+// RUN: %clang_cc1 -std=c++20 -verify %s -DCHAR8_T
+// RUN: %clang_cc1 -std=c++20 -verify %s -fchar8_t -DCHAR8_T
+// RUN: %clang_cc1 -std=c++17 -verify %s -fchar8_t -DCHAR8_T
+
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s -fno-char8_t
+// RUN: %clang_cc1 -std=c++20 -verify %s -fno-char8_t
+
+#if defined(__cpp_char8_t) != defined(CHAR8_T)
+#error wrong setting for __cpp_char_t
+#endif
#if defined(__cpp_char8_t) && __is_identifier(char8_t)
#error char8_t is an identifier under -fchar8_t