Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Arzt <arzt.samuel@live.de>2017-08-29 19:28:16 +0300
committerJan Kotas <jkotas@microsoft.com>2017-08-29 19:28:16 +0300
commit09f1de3e9b4e4616820d4bbb0321c1e688c01d31 (patch)
tree291b2bb8431585a5db1c68177ab7426377ff16db /src/ILVerify
parent6c6469a1ca854ae1286782ae4a15c6f152139569 (diff)
[ILVerify] Fix stind to allow storing a string to ref string (#4412)
* Added test case for assigning a string to a ref string. * Modified store indirect to correctly check types of value and address. * Added additional test case for assigning string to string ref as object. * Changed stind.ref to not replace typeToken with Object but address type.
Diffstat (limited to 'src/ILVerify')
-rw-r--r--src/ILVerify/src/ILImporter.Verify.cs11
-rw-r--r--src/ILVerify/tests/ILTests/LoadStoreIndirectTest.il24
2 files changed, 29 insertions, 6 deletions
diff --git a/src/ILVerify/src/ILImporter.Verify.cs b/src/ILVerify/src/ILImporter.Verify.cs
index 8ee832cf1..cc7adc402 100644
--- a/src/ILVerify/src/ILImporter.Verify.cs
+++ b/src/ILVerify/src/ILImporter.Verify.cs
@@ -1357,9 +1357,6 @@ namespace Internal.IL
ClearPendingPrefix(Prefix.Unaligned);
ClearPendingPrefix(Prefix.Volatile);
- if (type == null)
- type = GetWellKnownType(WellKnownType.Object);
-
var value = Pop();
var address = Pop();
@@ -1367,11 +1364,13 @@ namespace Internal.IL
CheckIsByRef(address);
+ if (type == null)
+ type = address.Type;
+
var typeVal = StackValue.CreateFromType(type);
var addressVal = StackValue.CreateFromType(address.Type);
- if (!value.IsNullReference)
- CheckIsAssignable(typeVal, addressVal);
+ CheckIsAssignable(typeVal, addressVal);
CheckIsAssignable(value, typeVal);
}
@@ -1382,7 +1381,7 @@ namespace Internal.IL
if (value.Kind != StackValueKind.ObjRef)
{
VerificationError(VerifierError.StackObjRef);
- }
+ }
}
void ImportLoadString(int token)
diff --git a/src/ILVerify/tests/ILTests/LoadStoreIndirectTest.il b/src/ILVerify/tests/ILTests/LoadStoreIndirectTest.il
index 3a9cc4cd5..eb7343a54 100644
--- a/src/ILVerify/tests/ILTests/LoadStoreIndirectTest.il
+++ b/src/ILVerify/tests/ILTests/LoadStoreIndirectTest.il
@@ -99,6 +99,30 @@
ret
}
+ .method static public hidebysig void StoreIndirect.AssignStringToRefString_Valid(string&) cil managed
+ {
+ // ref string x;
+ // string y = "a";
+ // x = y;
+
+ ldarg.0
+ ldstr "a"
+ stind.ref
+ ret
+ }
+
+ .method static public hidebysig void StoreObject.AssignStringToRefStringAsObject_Invalid_StackUnexpected(string&) cil managed
+ {
+ // ref string x;
+ // string y = "a";
+ // x = y;
+
+ ldarg.0
+ ldstr "a"
+ stobj [System.Runtime]System.Object
+ ret
+ }
+
.method static public hidebysig void StoreIndirect.AssignByteToBoolRef_Valid(bool&) cil managed
{
ldarg.0