2004-09-12 Marek Safar <marek.safar@seznam.cz>
[mono.git] / mcs / mcs / class.cs
index c9a81c3ee0825454be4ff960b3951ba88c01a2a2..b845cf022b74815b951c9bf32432b9d50ceb51f8 100755 (executable)
@@ -1331,7 +1331,7 @@ namespace Mono.CSharp {
                        DefineContainerMembers (constants);
                        DefineContainerMembers (fields);
 
-                       if ((Kind == Kind.Class) && !(this is ClassPart)){
+                       if ((Kind == Kind.Class) && !(this is ClassPart) && !(this is StaticClass)){
                                if ((instance_constructors == null) &&
                                    !(this is StaticClass)) {
                                        if (default_constructor == null)
@@ -2741,8 +2741,13 @@ namespace Mono.CSharp {
 
                public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
                {
-                       if (a.UsageAttribute != null)
+                       if (a.UsageAttribute != null) {
+                               if (base_class_type != TypeManager.attribute_type && !base_class_type.IsSubclassOf (TypeManager.attribute_type) &&
+                                       TypeBuilder.FullName != "System.Attribute") {
+                                       Report.Error (641, a.Location, "Attribute '{0}' is only valid on classes derived from System.Attribute", a.Name);
+                               }
                                attribute_usage = a.UsageAttribute;
+                       }
 
                        base.ApplyAttributeBuilder (a, cb);
                }
@@ -3473,6 +3478,13 @@ namespace Mono.CSharp {
                                        Report.Error (629, Location, "Conditional member '{0}' cannot implement interface member", GetSignatureForError ());
                                        return;
                                }
+
+                               for (int i = 0; i < parameter_info.Count; ++i) {
+                                       if ((parameter_info.ParameterModifier (i) & Parameter.Modifier.OUT) != 0) {
+                                               Report.Error (685, Location, "Conditional method '{0}' cannot have an out parameter", GetSignatureForError ());
+                                               return;
+                                       }
+                               }
                        }
 
                        MethodBuilder.SetCustomAttribute (cb);
@@ -6710,7 +6722,7 @@ namespace Mono.CSharp {
                                }
                                
                                if (first_arg_type == TypeManager.object_type ||
-                                   return_type == TypeManager.object_type){
+                                       return_type == TypeManager.object_type){
                                        Report.Error (
                                                -8, Location,
                                                "User-defined conversion cannot convert to or from " +
@@ -6735,6 +6747,11 @@ namespace Mono.CSharp {
                                        Report.Error (554, Location, "'{0}' : user defined conversion to/from derived class", GetSignatureForError ());
                                        return false;
                                }
+                       } else if (OperatorType == OpType.LeftShift || OperatorType == OpType.RightShift) {
+                               if (first_arg_type != declaring_type || parameter_types [1] != TypeManager.int32_type) {
+                                       Report.Error (564, Location, "Overloaded shift operator must have the type of the first operand be the containing type, and the type of the second operand must be int");
+                                       return false;
+                               }
                        } else if (Parameters.FixedParameters.Length == 1) {
                                // Checks for Unary operators