Author: marek
Date: 2005-04-06 03:50:36 -0400 (Wed, 06 Apr 2005)
New Revision: 42594

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/class.cs
   trunk/mcs/mcs/decl.cs
   trunk/mcs/mcs/delegate.cs
   trunk/mcs/mcs/ecore.cs
   trunk/mcs/mcs/expression.cs
   trunk/mcs/mcs/rootcontext.cs
Log:
2005-04-06  Marek Safar  <[EMAIL PROTECTED]>

        * class.cs (VerifyMembers): Doesn't need EmitContext argument.
        Warning CS0169 is back at level 3.
        (IMethodData.SetMemberIsUsed): New method.
        
        * decl.cs (IsUsed): New value; moved from FieldBase.Status
        (SetMemberIsUsed, IsUsed): New methods, encapsulate IsUsed.
        
        * delegate.cs (ResolveMethodGroupExpr): Call SetMemberIsUsed.

        * ecore.cs (FieldExpr.ResolveMemberAccess): Call SetMemberIsUsed for
        contants.
        (PropertyExpr.ResolveAccessors): Call SetMemberIsUsed when delegate
        is used.
        
        * expression.cs (OverloadResolve): Call SetMemberIsUsed. when method
        is used.
        
        * rootcontext.cs (RootContext.EmitCode): Call VerifyMembers in extra run
        to avoid the problems with nested types.

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2005-04-06 01:30:07 UTC (rev 42593)
+++ trunk/mcs/mcs/ChangeLog     2005-04-06 07:50:36 UTC (rev 42594)
@@ -1,3 +1,25 @@
+2005-04-06  Marek Safar  <[EMAIL PROTECTED]>
+
+       * class.cs (VerifyMembers): Doesn't need EmitContext argument.
+       Warning CS0169 is back at level 3.
+       (IMethodData.SetMemberIsUsed): New method.
+       
+       * decl.cs (IsUsed): New value; moved from FieldBase.Status
+       (SetMemberIsUsed, IsUsed): New methods, encapsulate IsUsed.
+       
+       * delegate.cs (ResolveMethodGroupExpr): Call SetMemberIsUsed.
+
+       * ecore.cs (FieldExpr.ResolveMemberAccess): Call SetMemberIsUsed for
+       contants.
+       (PropertyExpr.ResolveAccessors): Call SetMemberIsUsed when delegate
+       is used.
+       
+       * expression.cs (OverloadResolve): Call SetMemberIsUsed. when method
+       is used.
+       
+       * rootcontext.cs (RootContext.EmitCode): Call VerifyMembers in extra run
+       to avoid the problems with nested types.
+
 2005-04-05  Abin Thomas         <[EMAIL PROTECTED]>
            Anoob V.E  <[EMAIL PROTECTED]>
            Harilal P.R  <[EMAIL PROTECTED]>

Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs      2005-04-06 01:30:07 UTC (rev 42593)
+++ trunk/mcs/mcs/class.cs      2005-04-06 07:50:36 UTC (rev 42594)
@@ -1988,18 +1988,37 @@
                        return;
                }
 
