Skip to content

Commit ce7c196

Browse files
authored
[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
1 parent 127f486 commit ce7c196

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
@@ -319,6 +319,8 @@ Modified Compiler Flags
319319

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

322+
- The ``-fchar8_t`` flag is no longer considered in non-C++ languages modes. (#GH55373)
323+
322324
Removed Compiler Flags
323325
-------------------------
324326

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3911,7 +3911,8 @@ defm char8__t : BoolFOption<"char8_t",
39113911
LangOpts<"Char8">, Default<cpp20.KeyPath>,
39123912
PosFlag<SetTrue, [], [ClangOption], "Enable">,
39133913
NegFlag<SetFalse, [], [ClangOption], "Disable">,
3914-
BothFlags<[], [ClangOption, CC1Option], " C++ builtin type char8_t">>;
3914+
BothFlags<[], [ClangOption, CC1Option], " C++ builtin type char8_t">>,
3915+
ShouldParseIf<cplusplus.KeyPath>;
39153916
def fshort_wchar : Flag<["-"], "fshort-wchar">, Group<f_Group>,
39163917
HelpText<"Force wchar_t to be a short unsigned int">;
39173918
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)