[mcs] Fixes codegen for lifted null bitwise operators with constant left side of...
authorMarek Safar <marek.safar@gmail.com>
Tue, 8 Mar 2016 12:39:48 +0000 (13:39 +0100)
committerMarek Safar <marek.safar@gmail.com>
Tue, 8 Mar 2016 12:41:14 +0000 (13:41 +0100)
mcs/mcs/nullable.cs
mcs/tests/gtest-540.cs
mcs/tests/ver-il-net_4_x.xml

index dbfc6b0648da0b095787be343dc632f572e14ffe..cce1f8419ce4c470eb5880c529786d337c7f693b 100644 (file)
@@ -897,6 +897,18 @@ namespace Mono.CSharp.Nullable
 
                                        ec.MarkLabel (is_null_label);
                                        LiftedNull.Create (type, loc).Emit (ec);
+                               } else if (Left.IsNull && UnwrapRight != null) {
+                                       UnwrapRight.Emit (ec);
+
+                                       ec.Emit (or ? OpCodes.Brtrue_S : OpCodes.Brfalse_S, load_right);
+
+                                       LiftedNull.Create (type, loc).Emit (ec);
+
+                                       ec.Emit (OpCodes.Br_S, end_label);
+
+                                       ec.MarkLabel (load_right);
+
+                                       UnwrapRight.Load (ec);
                                } else {
                                        Right.Emit (ec);
                                        ec.Emit (or ? OpCodes.Brfalse_S : OpCodes.Brtrue_S, load_left);
index 61c94270ef5d24a2da181b2555956df0b949e6ab..46b6f3b6ce0fcf0b5e9f7b99f76171a6aaa50fdc 100644 (file)
@@ -98,6 +98,35 @@ class C
 
                if ((null | b4) != true)
                        return 103;
+
+               bool? x_n = null;
+               bool? x_f = false;
+               bool? x_t = true;
+
+               bool? res;
+               res = null & x_n;
+               if (res.HasValue)
+                       return 201;
+
+               res = null & x_t;
+               if (res.HasValue)
+                       return 202;
+
+               res = null & x_f;
+               if (res.Value != false)
+                       return 203;
+
+               res = null | x_n;
+               if (res.HasValue)
+                       return 204;
+
+               res = null | x_t;
+               if (res.Value != true)
+                       return 205;
+
+               res = null | x_f;
+               if (res.HasValue)
+                       return 206;
                
                return 0;
        }
index b3846fd0d9765258b282f4fe5939a99bc6c91f13..4d1b74ea4b82d8b4e7a3c92ad73530eea6013126 100644 (file)
   <test name="gtest-540.cs">
     <type name="C">
       <method name="Int32 Main()" attrs="150">
-        <size>1025</size>
+        <size>1425</size>
       </method>
       <method name="Void .ctor()" attrs="6278">
         <size>7</size>