hubert.reinterpretcast added inline comments.
================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16899
+ uint32_t CodePoint =
static_cast<uint32_t>(V.getInt().getZExtValue());
+ PrintCharLiteralPrefix(BTy->getKind(), OS);
+ OS << '\'';
----------------
hubert.reinterpretcast wrote:
> cor3ntin wrote:
> > Looking at the diagnostics, I don't think it makes sense to print a prefix
> > here. You could just leave that part out.
> Why is removing the prefix better? The types can matter (characters outside
> the basic character set are allowed to have negative `char` values). Also,
> moving forward, the value of a character need not be the same in the various
> encodings.
Some fun with signedness (imagine a more realistic example with `ISO-8859-1`
ordinary character encoding with a signed `char` type):
```
$ clang -Xclang -fwchar-type=short -xc++ -<<<$'static_assert(L"\\uFF10"[0] ==
U\'\\uFF10\');'
<stdin>:1:15: error: static assertion failed due to requirement 'L"\xFF10"[0]
== U'\uff10''
1 | static_assert(L"\uFF10"[0] == U'\uFF10');
| ^~~~~~~~~~~~~~~~~~~~~~~~~
<stdin>:1:28: note: expression evaluates to ''0' (0xFF10) == '0' (0xFF10)'
1 | static_assert(L"\uFF10"[0] == U'\uFF10');
| ~~~~~~~~~~~~~^~~~~~~~~~~~
1 error generated.
Return: 0x01:1 Fri Aug 11 23:49:02 2023 EDT
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155610/new/
https://reviews.llvm.org/D155610
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits