Browse Source

Fix missing cast in signed uint<int comparison.

pull/897/head 3.0-Preview2
Daniel Grunwald 8 years ago
parent
commit
30aa3bd42f
  1. 15
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

15
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -546,14 +546,15 @@ namespace ICSharpCode.Decompiler.CSharp
// attempt comparison without any additional casts // attempt comparison without any additional casts
var rr = resolver.ResolveBinaryOperator(inst.Kind.ToBinaryOperatorType(), left.ResolveResult, right.ResolveResult) var rr = resolver.ResolveBinaryOperator(inst.Kind.ToBinaryOperatorType(), left.ResolveResult, right.ResolveResult)
as OperatorResolveResult; as OperatorResolveResult;
if (rr != null && !rr.IsError if (rr != null && !rr.IsError) {
&& NullableType.GetUnderlyingType(rr.Operands[0].Type).GetSign() == inst.Sign IType compUType = NullableType.GetUnderlyingType(rr.Operands[0].Type);
&& NullableType.GetUnderlyingType(rr.Operands[1].Type).GetSign() == inst.Sign) if (compUType.GetSign() == inst.Sign && compUType.GetStackType() == inst.InputType) {
{ return new BinaryOperatorExpression(left.Expression, op, right.Expression)
return new BinaryOperatorExpression(left.Expression, op, right.Expression) .WithILInstruction(inst)
.WithILInstruction(inst) .WithRR(rr);
.WithRR(rr); }
} }
// Ensure the inputs have the correct sign: // Ensure the inputs have the correct sign:
KnownTypeCode inputType = KnownTypeCode.None; KnownTypeCode inputType = KnownTypeCode.None;
switch (inst.InputType) { switch (inst.InputType) {

Loading…
Cancel
Save