[PATCH] D153621: [Clang] Correctly handle $, @, and ` when represented as UCN

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 26 07:27:42 PDT 2023


aaron.ballman added a comment.

I'm a bit confused as to whether we're planning to support this as an extension in older language modes or whether we expect this to be a new feature only enabled in newer language modes. Also, this should update the C and CXX status pages and have a release note.



================
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">,
----------------
Don't we need similar warnings for C++2c?


================
Comment at: clang/lib/Lex/Lexer.cpp:3487-3489
   // C99 6.4.3p2: A universal character name shall not specify a character whose
   //   short identifier is less than 00A0 other than 0024 ($), 0040 (@), or
   //   0060 (`), nor one in the range D800 through DFFF inclusive.)
----------------
You should update the comments here so they match the source.


================
Comment at: clang/lib/Lex/Lexer.cpp:3499-3500
   if (CodePoint < 0xA0) {
-    if (CodePoint == 0x24 || CodePoint == 0x40 || CodePoint == 0x60)
-      return CodePoint;
-
----------------
Should this be looking for C2x?


================
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);
----------------
Won't this give the C warning in C++98  mode? (We should add test coverage for C++98)


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