Author: martin
Date: 2005-04-19 09:48:51 -0400 (Tue, 19 Apr 2005)
New Revision: 43255

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/class.cs
   trunk/mcs/gmcs/decl.cs
   trunk/mcs/gmcs/delegate.cs
   trunk/mcs/gmcs/ecore.cs
   trunk/mcs/gmcs/expression.cs
   trunk/mcs/gmcs/rootcontext.cs
Log:
**** Merged r42594 from MCS ****


Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-04-19 13:48:06 UTC (rev 43254)
+++ trunk/mcs/gmcs/ChangeLog    2005-04-19 13:48:51 UTC (rev 43255)
@@ -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/gmcs/class.cs
===================================================================
--- trunk/mcs/gmcs/class.cs     2005-04-19 13:48:06 UTC (rev 43254)
+++ trunk/mcs/gmcs/class.cs     2005-04-19 13:48:51 UTC (rev 43255)
@@ -2136,18 +2136,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;
                                                }
@@ -2249,8 +2268,6 @@
                                if (Pending.VerifyPendingMethods ())
                                        return;
 
-                       VerifyMembers (ec);
-
                        if (iterators != null)
                                foreach (Iterator iterator in iterators)
                                        iterator.EmitType ();
@@ -2872,9 +2889,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){
@@ -3711,6 +3728,16 @@
                        return false;
                }
 
+               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.
@@ -4097,6 +4124,9 @@
                            (RootContext.MainClass == null ||
                             RootContext.MainClass == 
Parent.TypeBuilder.FullName)){
                                 if (IsEntryPoint (MethodBuilder, 
ParameterInfo)) {
+                                        IMethodData md = TypeManager.GetMethod 
(MethodBuilder);
+                                        md.SetMemberIsUsed ();
+
                                         if (RootContext.EntryPoint == null) {
                                                if (Parent.IsGeneric){
                                                        Report.Error (-201, 
Location,
@@ -4875,6 +4905,7 @@
                string GetSignatureForError (TypeContainer tc);
                bool IsExcluded (EmitContext ec);
                bool IsClsCompliaceRequired (DeclSpace ds);
+               void SetMemberIsUsed ();
        }
 
        //
@@ -5563,7 +5594,6 @@
                [Flags]
                public enum Status : byte {
                        ASSIGNED = 1,
-                       USED = 2,
                        HAS_OFFSET = 4          // Used by FieldMember.
                }
 
@@ -6293,6 +6323,16 @@
                        return true;
                }
 
+               public override bool IsUsed
+               {
+                       get {
+                               if (IsDummy)
+                                       return false;
+
+                               return base.IsUsed;
+                       }
+               }
+
                public new Location Location { 
                        get {
                                return base.Location;
@@ -6757,6 +6797,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);
@@ -7036,8 +7086,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/gmcs/decl.cs
===================================================================
--- trunk/mcs/gmcs/decl.cs      2005-04-19 13:48:06 UTC (rev 43254)
+++ trunk/mcs/gmcs/decl.cs      2005-04-19 13:48:51 UTC (rev 43255)
@@ -312,7 +312,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>
@@ -393,6 +394,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/gmcs/delegate.cs
===================================================================
--- trunk/mcs/gmcs/delegate.cs  2005-04-19 13:48:06 UTC (rev 43254)
+++ trunk/mcs/gmcs/delegate.cs  2005-04-19 13:48:51 UTC (rev 43255)
@@ -851,6 +851,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/gmcs/ecore.cs
===================================================================
--- trunk/mcs/gmcs/ecore.cs     2005-04-19 13:48:06 UTC (rev 43254)
+++ trunk/mcs/gmcs/ecore.cs     2005-04-19 13:48:51 UTC (rev 43255)
@@ -2988,6 +2988,7 @@
                                        if (!c.LookupConstantValue (out o))
                                                return null;
 
+                                       c.SetMemberIsUsed ();
                                        object real_value = ((Constant) 
c.Expr).GetValue ();
 
                                        Expression exp = Constantify 
(real_value, t);
@@ -3225,7 +3226,7 @@
                                        if ((f.ModFlags & Modifiers.VOLATILE) 
!= 0)
                                                is_volatile = true;
                                        
-                                       f.status |= Field.Status.USED;
+                                       f.SetMemberIsUsed ();
                                }
                        } 
                        
@@ -3343,7 +3344,7 @@
                                        if ((mode & AddressOp.Store) != 0)
                                                f.status |= 
Field.Status.ASSIGNED;
                                        if ((mode & AddressOp.Load) != 0)
-                                               f.status |= Field.Status.USED;
+                                               f.SetMemberIsUsed ();
                                }
                        } 
 
@@ -3510,11 +3511,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/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs        2005-04-19 13:48:06 UTC (rev 43254)
+++ trunk/mcs/gmcs/expression.cs        2005-04-19 13:48:51 UTC (rev 43255)
@@ -5127,6 +5127,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/gmcs/rootcontext.cs
===================================================================
--- trunk/mcs/gmcs/rootcontext.cs       2005-04-19 13:48:06 UTC (rev 43254)
+++ trunk/mcs/gmcs/rootcontext.cs       2005-04-19 13:48:51 UTC (rev 43255)
@@ -625,6 +625,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