[PATCH] D99456: [C++2b] Support size_t literals
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 29 22:23:09 PDT 2021
rsmith added inline comments.
================
Comment at: clang/lib/Lex/LiteralSupport.cpp:640
isFloat16 = true;
continue;
}
----------------
Looks like this might fix [[ https://godbolt.org/z/9Pe4qr1c7 | incorrect acceptance ]] of `1.0f16f` and `1.0f16L` in CUDA mode too :)
================
Comment at: clang/lib/Sema/SemaExpr.cpp:3920-3927
+ if (ResultVal.isIntN(SizeTSize)) {
+ // Does it fit in a ssize_t?
+ if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0)
+ Ty = Context.getSignedSizeType();
+ else if (AllowUnsigned)
+ Ty = Context.getSizeType();
+ Width = SizeTSize;
----------------
I'd like to see some test coverage for this, particularly the testing of the high bit to determine if we're forming a signed or unsigned literal.
================
Comment at: clang/lib/Sema/SemaExpr.cpp:3975
// Check long long if needed.
if (Ty.isNull()) {
unsigned LongLongSize = Context.getTargetInfo().getLongLongWidth();
----------------
rsmith wrote:
> Likewise here -- and this one actually does matter, because we have targets with a 32-bit `size_t` but a 64-bit `long long`.
Can we get a test for this case? (Eg, `5'000'000'000z` with `-triple i686-linux`.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99456/new/
https://reviews.llvm.org/D99456
More information about the cfe-commits
mailing list