Browse Source

Fix #1854

pull/1855/head
SilverFox 6 years ago
parent
commit
5914d5b96b
  1. 22
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs
  2. 2
      ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs
  3. 2
      ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs

22
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs

@ -379,11 +379,33 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -379,11 +379,33 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
return UseSpan(span);
}
public string GetSpan3()
{
Span<decimal> span = stackalloc decimal[GetSize()];
return UseSpan(span);
}
public string GetSpan4()
{
Span<decimal> span = stackalloc decimal[4] {
1m,
2m,
3m,
4m
};
return UseSpan(span);
}
public string UseSpan(Span<int> span)
{
throw new NotImplementedException();
}
public string UseSpan(Span<decimal> span)
{
throw new NotImplementedException();
}
public int GetSize()
{
throw new NotImplementedException();

2
ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs

@ -77,6 +77,8 @@ namespace ICSharpCode.Decompiler.IL @@ -77,6 +77,8 @@ namespace ICSharpCode.Decompiler.IL
case KnownTypeCode.UInt64:
case KnownTypeCode.Double:
return 8;
case KnownTypeCode.Decimal:
return 16;
}
return null;
}

2
ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs

@ -405,7 +405,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -405,7 +405,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
var pointerType = new PointerType(elementType);
var elementCountInstr = PointerArithmeticOffset.Detect(sizeInBytesInstr, pointerType.ElementType, checkForOverflow: true, unwrapZeroExtension: true);
if (!elementCountInstr.Match(elementCountInstr2).Success)
if (elementCountInstr == null || !elementCountInstr.Match(elementCountInstr2).Success)
return false;
return true;
}

Loading…
Cancel
Save