In mcs:
authorRaja R Harinath <harinath@hurrynot.org>
Fri, 2 Sep 2005 12:19:54 +0000 (12:19 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Fri, 2 Sep 2005 12:19:54 +0000 (12:19 -0000)
Fix #75941.
* ecore.cs (SimpleNameResolve.DoSimpleNameResolve): Disable
flow-branching for LocalVariableReferences in case we were invoked
from a MemberAccess.
* expression.cs (LocalVariableReference.VerifyAssigned): New.
Carved out of ...
(LocalVariableReference.DoResolveBase): ... this.
(MemberAccess.Resolve): Do the check that was disabled during
SimpleNameResolve.

In tests:
* test-452.cs: New test from #75941.

svn path=/trunk/mcs/; revision=49340

mcs/errors/known-issues-mcs
mcs/mcs/ChangeLog
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/tests/ChangeLog
mcs/tests/test-452.cs [new file with mode: 0644]

index 97681d09710f39fcb06cec7971f9e0a6540055c1..6e0d45dd543e4b86fa91f35de0711e3c34f05539 100644 (file)
@@ -41,7 +41,3 @@ cs1638.cs NO ERROR
 cs1641.cs
 cs1666.cs NO ERROR
 cs2007.cs
-
-cs0149.cs
-cs0531-2.cs
-cs0571-4.cs
index 2c40a2143ec2ad1a32f1b8cd2ff64fbda088fcbd..d80fbb9058584275a0b7e66d975a7eb225851b79 100644 (file)
@@ -1,3 +1,15 @@
+2005-09-02  Raja R Harinath  <rharinath@novell.com>
+
+       Fix #75941.
+       * ecore.cs (SimpleNameResolve.DoSimpleNameResolve): Disable
+       flow-branching for LocalVariableReferences in case we were invoked
+       from a MemberAccess.
+       * expression.cs (LocalVariableReference.VerifyAssigned): New.
+       Carved out of ...
+       (LocalVariableReference.DoResolveBase): ... this.
+       (MemberAccess.Resolve): Do the check that was disabled during
+       SimpleNameResolve.
+
 2005-09-01  Atsushi Enomoto  <atsushi@ximian.com>
 
        * class.cs :
index 1fe9bc316a13bb5dd5163b2bdd501259ba399252..25be959853383847aa3e5492693d172d81eb6e0b 100644 (file)
@@ -1805,14 +1805,7 @@ namespace Mono.CSharp {
                public override FullNamedExpression ResolveAsTypeStep (EmitContext ec, bool silent)
                {
                        int errors = Report.Errors;
-               FullNamedExpression fne=null;
-       try {
-                       fne = ec.DeclSpace.LookupType (Name, loc, /*ignore_cs0104=*/ false);
-       } catch {
-
-                       Console.WriteLine ("Looking up: " + Name);
-       }
-
+                       FullNamedExpression fne = ec.DeclSpace.LookupType (Name, loc, /*ignore_cs0104=*/ false);
                        if (fne != null)
                                return fne;
 
@@ -1887,14 +1880,15 @@ namespace Mono.CSharp {
                        if (current_block != null){
                                LocalInfo vi = current_block.GetLocalInfo (Name);
                                if (vi != null){
-                                       Expression var;
-                                       
-                                       var = new LocalVariableReference (ec.CurrentBlock, Name, loc);
-                                       
-                                       if (right_side != null)
+                                       LocalVariableReference var = new LocalVariableReference (ec.CurrentBlock, Name, loc);
+                                       if (right_side != null) {
                                                return var.ResolveLValue (ec, right_side, loc);
-                                       else
-                                               return var.Resolve (ec);
+                                       } else {
+                                               ResolveFlags rf = ResolveFlags.VariableOrValue;
+                                               if (intermediate)
+                                                       rf |= ResolveFlags.DisableFlowAnalysis;
+                                               return var.Resolve (ec, rf);
+                                       }
                                }
 
                                ParameterReference pref = current_block.Toplevel.GetParameterReference (Name, loc);
index a4c3e44396524d072557c4cc9dcf9727058d25f6..c07719c82338e683ef0d71099c2b4e379c4a0e18 100644 (file)
@@ -3820,6 +3820,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool VerifyAssigned (EmitContext ec)
+               {
+                       VariableInfo variable_info = local_info.VariableInfo;
+                       return variable_info == null || variable_info.IsAssigned (ec, loc);
+               }
+
                protected Expression DoResolveBase (EmitContext ec, Expression lvalue_right_side)
                {
                        if (local_info == null) {
@@ -3857,7 +3863,7 @@ namespace Mono.CSharp {
                                return e.Resolve (ec);
                        }
 
-                       if ((variable_info != null) && !variable_info.IsAssigned (ec, loc))
+                       if (!VerifyAssigned (ec))
                                return null;
 
                        if (lvalue_right_side == null)
@@ -7486,15 +7492,22 @@ namespace Mono.CSharp {
                        if (member_lookup == null)
                                return null;
 
+                       if (original != null && !TypeManager.IsValueType (expr_type)) {
+                               me = member_lookup as MemberExpr;
+                               if (me != null && me.IsInstance) {
+                                       LocalVariableReference var = new_expr as LocalVariableReference;
+                                       if (var != null && !var.VerifyAssigned (ec))
+                                               return null;
+                               }
+                       }
+
                        // The following DoResolve/DoResolveLValue will do the definite assignment
                        // check.
 
                        if (right_side != null)
-                               member_lookup = member_lookup.DoResolveLValue (ec, right_side);
+                               return member_lookup.DoResolveLValue (ec, right_side);
                        else
-                               member_lookup = member_lookup.DoResolve (ec);
-
-                       return member_lookup;
+                               return member_lookup.DoResolve (ec);
                }
 
                public override Expression DoResolve (EmitContext ec)
index f240ed2f9df2bcaaa1a5eefe9ffbfd9ce047d065..b27b17e17377f65ac5b53c355cd3e5c8a7b858ad 100644 (file)
@@ -1,3 +1,7 @@
+2005-09-02  Raja R Harinath  <rharinath@novell.com>
+
+       * test-452.cs: New test from #75941.
+
 2005-08-30  Atsushi Enomoto  <atsushi@ximian.com>
 
        * test-partial-08.cs, test-partial-09.cs :
diff --git a/mcs/tests/test-452.cs b/mcs/tests/test-452.cs
new file mode 100644 (file)
index 0000000..af82adc
--- /dev/null
@@ -0,0 +1,13 @@
+class Foo
+{
+        static public Foo x;
+}
+
+class Test
+{
+        static void Main ()
+        {
+                Foo Foo;
+               Foo = Foo.x;
+        }
+}