[clang] ce7c196 - [Clang] Ignore -fchar8_t in C (#138716)
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 8 03:15:09 PDT 2025
Author: cor3ntin
Date: 2025-05-08T12:15:05+02:00
New Revision: ce7c1963b914931817dd983f488cc0b810187b3a
URL: https://github.com/llvm/llvm-project/commit/ce7c1963b914931817dd983f488cc0b810187b3a
DIFF: https://github.com/llvm/llvm-project/commit/ce7c1963b914931817dd983f488cc0b810187b3a.diff
LOG: [Clang] Ignore -fchar8_t in C (#138716)
In C, `char8_t` is an alias to unsigned char, and should never be a
keyword.
Fixes #55373
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/test/Lexer/char8_t.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c52e285bde627..7f68fd877e4e2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -319,6 +319,8 @@ Modified Compiler Flags
- The ``-mexecute-only`` and ``-mpure-code`` flags are now accepted for AArch64 targets. (#GH125688)
+- The ``-fchar8_t`` flag is no longer considered in non-C++ languages modes. (#GH55373)
+
Removed Compiler Flags
-------------------------
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 351e1ad4e1b03..c8bd81bdf1e43 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3911,7 +3911,8 @@ defm char8__t : BoolFOption<"char8_t",
LangOpts<"Char8">, Default<cpp20.KeyPath>,
PosFlag<SetTrue, [], [ClangOption], "Enable">,
NegFlag<SetFalse, [], [ClangOption], "Disable">,
- BothFlags<[], [ClangOption, CC1Option], " C++ builtin type char8_t">>;
+ BothFlags<[], [ClangOption, CC1Option], " C++ builtin type char8_t">>,
+ ShouldParseIf<cplusplus.KeyPath>;
def fshort_wchar : Flag<["-"], "fshort-wchar">, Group<f_Group>,
HelpText<"Force wchar_t to be a short unsigned int">;
def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group<f_Group>,
diff --git a/clang/test/Lexer/char8_t.cpp b/clang/test/Lexer/char8_t.cpp
index d65597c68d8bc..2148609155186 100644
--- a/clang/test/Lexer/char8_t.cpp
+++ b/clang/test/Lexer/char8_t.cpp
@@ -5,6 +5,7 @@
// 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
+// RUN: %clang_cc1 -x c -verify %s -fchar8_t
#if defined(__cpp_char8_t) != defined(CHAR8_T)
#error wrong setting for __cpp_char_t
More information about the cfe-commits
mailing list