public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
{
if (a.Type == TypeManager.marshal_as_attr_type) {
- UnmanagedMarshal marshal = a.GetMarshal ();
+ UnmanagedMarshal marshal = a.GetMarshal (this);
if (marshal != null) {
builder.SetMarshal (marshal);
- return;
}
- Report.Warning (-24, a.Location, "The Microsoft Runtime cannot set this marshal info. Please use the Mono runtime instead.");
return;
}
public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
{
+ if (a.Type == TypeManager.cls_compliant_attribute_type) {
+ Report.Warning (3023, 1, a.Location, "CLSCompliant attribute has no meaning when applied to return types. Try putting it on the method instead");
+ }
+
// This occurs after Warning -28
if (builder == null)
return;
public readonly Modifier ModFlags;
public readonly string Name;
Type parameter_type;
+
+ EmitContext ec; // because ApplyAtrribute doesn't have ec
public Parameter (Expression type, string name, Modifier mod, Attributes attrs)
: base (attrs)
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
{
+ if (a.Type == TypeManager.in_attribute_type && Attributes == ParameterAttributes.Out) {
+ Report.Error (36, a.Location, "Can not use [In] attribute on out parameter");
+ return;
+ }
+
if (a.Type == TypeManager.param_array_type) {
Report.Error (674, a.Location, "Do not use 'System.ParamArrayAttribute'. Use the 'params' keyword instead");
return;
}
+
+ if (a.Type == TypeManager.out_attribute_type && (ModFlags & Modifier.REF) != 0 &&
+ !OptAttributes.Contains (TypeManager.in_attribute_type, ec)) {
+ Report.Error (662, a.Location,
+ "'{0}' cannot specify only Out attribute on a ref parameter. Use both In and Out attributes, or neither", GetSignatureForError ());
+ return;
+ }
+
+ if (a.Type == TypeManager.cls_compliant_attribute_type) {
+ Report.Warning (3022, 1, a.Location, "CLSCompliant attribute has no meaning when applied to parameters. Try putting it on the method instead");
+ }
+
base.ApplyAttributeBuilder (a, cb);
}
// </summary>
public bool Resolve (EmitContext ec, Location l)
{
+ this.ec = ec;
+
TypeExpr texpr = TypeName.ResolveAsTypeTerminal (ec, false);
if (texpr == null)
return false;
}
if (parameter_type == TypeManager.void_type){
- Report.Error (1536, l, "`void' parameter is not permitted");
+ Report.Error (1536, l, "Invalid parameter type 'void'");
return false;
}
if (OptAttributes != null) {
OptAttributes.Emit (ec, this);
-
- if (par_attr == ParameterAttributes.Out){
- if (OptAttributes.Contains (TypeManager.in_attribute_type, ec))
- Report.Error (36, loc, "Can not use [In] attribute on out parameter");
- }
}
}
return true;
}
-
- //
- // This variant is used by Delegates, because they need to
- // resolve/define names, instead of the plain LookupType
- //
- public bool ComputeAndDefineParameterTypes (EmitContext ec)
- {
- bool old_type_resolving = ec.ResolvingTypeTree;
- ec.ResolvingTypeTree = true;
- bool retval = ComputeParameterTypes (ec);
- ec.ResolvingTypeTree = old_type_resolving;
- return retval;
- }
/// <summary>
/// Returns the argument types as an array