**** Merged from MCS ****
authorMartin Baulig <martin@novell.com>
Tue, 14 Sep 2004 16:48:09 +0000 (16:48 -0000)
committerMartin Baulig <martin@novell.com>
Tue, 14 Sep 2004 16:48:09 +0000 (16:48 -0000)
svn path=/trunk/mcs/; revision=33890

mcs/gmcs/ChangeLog
mcs/gmcs/class.cs
mcs/gmcs/codegen.cs
mcs/gmcs/decl.cs
mcs/gmcs/enum.cs
mcs/gmcs/expression.cs

index a8aa71ccd8d66c4f3ec654dc0e340bbba1c08aff..80ebcb08532277ee15f7c5f763e6dea680ff7ff4 100755 (executable)
@@ -1,3 +1,12 @@
+2004-09-14  Marek Safar  <marek.safar@seznam.cz>
+
+       Fixed bug #61902
+       * codegen.cs (TestObsoleteMethodUsage): Trace when method is
+       called and is obsolete then this member suppress message
+       when call is inside next [Obsolete] method or type.
+
+       * expression.cs: Use TestObsoleteMethodUsage member.
+
 2004-09-14  Martin Baulig  <martin@ximian.com>
 
        * genericparser.cs: Removed.
index b851ffec290552c2af646ae706bfc50f7fce1428..69f00d437eca5055d2880dd63511f6ed9b96f2b8 100755 (executable)
@@ -4456,7 +4456,10 @@ namespace Mono.CSharp {
                                }
                        }
                        if (Initializer != null) {
-                               Initializer.CheckObsoleteAttribute (Parent, Location);
+                               if (GetObsoleteAttribute (Parent) == null && Parent.GetObsoleteAttribute (Parent.Parent) == null)
+                                       Initializer.CheckObsoleteAttribute (Parent, Location);
+                               else
+                                       ec.TestObsoleteMethodUsage = false;
                                Initializer.Emit (ec);
                        }
                        
@@ -4875,6 +4878,9 @@ namespace Mono.CSharp {
                        else
                                ec = method.CreateEmitContext (container, null);
 
+                       if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute (container.Parent) != null)
+                               ec.TestObsoleteMethodUsage = false;
+
                        Location loc = method.Location;
                        Attributes OptAttributes = method.OptAttributes;
 
index 95e0644b4b1ef335fea6439060126c2c38c0c158..644bf73f1aa1af6acdde150a7724fe6111962b74 100755 (executable)
@@ -393,6 +393,12 @@ namespace Mono.CSharp {
                /// </summary>
                public bool InEnumContext;
 
+               /// <summary>
+               /// Trace when method is called and is obsolete then this member suppress message
+               /// when call is inside next [Obsolete] method or type.
+               /// </summary>
+               public bool TestObsoleteMethodUsage = true;
+
                public Iterator CurrentIterator;
 
                FlowBranching current_flow_branching;
index bf28a2e3472da261074142729ffdd1ff04b1b99f..0444932e623fcd0e2cfff67b50f64a41b714eead 100755 (executable)
@@ -303,7 +303,9 @@ namespace Mono.CSharp {
                /// </summary>
                public virtual void Emit ()
                {
-                       VerifyObsoleteAttribute ();
+                       // Hack with Parent == null is for EnumMember 
+                       if (Parent == null || (GetObsoleteAttribute (Parent) == null && Parent.GetObsoleteAttribute (Parent.Parent) == null))
+                               VerifyObsoleteAttribute ();
 
                        if (!RootContext.VerifyClsCompliance)
                                return;
index 2511ec62312131e71875431bda272fb6e66bf154..2d05dd19a15a042f79c873451a5c7dbf8f6fd4e4 100755 (executable)
@@ -69,8 +69,6 @@ namespace Mono.CSharp {
 
                public void Emit (EmitContext ec)
                {
-                       base.Emit ();
-
                        if (OptAttributes != null)
                                OptAttributes.Emit (ec, this); 
 
index 0b763e3d532193f1e71ba4d41c3520d8620f0ff0..3c1121b8393ba2586215879f1ffb6b2af3d78f66 100755 (executable)
@@ -5529,22 +5529,18 @@ namespace Mono.CSharp {
                                        method = TypeManager.void_array_copyto_array_int;
                        }
 
-                       //
-                       // This checks ObsoleteAttribute on the method and on the declaring type
-                       //
-                       ObsoleteAttribute oa = AttributeTester.GetMethodObsoleteAttribute (method);
-                       if (oa != null)
-                               AttributeTester.Report_ObsoleteMessage (oa, TypeManager.CSharpSignature (method), loc);
-
-                       oa = AttributeTester.GetObsoleteAttribute (method.DeclaringType);
-                       if (oa != null) {
-                               AttributeTester.Report_ObsoleteMessage (oa, method.DeclaringType.FullName, loc);
-                       }
-
+                       if (ec.TestObsoleteMethodUsage) {
+                               //
+                               // This checks ObsoleteAttribute on the method and on the declaring type
+                               //
+                               ObsoleteAttribute oa = AttributeTester.GetMethodObsoleteAttribute (method);
+                               if (oa != null)
+                                       AttributeTester.Report_ObsoleteMessage (oa, TypeManager.CSharpSignature (method), loc);
 
-                       oa = AttributeTester.GetObsoleteAttribute (method.DeclaringType);
-                       if (oa != null) {
-                               AttributeTester.Report_ObsoleteMessage (oa, method.DeclaringType.FullName, loc);
+                               oa = AttributeTester.GetObsoleteAttribute (method.DeclaringType);
+                               if (oa != null) {
+                                       AttributeTester.Report_ObsoleteMessage (oa, method.DeclaringType.FullName, loc);
+                               }
                        }
 
                        if (IsMethodExcluded (method, ec))