2005-03-16 Alexander Olk <xenomorph2@onlinehome.de>
[mono.git] / mcs / gmcs / codegen.cs
index bf0ccd890d6f961553291fa073b575b6242ed3fe..7f5d62efb21963cc23558a1e2ba0159949972416 100644 (file)
@@ -88,7 +88,7 @@ namespace Mono.CSharp {
                        //
                        if (SymbolWriter == null) {
                                Report.Warning (
-                                       -18, "Could not find the symbol writer assembly (Mono.CSharp.Debugger.dll). This is normally an installation problem. Please make sure to compile and install the mcs/class/Mono.CSharp.Debugger directory.");
+                                       -18, "Could not find the symbol writer assembly (Mono.CompilerServices.SymbolWriter.dll). This is normally an installation problem. Please make sure to compile and install the mcs/class/Mono.CompilerServices.SymbolWriter directory.");
                                return;
                        }
                }
@@ -435,6 +435,9 @@ namespace Mono.CSharp {
                        DeclSpace = ds;
                        CheckState = RootContext.Checked;
                        ConstantCheckState = true;
+
+                       if ((return_type is TypeBuilder) && return_type.IsGenericTypeDefinition)
+                               throw new Exception ("FUCK");
                        
                        IsStatic = (code_flags & Modifiers.STATIC) != 0;
                        InIterator = (code_flags & Modifiers.METHOD_YIELDS) != 0;
@@ -1041,6 +1044,10 @@ namespace Mono.CSharp {
                        if (OptAttributes == null)
                                return null;
 
+                       // Ensure that we only have GlobalAttributes, since the Search below isn't safe with other types.
+                       if (!OptAttributes.CheckTargets (this))
+                               return null;
+
                        EmitContext temp_ec = new EmitContext (RootContext.Tree.Types, Mono.CSharp.Location.Null, null, null, 0, false);
                        Attribute a = OptAttributes.Search (TypeManager.cls_compliant_attribute_type, temp_ec);
                        if (a != null) {
@@ -1055,6 +1062,7 @@ namespace Mono.CSharp {
                public AssemblyBuilder Builder;
                     
                bool is_cls_compliant;
+               public Attribute ClsCompliantAttribute;
 
                ListDictionary declarative_security;
 
@@ -1084,11 +1092,11 @@ namespace Mono.CSharp {
 
                public void ResolveClsCompliance ()
                {
-                       Attribute a = GetClsCompliantAttribute ();
-                       if (a == null)
+                       ClsCompliantAttribute = GetClsCompliantAttribute ();
+                       if (ClsCompliantAttribute == null)
                                return;
 
-                       is_cls_compliant = a.GetClsCompliantAttributeValue (null);
+                       is_cls_compliant = ClsCompliantAttribute.GetClsCompliantAttributeValue (null);
                }
 
                // fix bug #56621
@@ -1322,13 +1330,20 @@ namespace Mono.CSharp {
                                return;
                        }
                                
-                       ApplyAttributeBuilder (null, new CustomAttributeBuilder (TypeManager.unverifiable_code_ctor, new object [0]));
+                       Builder.SetCustomAttribute (new CustomAttributeBuilder (TypeManager.unverifiable_code_ctor, new object [0]));
                }
                 
                public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder customBuilder)
                {
-                       if (a != null && a.Type == TypeManager.cls_compliant_attribute_type) {
-                               Report.Warning (3012, a.Location, "You must specify the CLSCompliant attribute on the assembly, not the module, to enable CLS compliance checking");
+                       if (a.Type == TypeManager.cls_compliant_attribute_type) {
+                               if (CodeGen.Assembly.ClsCompliantAttribute == null) {
+                                       Report.Warning (3012, a.Location, "You must specify the CLSCompliant attribute on the assembly, not the module, to enable CLS compliance checking");
+                               }
+                               else if (CodeGen.Assembly.IsClsCompliant != a.GetBoolean ()) {
+                                       Report.SymbolRelatedToPreviousError (CodeGen.Assembly.ClsCompliantAttribute.Location, CodeGen.Assembly.ClsCompliantAttribute.Name);
+                                       Report.Error (3017, a.Location, "You cannot specify the CLSCompliant attribute on a module that differs from the CLSCompliant attribute on the assembly");
+                                       return;
+                               }
                        }
 
                        Builder.SetCustomAttribute (customBuilder);