Skip to content

Commit cb8c804

Browse files
committed
[Clang] Ignore -fchar8_t in C
In C, char8_t is an alias to unsigned char, and should never be a keyword. Fixes #55373
1 parent ffc5f79 commit cb8c804

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ Modified Compiler Flags
317317

318318
- The ``-mexecute-only`` and ``-mpure-code`` flags are now accepted for AArch64 targets. (#GH125688)
319319

320+
- The ``-fchar8_t`` flag is no longer consider in non-C++ languages modes. (#GH55373)
321+
320322
Removed Compiler Flags
321323
-------------------------
322324

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3879,7 +3879,8 @@ defm char8__t : BoolFOption<"char8_t",
38793879
LangOpts<"Char8">, Default<cpp20.KeyPath>,
38803880
PosFlag<SetTrue, [], [ClangOption], "Enable">,
38813881
NegFlag<SetFalse, [], [ClangOption], "Disable">,
3882-
BothFlags<[], [ClangOption, CC1Option], " C++ builtin type char8_t">>;
3882+
BothFlags<[], [ClangOption, CC1Option], " C++ builtin type char8_t">>,
3883+
ShouldParseIf<cplusplus.KeyPath>;
38833884
def fshort_wchar : Flag<["-"], "fshort-wchar">, Group<f_Group>,
38843885
HelpText<"Force wchar_t to be a short unsigned int">;
38853886
def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group<f_Group>,

clang/test/Lexer/char8_t.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// RUN: %clang_cc1 -std=c++17 -verify %s
66
// RUN: %clang_cc1 -std=c++17 -verify %s -fno-char8_t
77
// RUN: %clang_cc1 -std=c++20 -verify %s -fno-char8_t
8+
// RUN: %clang_cc1 -x c -verify %s -fchar8_t
89

910
#if defined(__cpp_char8_t) != defined(CHAR8_T)
1011
#error wrong setting for __cpp_char_t

0 commit comments

Comments
 (0)