-               protected virtual void VerifyMembers (EmitContext ec)
+               void CheckMemberUsage (MemberCoreArrayList al, string 
member_type)
                {
+                       if (al == null)
+                               return;
+
+                       foreach (MemberCore mc in al) {
+                               if ((mc.ModFlags & Modifiers.Accessibility) != 
Modifiers.PRIVATE)
+                                       continue;
+
+                               if (!mc.IsUsed) {
+                                       Report.Warning (169, mc.Location, "The 
private {0} '{1}' is never used", member_type, mc.GetSignatureForError ());
+                               }
+                       }
+               }
+
+               public virtual void VerifyMembers ()
+               {
                        //
                        // Check for internal or private fields that were never 
assigned
                        //
-                       if (RootContext.WarningLevel >= 4) {
+                       if (RootContext.WarningLevel >= 3) {
+                               CheckMemberUsage (properties, "property");
+                               CheckMemberUsage (methods, "method");
+                               CheckMemberUsage (constants, "constant");
+
                                if (fields != null){
-                                       foreach (Field f in fields) {
+                                       foreach (FieldMember f in fields) {
                                                if ((f.ModFlags & 
Modifiers.Accessibility) != Modifiers.PRIVATE)
                                                        continue;
                                                
-                                               if ((f.status & 
Field.Status.USED) == 0){
+                                               if (!f.IsUsed){
                                                        Report.Warning (169, 
f.Location, "The private field '{0}' is never used", f.GetSignatureForError ());
                                                        continue;
                                                }
@@ -2101,8 +2120,6 @@
                                if (Pending.VerifyPendingMethods ())
                                        return;
 
-                       VerifyMembers (ec);
-
                        if (iterators != null)
                                foreach (Iterator iterator in iterators)
                                        iterator.EmitType ();
@@ -2632,9 +2649,9 @@
                        }
                }
 
-               protected override void VerifyMembers (EmitContext ec)
+               public override void VerifyMembers ()
                {
-                       base.VerifyMembers (ec);
+                       base.VerifyMembers ();
 
                        if ((events != null) && (RootContext.WarningLevel >= 
3)) {
                                foreach (Event e in events){
@@ -3353,6 +3370,16 @@
                        return true;
                }
 
+               public override bool IsUsed
+               {
+                       get {
+                               if (IsExplicitImpl)
+                                       return true;
+
+                               return base.IsUsed;
+                       }
+               }
+
                //
                // Returns a string that represents the signature for this 
                // member which should be used in XML documentation.
@@ -3726,6 +3753,9 @@
                            (RootContext.MainClass == null ||
                             RootContext.MainClass == 
Parent.TypeBuilder.FullName)){
                                 if (IsEntryPoint (MethodBuilder, 
ParameterInfo)) {
+                                        IMethodData md = TypeManager.GetMethod 
(MethodBuilder);
+                                        md.SetMemberIsUsed ();
+
                                         if (RootContext.EntryPoint == null) {
                                                 RootContext.EntryPoint = 
MethodBuilder;
                                                 RootContext.EntryPointLocation 
= Location;
@@ -4486,6 +4516,7 @@
                string GetSignatureForError (TypeContainer tc);
                bool IsExcluded (EmitContext ec);
                bool IsClsCompliaceRequired (DeclSpace ds);
+               void SetMemberIsUsed ();
        }
 
        //
@@ -5111,7 +5142,6 @@
                [Flags]
                public enum Status : byte {
                        ASSIGNED = 1,
-                       USED = 2,
                        HAS_OFFSET = 4          // Used by FieldMember.
                }
 
@@ -5824,6 +5854,16 @@
                        return true;
                }
 
+               public override bool IsUsed
+               {
+                       get {
+                               if (IsDummy)
+                                       return false;
+
+                               return base.IsUsed;
+                       }
+               }
+
                public new Location Location { 
                        get {
                                return base.Location;
@@ -6291,6 +6331,16 @@
                        return Get.IsDuplicateImplementation (mc) || 
Set.IsDuplicateImplementation (mc);
                }
 
+               public override bool IsUsed
+               {
+                       get {
+                               if (IsExplicitImpl)
+                                       return true;
+
+                               return Get.IsUsed | Set.IsUsed;
+                       }
+               }
+
                protected override void SetMemberName (MemberName new_name)
                {
                        base.SetMemberName (new_name);
@@ -6567,8 +6617,10 @@
                
                public void SetUsed ()
                {
-                       if (my_event != null)
-                               my_event.status = (FieldBase.Status.ASSIGNED | 
FieldBase.Status.USED);
+                       if (my_event != null) {
+                               my_event.status = FieldBase.Status.ASSIGNED;
+                               my_event.SetMemberIsUsed ();
+                       }
                }
        }
        

Modified: trunk/mcs/mcs/decl.cs
===================================================================
--- trunk/mcs/mcs/decl.cs       2005-04-06 01:30:07 UTC (rev 42593)
+++ trunk/mcs/mcs/decl.cs       2005-04-06 07:50:36 UTC (rev 42594)
@@ -227,7 +227,8 @@
                        ClsCompliantAttributeTrue = 1 << 7,                     
// Type has CLSCompliant (true)
                        Excluded_Undetected = 1 << 8,           // Conditional 
attribute has not been detected yet
                        Excluded = 1 << 9,                                      
// Method is conditional
-                       TestMethodDuplication = 1 << 10         // Test for 
duplication must be performed
+                       TestMethodDuplication = 1 << 10,                // Test 
for duplication must be performed
+                       IsUsed = 1 << 11
                }
 
                /// <summary>
@@ -308,6 +309,17 @@
                        }
                }
 
+               public virtual bool IsUsed {
+                       get {
+                               return (caching_flags & Flags.IsUsed) != 0;
+                       }
+               }
+
+               public void SetMemberIsUsed ()
+               {
+                       caching_flags |= Flags.IsUsed;
+               }
+
                // 
                // Whehter is it ok to use an unsafe pointer in this type 
container
                //

Modified: trunk/mcs/mcs/delegate.cs
===================================================================
--- trunk/mcs/mcs/delegate.cs   2005-04-06 01:30:07 UTC (rev 42593)
+++ trunk/mcs/mcs/delegate.cs   2005-04-06 07:50:36 UTC (rev 42594)
@@ -798,6 +798,7 @@
                                        Report.Error (1618, loc, "Cannot create 
delegate with '{0}' because it has a Conditional attribute", 
TypeManager.CSharpSignature (delegate_method));
                                }
                        } else {
+                               md.SetMemberIsUsed ();
                                if (md.OptAttributes != null && 
md.OptAttributes.Search (TypeManager.conditional_attribute_type, ec) != null) {
                                        Report.Error (1618, loc, "Cannot create 
delegate with '{0}' because it has a Conditional attribute", 
TypeManager.CSharpSignature (delegate_method));
                                }

Modified: trunk/mcs/mcs/ecore.cs
===================================================================
--- trunk/mcs/mcs/ecore.cs      2005-04-06 01:30:07 UTC (rev 42593)
+++ trunk/mcs/mcs/ecore.cs      2005-04-06 07:50:36 UTC (rev 42594)
@@ -2729,6 +2729,7 @@
                                        if (!c.LookupConstantValue (out o))
                                                return null;
 
+                                       c.SetMemberIsUsed ();
                                        object real_value = ((Constant) 
c.Expr).GetValue ();
 
                                        Expression exp = Constantify 
(real_value, t);
@@ -2960,7 +2961,7 @@
                                        if ((f.ModFlags & Modifiers.VOLATILE) 
!= 0)
                                                is_volatile = true;
                                        
-                                       f.status |= Field.Status.USED;
+                                       f.SetMemberIsUsed ();
                                }
                        } 
                        
@@ -3078,7 +3079,7 @@
                                        if ((mode & AddressOp.Store) != 0)
                                                f.status |= 
Field.Status.ASSIGNED;
                                        if ((mode & AddressOp.Load) != 0)
-                                               f.status |= Field.Status.USED;
+                                               f.SetMemberIsUsed ();
                                }
                        } 
 
@@ -3245,11 +3246,19 @@
                        FindAccessors (ec.ContainerType);
 
                        if (getter != null) {
+                               IMethodData md = TypeManager.GetMethod (getter);
+                               if (md != null)
+                                       md.SetMemberIsUsed ();
+
                                AccessorTable [getter] = PropertyInfo;
                                is_static = getter.IsStatic;
                        }
 
                        if (setter != null) {
+                               IMethodData md = TypeManager.GetMethod (setter);
+                               if (md != null)
+                                       md.SetMemberIsUsed ();
+
                                AccessorTable [setter] = PropertyInfo;
                                is_static = setter.IsStatic;
                        }

Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2005-04-06 01:30:07 UTC (rev 42593)
+++ trunk/mcs/mcs/expression.cs 2005-04-06 07:50:36 UTC (rev 42594)
@@ -5031,6 +5031,11 @@
                                                     method_params, null, 
may_fail, loc))
                                return null;
 
+                       if (method != null) {
+                               IMethodData data = TypeManager.GetMethod 
(method);
+                               if (data != null)
+                                       data.SetMemberIsUsed ();
+                       }
                        return method;
                }
 

Modified: trunk/mcs/mcs/rootcontext.cs
===================================================================
--- trunk/mcs/mcs/rootcontext.cs        2005-04-06 01:30:07 UTC (rev 42593)
+++ trunk/mcs/mcs/rootcontext.cs        2005-04-06 07:50:36 UTC (rev 42594)
@@ -613,6 +613,9 @@
                        if (type_container_resolve_order != null) {
                                foreach (TypeContainer tc in 
type_container_resolve_order)
                                        tc.EmitType ();
+
+                               foreach (TypeContainer tc in 
type_container_resolve_order)
+                                       tc.VerifyMembers ();
                        }
                        
                        if (Tree.Types.Delegates != null) {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to