2004-09-14 Marek Safar <marek.safar@seznam.cz>
authorMarek Safar <marek.safar@gmail.com>
Tue, 14 Sep 2004 15:55:09 +0000 (15:55 -0000)
committerMarek Safar <marek.safar@gmail.com>
Tue, 14 Sep 2004 15:55:09 +0000 (15:55 -0000)
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.

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

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

index 1a37ee6d6c4f60a3a66198e0c127ae641798ded4..01a787ea5638f729a0da8d2a21c80e62a8dc42e5 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>
 
        * cs-parser.jay: Sync a bit with the GMCS version.
index 13f2b6f028a78d4c0090ebda426343eb78c04520..eebbfc548120bca733811c6112418ca0c5303e82 100755 (executable)
@@ -4164,7 +4164,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);
                        }
                        
@@ -4507,6 +4510,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 3482c06f929006925feba752198b4848f65fba09..06e3439e4e6731b7cf4d7c9169e15683368b8c86 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 12aa89a01010cfbf6b6ff98143fa8c383c1d51f8..a24ec9199fdacdc853ac7cd8b6178a8faee37af2 100755 (executable)
@@ -199,7 +199,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 a8a009c7137850d036bb511f278444e8bed1767f..89f9b9d5fc4662a9dadae7462dbbbb4542118c37 100755 (executable)
@@ -5233,17 +5233,19 @@ 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);
+                       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))