From fe00e10a58ab5fe789a6bb4d548dc13b83903974 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 29 May 2015 17:45:25 +0200 Subject: [PATCH] Fix handling of 'volatile' prefix --- ICSharpCode.Decompiler/IL/ILReader.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/ILReader.cs b/ICSharpCode.Decompiler/IL/ILReader.cs index 4bbc69741..f000785d6 100644 --- a/ICSharpCode.Decompiler/IL/ILReader.cs +++ b/ICSharpCode.Decompiler/IL/ILReader.cs @@ -771,7 +771,7 @@ namespace ICSharpCode.Decompiler.IL { byte alignment = reader.ReadByte(); var inst = DecodeInstruction(); - var sup = inst as ISupportsUnalignedPrefix; + var sup = UnpackVoid(inst) as ISupportsUnalignedPrefix; if (sup != null) sup.UnalignedPrefix = alignment; else @@ -782,13 +782,19 @@ namespace ICSharpCode.Decompiler.IL private ILInstruction DecodeVolatile() { var inst = DecodeInstruction(); - var svp = inst as ISupportsVolatilePrefix; + var svp = UnpackVoid(inst) as ISupportsVolatilePrefix; if (svp != null) svp.IsVolatile = true; else Warn("Ignored invalid 'volatile' prefix"); return inst; } + + ILInstruction UnpackVoid(ILInstruction inst) + { + Void v = inst as Void; + return v != null ? v.Argument : inst; + } private ILInstruction DecodeReadonly() {