Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ Improvements to Clang's diagnostics

- Clang now diagnoses integer constant expressions that are folded to a constant value as an extension in more circumstances. Fixes #GH59863

- Clang now warns for u8 character literals used in C23 with ``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``.

Improvements to Clang's time-trace
----------------------------------

Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticLexKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ def warn_cxx98_compat_unicode_literal : Warning<
def warn_cxx14_compat_u8_character_literal : Warning<
"unicode literals are incompatible with C++ standards before C++17">,
InGroup<CXXPre17Compat>, DefaultIgnore;
def warn_c17_compat_u8_character_literal : Warning<
"unicode literals are incompatible with C standards before C23">,
InGroup<CPre23Compat>, DefaultIgnore;
def warn_cxx11_compat_user_defined_literal : Warning<
"identifier after literal will be treated as a user-defined literal suffix "
"in C++11">, InGroup<CXX11Compat>, DefaultIgnore;
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Lex/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2428,7 +2428,9 @@ bool Lexer::LexCharConstant(Token &Result, const char *CurPtr,
? diag::warn_cxx98_compat_unicode_literal
: diag::warn_c99_compat_unicode_literal);
else if (Kind == tok::utf8_char_constant)
Diag(BufferPtr, diag::warn_cxx14_compat_u8_character_literal);
Diag(BufferPtr, LangOpts.CPlusPlus
? diag::warn_cxx14_compat_u8_character_literal
: diag::warn_c17_compat_u8_character_literal);
}

char C = getAndAdvanceChar(CurPtr, Result);
Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/pre-c2x-compat.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// RUN: %clang_cc1 %s -std=c2x -Wpre-c2x-compat -pedantic -fsyntax-only -verify

int digit_seps = 123'456; // expected-warning {{digit separators are incompatible with C standards before C23}}
unsigned char u8_char = u8'x'; // expected-warning {{unicode literals are incompatible with C standards before C23}}