[mcs] Arguments flow analysis needs to ignore out modifier.
authorMarek Safar <marek.safar@gmail.com>
Mon, 25 Nov 2013 14:56:46 +0000 (15:56 +0100)
committerMarek Safar <marek.safar@gmail.com>
Mon, 25 Nov 2013 15:02:58 +0000 (16:02 +0100)
mcs/errors/cs0165-29.cs [new file with mode: 0644]
mcs/errors/cs0165-30.cs [new file with mode: 0644]
mcs/errors/cs0165-31.cs [new file with mode: 0644]
mcs/errors/cs0165-32.cs [new file with mode: 0644]
mcs/mcs/argument.cs

diff --git a/mcs/errors/cs0165-29.cs b/mcs/errors/cs0165-29.cs
new file mode 100644 (file)
index 0000000..238093d
--- /dev/null
@@ -0,0 +1,12 @@
+// CS0165: Use of unassigned local variable `j'
+// Line: 10
+
+class Test
+{
+       static void Main ()
+       {
+               int? i;
+               int? j;
+               int? x = (i = 7) ?? j;
+    }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs0165-30.cs b/mcs/errors/cs0165-30.cs
new file mode 100644 (file)
index 0000000..c800aff
--- /dev/null
@@ -0,0 +1,11 @@
+// CS0165: Use of unassigned local variable `a'
+// Line: 9
+
+using System;
+
+class Test {
+       
+       static void Main () {
+               Action a = () => a();
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs0165-31.cs b/mcs/errors/cs0165-31.cs
new file mode 100644 (file)
index 0000000..07759cb
--- /dev/null
@@ -0,0 +1,11 @@
+// CS0165: Use of unassigned local variable `i'
+// Line: 9
+
+public class MainClass
+{
+       public void Foo ()
+       {
+               int i;
+               i++;
+       }
+}
diff --git a/mcs/errors/cs0165-32.cs b/mcs/errors/cs0165-32.cs
new file mode 100644 (file)
index 0000000..fb96522
--- /dev/null
@@ -0,0 +1,16 @@
+// CS0165: Use of unassigned local variable `a'
+// Line: 9
+
+class C
+{
+       static void Main ()
+       {
+               int a;
+               Foo (out a, a);
+       }
+
+       static void Foo (out int a, int b)
+       {
+               a = b;
+       }
+}
\ No newline at end of file
index c516ffde5b0f080798142ce2e2d361745c4f6104..13d0526cc2cd9c5a47e422bbdc2b9c763c2de9b4 100644 (file)
@@ -499,8 +499,25 @@ namespace Mono.CSharp
 
                public void FlowAnalysis (FlowAnalysisContext fc)
                {
-                       foreach (var arg in args)
+                       bool has_out = false;
+                       foreach (var arg in args) {
+                               if (arg.ArgType == Argument.AType.Out) {
+                                       has_out = true;
+                                       continue;
+                               }
+
                                arg.FlowAnalysis (fc);
+                       }
+
+                       if (!has_out)
+                               return;
+
+                       foreach (var arg in args) {
+                               if (arg.ArgType != Argument.AType.Out)
+                                       continue;
+
+                               arg.FlowAnalysis (fc);
+                       }
                }
 
                public List<Argument>.Enumerator GetEnumerator ()