File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -903,10 +903,17 @@ std::optional<int32_t> RootSignatureParser::handleIntLiteral(bool Negated) {
903
903
904
904
llvm::APSInt Val (32 , /* IsUnsigned=*/ true );
905
905
// GetIntegerValue will overwrite Val from the parsed Literal and return
906
- // true if it overflows as a 32-bit unsigned int. Then check that it also
907
- // doesn't overflow as a signed 32-bit int.
908
- int64_t MaxMagnitude = -int64_t (std::numeric_limits<int32_t >::min ());
909
- if (Literal.GetIntegerValue (Val) || MaxMagnitude < Val.getExtValue ()) {
906
+ // true if it overflows as a 32-bit unsigned int
907
+ bool Overflowed = Literal.GetIntegerValue (Val);
908
+
909
+ // So we then need to check that it doesn't overflow as a 32-bit signed int:
910
+ int64_t MaxNegativeMagnitude = -int64_t (std::numeric_limits<int32_t >::min ());
911
+ Overflowed |= (Negated && MaxNegativeMagnitude < Val.getExtValue ());
912
+
913
+ int64_t MaxPositiveMagnitude = int64_t (std::numeric_limits<int32_t >::max ());
914
+ Overflowed |= (!Negated && MaxPositiveMagnitude < Val.getExtValue ());
915
+
916
+ if (Overflowed) {
910
917
// Report that the value has overflowed
911
918
PP.getDiagnostics ().Report (CurToken.TokLoc ,
912
919
diag::err_hlsl_number_literal_overflow)
You can’t perform that action at this time.
0 commit comments