Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tools/clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3540,7 +3540,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
if (Val < std::numeric_limits<uint32_t>::max())
Width = 32;
uint64_t MSB = 1ull << (Width - 1);
if ((Val & MSB) != 0)
if (!Literal.isUnsigned && (Val & MSB) != 0)
Comment thread
llvm-beanz marked this conversation as resolved.
Diag(Tok.getLocation(),
diag::warn_hlsl_legacy_integer_literal_signedness);
}
Expand Down Expand Up @@ -3702,7 +3702,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
// HLSL Change Begin - 202x integer warnings.
if (Literal.getRadix() != 10) {
uint64_t Val = ResultVal.getLimitedValue();
if ((Val & MSB) != 0)
if (!Literal.isUnsigned && (Val & MSB) != 0)
Diag(Tok.getLocation(),
diag::warn_hlsl_legacy_integer_literal_signedness);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ _Static_assert(is_same<__decltype(0x7000000000000000), int64_t>::value, "0x70000
// expected-warning@+1{{literal value is treated as signed in HLSL 2021 and earlier, and unsigned in later language versions}}
_Static_assert(is_same<__decltype(0xF000000000000000), uint64_t>::value, "0xF000000000000000 is uint64_t");

static const uint Suffixed = 0xFFF00000u; // No warning here!
// expected-warning@+1{{literal value is treated as signed in HLSL 2021 and earlier, and unsigned in later language versions}}
static const uint CastedUnsigned = (uint)0xFFF00000;
// expected-warning@+1{{literal value is treated as signed in HLSL 2021 and earlier, and unsigned in later language versions}}
static const int CastedSigned = (int)0xFFF00000;
Comment thread
Copilot marked this conversation as resolved.

#else
Comment thread
Copilot marked this conversation as resolved.
// The `literal float` typename is not spellable so we cannot verify the truth
// in this way.
Expand Down
Loading