+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>
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>
{
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)
{
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)) {
return false;
}
}
-
return true;
+
}
override public Expression DoResolve (EmitContext ec)
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;
}
}
}
}
+ if (mg.InstanceExpression != null)
+ mg.InstanceExpression.CheckMarshallByRefAccess (ec.ContainerType);
+
eclass = ExprClass.Value;
return this;
}
UnsafeError (loc);
return null;
}
+
+ instance_expr.CheckMarshallByRefAccess (ec.ContainerType);
eclass = ExprClass.IndexerAccess;
return this;
}
}
+ instance_expr.CheckMarshallByRefAccess (ec.ContainerType);
+
eclass = ExprClass.IndexerAccess;
return this;
}
Console.Error.WriteLine (msg.ToString ());
foreach (string s in extra_information)
- Console.Error.WriteLine (s);
+ Console.Error.WriteLine (s + MessageType + ")");
extra_information.Clear ();