[mcs] Flow analysis of binary expressions not using logical operators. Fixes #20086
authorMarek Safar <marek.safar@gmail.com>
Wed, 28 May 2014 14:23:01 +0000 (16:23 +0200)
committerMarek Safar <marek.safar@gmail.com>
Wed, 28 May 2014 14:24:37 +0000 (16:24 +0200)
mcs/mcs/expression.cs
mcs/tests/test-893.cs [new file with mode: 0644]

index 469b89835dba91d9c52adfd0d3e78561a02a8378..01bbbafcf92d970069c5fc842632dc77349256d9 100644 (file)
@@ -2610,8 +2610,14 @@ namespace Mono.CSharp
                public override void FlowAnalysis (FlowAnalysisContext fc)
                {
                        if ((oper & Operator.LogicalMask) == 0) {
+                               var fc_ontrue = fc.DefiniteAssignmentOnTrue;
+                               var fc_onfalse = fc.DefiniteAssignmentOnFalse;
+                               fc.DefiniteAssignmentOnTrue = fc.DefiniteAssignmentOnFalse = fc.DefiniteAssignment;
                                left.FlowAnalysis (fc);
+                               fc.DefiniteAssignmentOnTrue = fc.DefiniteAssignmentOnFalse = fc.DefiniteAssignment;
                                right.FlowAnalysis (fc);
+                               fc.DefiniteAssignmentOnTrue = fc_ontrue;
+                               fc.DefiniteAssignmentOnFalse = fc_onfalse;
                                return;
                        }
 
diff --git a/mcs/tests/test-893.cs b/mcs/tests/test-893.cs
new file mode 100644 (file)
index 0000000..97cfc0a
--- /dev/null
@@ -0,0 +1,15 @@
+public class A
+{
+       public static bool TryAssign (out int x)
+       {
+               x = 0;
+               return true;
+       }
+
+       public static void Main ()
+       {
+               int x, y;
+               if ((!TryAssign (out x) || x == 0) & (!TryAssign (out y) || y == 0)) {
+               }
+       }
+}