[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 08:18:57 PDT 2023


aaron.ballman 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">,
----------------
cor3ntin wrote:
> 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)
Ahhh, thanks!


================
Comment at: clang/test/Preprocessor/ucn-allowed-chars.c:86
+#define AAA\u0024 // expected-error{{character '$' cannot be specified by a universal character name}} \
+                  // expected-warning{{whitespace}}
+#define AAB\u0040 // expected-error{{character '@' cannot be specified by a universal character name}} \
----------------
I'd like more context for this diagnostic message because I have no idea what it's trying to warn.


================
Comment at: clang/test/Preprocessor/ucn-pp-identifier.c:117
 // CHECK: note: did you mean to use '\u'?
-// CHECK-NEXT: {{^  112 | #define capital_u_\U00FC}}
+// CHECK-NEXT: {{^  114 | #define capital_u_\U00FC}}
 // CHECK-NEXT: {{^      |                    \^}}
----------------
Ugh, that's unfortunate. I wonder if we should change this to use a regex so the line number doesn't matter?


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