2004-12-06 Raja R Harinath <rharinath@novell.com>
authorRaja R Harinath <harinath@hurrynot.org>
Mon, 6 Dec 2004 09:53:49 +0000 (09:53 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Mon, 6 Dec 2004 09:53:49 +0000 (09:53 -0000)
Fix crash on cs0657-17.cs.
* codegen.cs (CommonAssemblyModulClass.GetClsCompliantAttribute):
Use RootContext.Tree.Types, not 'new RootTypes ()'.
* attribute.cs (GlobalAttribute.CheckAttributeType): Narrow down
the case where the NamespaceEntry gets overwritten.

svn path=/trunk/mcs/; revision=37179

mcs/errors/mcs-ignore-tests
mcs/mcs/ChangeLog
mcs/mcs/attribute.cs
mcs/mcs/codegen.cs

index d5b59f34aa4a781db10b3ae348c2cfbbe27dc44f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-cs0657-17.cs
index a0fa78ca47c0381ac050a860247d9dd7dfbb022e..976214e30bc6148ae652a4307fa9c3e3616de866 100755 (executable)
@@ -1,3 +1,11 @@
+2004-12-06  Raja R Harinath  <rharinath@novell.com>
+
+       Fix crash on cs0657-17.cs.
+       * codegen.cs (CommonAssemblyModulClass.GetClsCompliantAttribute):
+       Use RootContext.Tree.Types, not 'new RootTypes ()'.
+       * attribute.cs (GlobalAttribute.CheckAttributeType): Narrow down
+       the case where the NamespaceEntry gets overwritten.
+
 2004-12-06  Marek Safar  <marek.safar@seznam.cz>
 
        Fixed #69195, #56821
index 7dd1deb4d1adb0b933cac5207d1330181ba416e6..3d0d1a07650ef2cc2de0b2ccf9677ad9c885cab4 100644 (file)
@@ -1170,9 +1170,16 @@ namespace Mono.CSharp {
 
                protected override Type CheckAttributeType (EmitContext ec)
                {
-                       NamespaceEntry old = ec.DeclSpace.NamespaceEntry;
-                       if (old == null || old.NS == null || old.NS == Namespace.Root) 
+                       // RootContext.Tree.Types has a single NamespaceEntry which gets overwritten
+                       // each time a new file is parsed.  However, we need to use the NamespaceEntry
+                       // in effect where the attribute was used.  Since code elsewhere cannot assume
+                       // that the NamespaceEntry is right, just overwrite it.
+                       //
+                       // FIXME: Check every place the NamespaceEntry of RootContext.Tree.Types is used
+                       //        to ensure the right one is used.
+                       if (ec.DeclSpace == RootContext.Tree.Types)
                                ec.DeclSpace.NamespaceEntry = ns;
+
                        return base.CheckAttributeType (ec);
                }
        }
index 8ef70bbf5697cb6e48510d654003f891f44e9423..04eb6e74c86393a09ae10b40622b4f7b61dd06dc 100755 (executable)
@@ -1041,7 +1041,7 @@ namespace Mono.CSharp {
                        if (OptAttributes == null)
                                return null;
 
-                       EmitContext temp_ec = new EmitContext (new RootTypes (), Mono.CSharp.Location.Null, null, null, 0, false);
+                       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) {
                                a.Resolve (temp_ec);