[Mono-bugs] [Bug 30333][Min] New - MCS doesn't report missing `break' statements

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
14 Sep 2002 01:00:15 -0000


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by martin@gnome.org.

http://bugzilla.ximian.com/show_bug.cgi?id=30333

--- shadow/30333	Fri Sep 13 21:00:14 2002
+++ shadow/30333.tmp.24057	Fri Sep 13 21:00:14 2002
@@ -0,0 +1,352 @@
+Bug#: 30333
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: martin@gnome.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: MCS doesn't report missing `break' statements
+
+Here's a patch which I needed to commit to the debugger to make it compile with csc.  It compiled fine with mcs, so it doesn't report these 
+bugs (some of the changes are actually warning fixes):
+
+====
+Index: class.cs
+===================================================================
+RCS file: /cvs/public/mcs/mcs/class.cs,v
+retrieving revision 1.268
+diff -u -u -r1.268 class.cs
+--- class.cs	15 Aug 2002 00:53:27 -0000	1.268
++++ class.cs	15 Aug 2002 21:05:41 -0000
+@@ -23,7 +23,7 @@
+ 	/// <summary>
+ 	///   This is the base class for structs and classes.  
+ 	/// </summary>
+-	public class TypeContainer : DeclSpace, IMemberFinder {
++	public class TypeContainer : DeclSpace, IMemberFinder, IMemberContainer {
+ 		// Holds a list of classes and structures
+ 		ArrayList types;
+ 
+@@ -107,6 +107,10 @@
+ 
+ 		// The interfaces we implement.
+ 		Type [] ifaces;
++
++		// The member cache.
++		bool is_defined;
++		MemberCache member_cache;
+ 		
+ 		//
+ 		// The indexer name for this class
+@@ -736,6 +740,8 @@
+ 			
+ 			InTransit = true;
+ 
++			Report.Debug ("DEFINE TYPE", Name);
++
+ 			if (this is Class)
+ 				is_class = true;
+ 			else
+@@ -960,6 +966,8 @@
+ 		{
+ 			MemberInfo [] defined_names = null;
+ 
++			Report.Debug ("DEFINE", Name);
++
+ 			if (interface_order != null){
+ 				foreach (Interface iface in interface_order)
+ 					if ((iface.ModFlags & Modifiers.NEW) == 0)
+@@ -1050,6 +1058,9 @@
+ 			if (delegates != null)
+ 				DefineMembers (delegates, defined_names);
+ 
++			is_defined = true;
++			member_cache = new MemberCache (this);
++
+ 			return true;
+ 		}
+ 
+@@ -1277,7 +1288,6 @@
+ 
+ 			return new MemberList (members);
+ 		}
+-
+ 		
+ 
+ 		public static MemberList FindMembers (Type t, MemberTypes mt, BindingFlags bf,
+@@ -1686,6 +1696,265 @@
+ 		public static void Error_ExplicitInterfaceNotMemberInterface (Location loc, string name)
+ 		{
+ 			Report.Error (539, loc, "Explicit implementation: `" + name + "' is not a member of the interface");
++		}
++
++		//
++		// ICachingMemberFinder
++		//
++
++		public MemberList FindMembers (MemberTypes mt, BindingFlags bf, string name,
++					       MemberFilter filter, object criteria)
++		{
++			if (member_cache == null) {
++				Report.Debug (8, "OOOPS", Name, name, mt, bf, filter, criteria);
++				return FindMembers (mt, bf, filter, name);
++			} else {
++				return FindMembers (mt, bf, filter, name);
++				return member_cache.FindMembers (mt, bf, name, filter, criteria);
++			}
++		}
++
++		//
++		// IMemberContainer
++		//
++
++		string IMemberContainer.Name {
++			get {
++				return Name;
++			}
++		}
++
++		Type IMemberContainer.Type {
++			get {
++				return TypeBuilder;
++			}
++		}
++
++		IMemberContainer IMemberContainer.Parent {
++			get {
++				return TypeHandle.GetTypeHandle (TypeBuilder.BaseType);
++			}
++		}
++
++		bool IMemberContainer.IsInterface {
++			get {
++				return false;
++			}
++		}
++
++		MemberList IMemberContainer.GetMembers (MemberTypes mt, BindingFlags bf)
++		{
++			ArrayList members = new ArrayList ();
++
++			if (!is_defined)
++				throw new Exception ("FUCK");
++
++			int modflags = 0, static_flags = 0, want_static = 0;
++
++			if ((bf & BindingFlags.NonPublic) != 0)
++				modflags |= Modifiers.PRIVATE | Modifiers.PROTECTED | Modifiers.INTERNAL;
++			if ((bf & BindingFlags.Public) != 0)
++				modflags |= Modifiers.PUBLIC;
++
++			BindingFlags static_bf = bf & (BindingFlags.Static | BindingFlags.Instance);
++			if (static_bf == BindingFlags.Static)
++				static_flags = want_static = Modifiers.STATIC;
++			else if (static_bf == BindingFlags.Instance) {
++				static_flags = Modifiers.STATIC;
++				want_static = 0;
++			} else
++				static_flags = want_static = 0;
++
++			Report.Debug ("GET MEMBERS", Name, mt, bf, modflags, static_flags, want_static);
++
++			if ((mt & MemberTypes.Field) != 0) {
++				if (fields != null) {
++					foreach (Field f in fields) {
++						if ((f.ModFlags & modflags) == 0)
++							continue;
++						if ((f.ModFlags & static_flags) != want_static)
++							continue;
++
++						FieldBuilder fb = f.FieldBuilder;
++						if (fb != null)
++							members.Add (fb);
++					}
++				}
++
++				if (constants != null) {
++					foreach (Const con in constants) {
++						if ((con.ModFlags & modflags) == 0)
++							continue;
++						if ((con.ModFlags & static_flags) != want_static)
++							continue;
++						
++						FieldBuilder fb = con.FieldBuilder;
++						if (fb != null)
++							members.Add (fb);
++					}
++				}
++			}
++
++			if ((mt & MemberTypes.Method) != 0) {
++				if (methods != null) {
++					foreach (Method m in methods) {
++						if ((m.ModFlags & modflags) == 0)
++							continue;
++						if ((m.ModFlags & static_flags) != want_static)
++							continue;
++						
++						MethodBuilder mb = m.MethodBuilder;
++
++						if (mb != null)
++							members.Add (mb);
++					}
++				}
++
++				if (operators != null){
++					foreach (Operator o in operators) {
++						if ((o.ModFlags & modflags) == 0)
++							continue;
++						if ((o.ModFlags & static_flags) != want_static)
++							continue;
++						
++						MethodBuilder ob = o.OperatorMethodBuilder;
++						if (ob != null)
++							members.Add (ob);
++					}
++				}
++
++				if (properties != null){
++					foreach (Property p in properties){
++						if ((p.ModFlags & modflags) == 0)
++							continue;
++						if ((p.ModFlags & static_flags) != want_static)
++							continue;
++						
++						MethodBuilder b;
++
++						b = p.GetBuilder;
++						if (b != null)
++							members.Add (b);
++
++						b = p.SetBuilder;
++						if (b != null)
++							members.Add (b);
++					}
++				}
++
++				if (indexers != null){
++					foreach (Indexer ix in indexers){
++						if ((ix.ModFlags & modflags) == 0)
++							continue;
++						if ((ix.ModFlags & static_flags) != want_static)
++							continue;
++						
++						MethodBuilder b;
++
++						b = ix.GetBuilder;
++						if (b != null)
++							members.Add (b);
++
++						b = ix.SetBuilder;
++						if (b != null)							
++							members.Add (b);
++					}
++				}
++			}
++
++			if ((mt & MemberTypes.Event) != 0) {
++				if (events != null) {
++				        foreach (Event e in events) {
++						if ((e.ModFlags & modflags) == 0)
++							continue;
++						if ((e.ModFlags & static_flags) != want_static)
++							continue;
++
++						MemberInfo eb = e.EventBuilder;
++						if (eb != null)
++						        members.Add (e.EventBuilder);
++					}
++				}
++			}
++			
++			if ((mt & MemberTypes.Property) != 0){
++				if (properties != null) {
++					foreach (Property p in properties) {
++						if ((p.ModFlags & modflags) == 0)
++							continue;
++						if ((p.ModFlags & static_flags) != want_static)
++							continue;
++
++						MemberInfo pb = p.PropertyBuilder;
++						if (pb != null)
++							members.Add (p.PropertyBuilder);
++					}
++				}
++
++				if (indexers != null) {
++					foreach (Indexer ix in indexers) {
++						if ((ix.ModFlags & modflags) == 0)
++							continue;
++						if ((ix.ModFlags & static_flags) != want_static)
++							continue;
++
++						MemberInfo ib = ix.PropertyBuilder;
++						if (ib != null)
++							members.Add (ix.PropertyBuilder);
++					}
++				}
++			}
++			
++			if ((mt & MemberTypes.NestedType) != 0) {
++				if (types != null){
++					foreach (TypeContainer t in types) {
++						TypeBuilder tb = t.TypeBuilder;
++
++						if (tb != null)
++							members.Add (tb);
++					}
++				}
++
++				if (enums != null){
++					foreach (Enum en in enums){
++						TypeBuilder tb = en.TypeBuilder;
++
++						if (tb != null)
++							members.Add (tb);
++					}
++				}
++				
++				if (delegates != null){
++					foreach (Delegate d in delegates){
++						TypeBuilder tb = d.TypeBuilder;
++						
++						if (tb != null)
++							members.Add (tb);
++					}
++				}
++			}
++
++			if ((mt & MemberTypes.Constructor) != 0){
++
++				if (((bf & BindingFlags.Instance) != 0) && (instance_constructors != null)){
++					foreach (Constructor c in instance_constructors){
++						ConstructorBuilder cb = c.ConstructorBuilder;
++
++						if (cb != null)
++							members.Add (cb);
++					}
++				}
++
++				if (((bf & BindingFlags.Static) != 0) && (default_static_constructor != null)){
++					ConstructorBuilder cb =
++						default_static_constructor.ConstructorBuilder;
++					
++					if (cb != null)
++						members.Add (cb);
++				}
++			}
++
++			return new MemberList (members);
+ 		}
+ 	}
+ 
+====