[PATCH] D124996: [clang][preprocessor] Fix unsigned-ness of utf8 char literals

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 6 06:47:08 PDT 2022


aaron.ballman added inline comments.


================
Comment at: clang/test/Lexer/utf8-char-literal.cpp:37-47
+#if __cplusplus == 201703L
+#  if defined(CHAR8_T)
+#    if u8'\xff' == '\xff' // expected-warning {{right side of operator converted from negative value to unsigned}}
+#      error Something's not right.
+#    endif
+#  else
+#    if u8'\xff' != '\xff'
----------------
The equality operators seem backwards to what @tahonermann was saying -- I read his comment as:

C++17/14/11: u8'\xff' == '\xff'
C++17/14/11, -fchar8_t: u8'\xff' != '\xff'
C++20 and up: u8'\xff' != '\xff'
C++20 and up, -fno-char8_t: u8'\xff' == '\xff'

Hopefully Tom can clarify if I misunderstood.


================
Comment at: clang/test/Lexer/utf8-char-literal.cpp:65
+
+/// In C2x, 8u char literals are always unsigned
+#if __STDC_VERSION__ >= 202000L
----------------



================
Comment at: clang/test/Lexer/utf8-char-literal.cpp:70
+#  endif
+#endif
----------------
tbaeder wrote:
> I know indenting the preprocessor directives here isn't according to coding style, but it helps a lot with readability.
I'm fine with the formatting -- it helps readability, and we don't require our tests to be correctly formatted anyway.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124996/new/

https://reviews.llvm.org/D124996



More information about the cfe-commits mailing list