disable the building of mjs while I solve the problem with the unexposed ctr of Context
[mono.git] / mcs / mcs / parameter.cs
old mode 100755 (executable)
new mode 100644 (file)
index 209cd0a..51af0f7
@@ -69,6 +69,10 @@ namespace Mono.CSharp {
 
                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;
@@ -142,6 +146,8 @@ namespace Mono.CSharp {
                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)
@@ -153,10 +159,27 @@ namespace Mono.CSharp {
 
                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);
                }
 
@@ -165,6 +188,8 @@ namespace Mono.CSharp {
                // </summary>
                public bool Resolve (EmitContext ec, Location l)
                {
+                       this.ec = ec;
+
                        TypeExpr texpr = TypeName.ResolveAsTypeTerminal (ec, false);
                        if (texpr == null)
                                return false;
@@ -177,7 +202,7 @@ namespace Mono.CSharp {
                        }
 
                        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;
                        }
 
@@ -277,11 +302,6 @@ namespace Mono.CSharp {
                                        
                        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");
-                               }
                        }
                }