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

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 9 00:46:06 PDT 2022


tbaeder marked 4 inline comments as done.
tbaeder 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'
----------------
tahonermann wrote:
> aaron.ballman wrote:
> > 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.
> Yes, that looks right (as long as the target has a signed `char` type).
Are you listing the positive conditions (that should be true) or negative ones? The conditions in the test case need to be false in order for the test case to succeed.


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

https://reviews.llvm.org/D124996



More information about the cfe-commits mailing list