[PATCH] D153621: [Clang] Correctly handle $, @, and ` when represented as UCN
Corentin Jabot via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 26 07:49:49 PDT 2023
cor3ntin added inline comments.
================
Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:200-207
+def warn_c2x_compat_literal_ucn_escape_basic_scs : Warning<
+ "specifying character '%0' with a universal character name is "
+ "incompatible with C standards before C2x">,
+ InGroup<CPre2xCompat>, DefaultIgnore;
+def warn_c2x_compat_literal_ucn_control_character : Warning<
+ "universal character name referring to a control character "
+ "incompatible with C standards before C2x">,
----------------
aaron.ballman wrote:
> Don't we need similar warnings for C++2c?
The change in C++ dates back to C++11, the warning you are looking for are just above (unchanged text)
================
Comment at: clang/lib/Lex/Lexer.cpp:3499-3500
if (CodePoint < 0xA0) {
- if (CodePoint == 0x24 || CodePoint == 0x40 || CodePoint == 0x60)
- return CodePoint;
-
----------------
aaron.ballman wrote:
> Should this be looking for C2x?
See https://github.com/llvm/llvm-project/issues/62133
This never worked. Making it work in older C mode is something I looked into but it didn't seem worth it.
================
Comment at: clang/lib/Lex/LiteralSupport.cpp:630
+ diag::warn_cxx98_compat_literal_ucn_escape_basic_scs
+ : diag::warn_c2x_compat_literal_ucn_escape_basic_scs )
<< StringRef(&BasicSCSChar, 1);
----------------
aaron.ballman wrote:
> Won't this give the C warning in C++98 mode? (We should add test coverage for C++98)
I'll be adding test and replace by `Features.CPlusPlus`. But to your question, no, in C++98, `IsError` is true so that branch is not taken
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153621/new/
https://reviews.llvm.org/D153621
More information about the cfe-commits
mailing list