[mcs] Fixes codegen for lifted bitwise operators which are liften only due to null...
authorMarek Safar <marek.safar@gmail.com>
Thu, 26 Nov 2015 18:52:25 +0000 (19:52 +0100)
committerMarek Safar <marek.safar@gmail.com>
Thu, 26 Nov 2015 19:07:03 +0000 (20:07 +0100)
mcs/mcs/expression.cs
mcs/mcs/nullable.cs
mcs/tests/gtest-540.cs
mcs/tests/ver-il-net_4_x.xml

index 53e1f1b707b1b3f5a153025fd774a6b1937b6aa8..66f26de7b28dc063477aae0dbdf490a8220c256b 100644 (file)
@@ -2953,11 +2953,11 @@ namespace Mono.CSharp
                                        }
 
                                        lifted.Left = b.left.IsNull ?
-                                               b.left :
+                                               Nullable.LiftedNull.Create (ltype, b.left.Location) :
                                                Convert.ImplicitConversion (rc, lifted.UnwrapLeft ?? b.left, ltype, b.left.Location);
 
                                        lifted.Right = b.right.IsNull ?
-                                               b.right :
+                                               Nullable.LiftedNull.Create (rtype, b.right.Location) :
                                                Convert.ImplicitConversion (rc, lifted.UnwrapRight ?? b.right, rtype, b.right.Location);
 
                                        return lifted.Resolve (rc);
index 38d36c807cb344a737d443306080b4bed111ffa1..4423ec8fee59c56ae6a8967ffa608aca1c8fb1c9 100644 (file)
@@ -795,7 +795,7 @@ namespace Mono.CSharp.Nullable
                        //
                        // Both operands are bool? types
                        //
-                       if (UnwrapLeft != null && UnwrapRight != null) {
+                       if ((UnwrapLeft != null && !Left.IsNull) && (UnwrapRight != null && !Right.IsNull)) {
                                if (ec.HasSet (BuilderContext.Options.AsyncBody) && Binary.Right.ContainsEmitWithAwait ()) {
                                        Left = Left.EmitToField (ec);
                                        Right = Right.EmitToField (ec);
index 7596032d16fcf14d71e45222d72469f2d00056f5..61c94270ef5d24a2da181b2555956df0b949e6ab 100644 (file)
@@ -85,6 +85,19 @@ class C
                
                if ((true | a) != true)
                        return 65;
+
+               var b4 = true;
+               if ((b4 & null) != null)
+                       return 100;
+
+               if ((null & b4) != null)
+                       return 101;
+
+               if ((b4 | null) != true)
+                       return 102;
+
+               if ((null | b4) != true)
+                       return 103;
                
                return 0;
        }
index 84d6bf2c1be1074923bf2f6dcc7efe32e173dbc3..228795963fc1132cc09cf6f3e0ba3a4e2108b963 100644 (file)
   <test name="gtest-540.cs">
     <type name="C">
       <method name="Int32 Main()" attrs="150">
-        <size>762</size>
+        <size>1017</size>
       </method>
       <method name="Void .ctor()" attrs="6278">
         <size>7</size>