[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
Tue May 10 23:52:16 PDT 2022


tbaeder added inline comments.


================
Comment at: clang/test/Lexer/utf8-char-literal.cpp:54-56
+#  if !(u8'\xff' == 0xff)
+#    error u8 char literal is not unsigned
+#  endif
----------------
tahonermann wrote:
> The C++ case looks good now, but the condition doesn't look right for the C case. The expectation is that `u8'\xff'` should not match `'\xff'` in C23 mode, but the test treats this as an error. If the test is passing, that indicates something is not being validated correctly. Shouldn't unexpected error diagnostics cause the test to fail?
I used `u8'\xff' != 0xff` here because that's the condition you mentioned in the phab review adding the `u8` prefix. Using `u8'\xff' != '\xff'` indeed fails with:

```
clang/test/Lexer/utf8-char-literal.cpp Line 55: u8 char literal is not unsigned
clang/test/Lexer/utf8-char-literal.cpp Line 54: right side of operator converted from negative value to unsigned: -1 to 18446744073709551615
```


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

https://reviews.llvm.org/D124996



More information about the cfe-commits mailing list