[verifier] Add test for structs.
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 12 Sep 2017 17:39:38 +0000 (10:39 -0700)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 12 Sep 2017 17:39:38 +0000 (10:39 -0700)
mono/tests/verifier/valid_ref_return.cs

index 6350f1ec2514f24ad73f465525774ad7603f1b69..85e1f5486e5fa948f2c26452d76b68a11099302e 100644 (file)
@@ -1,5 +1,10 @@
 using System;
 
+struct Point {
+    public int x;
+    public int y;
+}
+
 class Foo {
        static int X = 10;
        static int[] Arr = new int[1];
@@ -52,4 +57,21 @@ class Foo {
        ref int ReturnFunc () {
                return ref ReturnStatic ();
        }
+
+    Point mp;
+
+    ref int Pick (bool b, ref Point p) {
+        if (b)
+            return ref p.x;
+        else
+            return ref p.y;
+    }
+
+    void F (bool b) {
+        Point lp = new Point {x = 3, y = 3};
+        ref int z = ref Pick (b, ref lp);
+        z = 4;
+        ref int z2 = ref Pick (b, ref mp);
+        z2 = 5;
+    }
 }