[clang] [Clang] [C23] Implement N2653: u8 strings are char8_t[] (PR #97208)

Mital Ashok via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 1 09:56:10 PDT 2024


================
@@ -1342,8 +1342,10 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
                       getLockFreeValue(TI.get##Type##Width(), TI));
     DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
     DEFINE_LOCK_FREE_MACRO(CHAR, Char);
-    if (LangOpts.Char8)
-      DEFINE_LOCK_FREE_MACRO(CHAR8_T, Char); // Treat char8_t like char.
+    // char8_t has the same representation / width as unsigned
+    // char in C++ and is a typedef for unsigned char in C23
+    if (LangOpts.Char8 || LangOpts.C23)
----------------
MitalAshok wrote:

Looks like that also controls if `char8_t` is a keyword/builtin type, which it isn't in C23. (`LangOpts.Char8` is also false in C++20 with `-fno-char8_t`)

https://github.com/llvm/llvm-project/pull/97208


More information about the cfe-commits mailing list