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>
return null;
}
+ public override void CheckMarshallByRefAccess (Type container)
+ {
+ if (!IsStatic && Type.IsValueType && !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 bool VerifyFixed (bool is_expression)
{
IVariable variable = instance_expr as IVariable;
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)) {
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 ();