**** Merged r36893 from MCS ****
authorMartin Baulig <martin@novell.com>
Sat, 4 Dec 2004 23:19:06 +0000 (23:19 -0000)
committerMartin Baulig <martin@novell.com>
Sat, 4 Dec 2004 23:19:06 +0000 (23:19 -0000)
svn path=/trunk/mcs/; revision=37117

mcs/gmcs/ChangeLog
mcs/gmcs/ecore.cs
mcs/gmcs/expression.cs
mcs/gmcs/report.cs

index aef545b07ceb06d741fecc2ac53deeae476baba3..5f381cad7da698b5a5dc51e366263847b3aa83b7 100755 (executable)
@@ -1,7 +1,18 @@
+2004-12-01  Marek Safar  <marek.safar@seznam.cz>
+
+       Fix bug #68790
+       * ecore.cs: CheckMarshallByRefAccess new virtual method for testing
+       MarshallByReference members access.
+
+       * expression.cs: Use CheckMarshallByRefAccess;
+       Better error CS0197 message.
+
+       * report.cs: Print whole related error message.
+
 2004-11-29  Marek Safar  <marek.safar@seznam.cz>
 
        * class (GetClassBases): Better error 60 report.
-        (EventProperty): Disabled warning 67 detection.
+       (EventProperty): Disabled warning 67 detection.
 
 2004-11-29  Marek Safar  <marek.safar@seznam.cz>
 
index f03efd883103773d03bf2857dc8d5e75cd12b04b..5baf3249857fbb8de790c9e897aae5512c0e34bd 100755 (executable)
@@ -209,6 +209,9 @@ namespace Mono.CSharp {
                        Report.Warning (code, loc, format, args);
                }
 
+               // Not nice but we have broken hierarchy
+               public virtual void CheckMarshallByRefAccess (Type container) {}
+
                /// <summary>
                /// Tests presence of ObsoleteAttribute and report proper error
                /// </summary>
@@ -3109,6 +3112,14 @@ namespace Mono.CSharp {
                {
                        Emit (ec, false);
                }
+
+               public override void CheckMarshallByRefAccess (Type container)
+               {
+                       if (!container.IsSubclassOf (TypeManager.mbr_type) && DeclaringType.IsSubclassOf (TypeManager.mbr_type)) {
+                               Report.SymbolRelatedToPreviousError (DeclaringType);
+                               Report.Error (1690, loc, "Cannot call '{0}' method, property, or indexer because it is a value type member of a marshal-by-reference class", Name);
+                       }
+               }
                
                public void AddressOf (EmitContext ec, AddressOp mode)
                {
@@ -3366,6 +3377,8 @@ namespace Mono.CSharp {
                                instance_expr = instance_expr.DoResolve (ec);
                                if (instance_expr == null)
                                        return false;
+
+                               instance_expr.CheckMarshallByRefAccess (ec.ContainerType);
                        }
 
                        if (must_do_cs1540_check && (instance_expr != null)) {
@@ -3381,8 +3394,8 @@ namespace Mono.CSharp {
                                        return false;
                                }
                        }
-
                        return true;
+
                }
                
                override public Expression DoResolve (EmitContext ec)
index d184416e842c7cf1e267e28c95deed77dc5fef95..828f0fe365efc97a8e8c62194a18dc70c8f49a47 100755 (executable)
@@ -4172,8 +4172,9 @@ namespace Mono.CSharp {
 
                                        if (instance.GetType () != typeof (This)){
                                                if (fe.InstanceExpression.Type.IsSubclassOf (TypeManager.mbr_type)){
-                                                       Report.Error (197, loc,
-                                                                     "Can not pass a type that derives from MarshalByRefObject with out or ref");
+                                                       Report.SymbolRelatedToPreviousError (fe.InstanceExpression.Type);
+                                                       Report.Error (197, loc, "Cannot pass '{0}' as ref or out or take its address because it is a member of a marshal-by-reference class",
+                                                               fe.Name);
                                                        return false;
                                                }
                                        }
@@ -5503,6 +5504,9 @@ namespace Mono.CSharp {
                                }
                        }
                        
+                       if (mg.InstanceExpression != null)
+                               mg.InstanceExpression.CheckMarshallByRefAccess (ec.ContainerType);
+
                        eclass = ExprClass.Value;
                        return this;
                }
@@ -8696,6 +8700,8 @@ namespace Mono.CSharp {
                                UnsafeError (loc);
                                return null;
                        }
+
+                       instance_expr.CheckMarshallByRefAccess (ec.ContainerType);
                        
                        eclass = ExprClass.IndexerAccess;
                        return this;
@@ -8766,6 +8772,8 @@ namespace Mono.CSharp {
                                }
                        }
                        
+                       instance_expr.CheckMarshallByRefAccess (ec.ContainerType);
+
                        eclass = ExprClass.IndexerAccess;
                        return this;
                }
index d4326f734cf0e584327d5729d22691077ffe629f..08689ecf56db37b41b7038a9760d94ee0959c1f0 100644 (file)
@@ -94,7 +94,7 @@ namespace Mono.CSharp {
                                Console.Error.WriteLine (msg.ToString ());
 
                                foreach (string s in extra_information) 
-                                       Console.Error.WriteLine (s);
+                                       Console.Error.WriteLine (s + MessageType + ")");
 
                                extra_information.Clear ();