2008-03-17 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Mon, 17 Mar 2008 17:38:53 +0000 (17:38 -0000)
committerMarek Safar <marek.safar@gmail.com>
Mon, 17 Mar 2008 17:38:53 +0000 (17:38 -0000)
* class.cs, decl.cs, delegate.cs: Do protected modifier check on each member

* symbolwriter.cs: Fixed.

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

mcs/mcs/ChangeLog
mcs/mcs/class.cs
mcs/mcs/decl.cs
mcs/mcs/delegate.cs
mcs/mcs/symbolwriter.cs

index cc8ba29ebeb752d19b8b57b05847e5092cbdacd9..89e36bd3c01e9ec9df3bee01a41bc204a4dedbe5 100644 (file)
@@ -1,3 +1,9 @@
+2008-03-17  Marek Safar  <marek.safar@gmail.com>
+
+       * class.cs, decl.cs, delegate.cs: Do protected modifier check on each member
+       
+       * symbolwriter.cs: Fixed.
+
 2008-03-17  Marek Safar  <marek.safar@gmail.com>
 
        * anonymous.cs, driver.cs: Reset anonymous types counters.
index 9b520d4ff414b0dae504bfe089b9f5cddbb5650b..2435d31f3e352ae3c552385e996ca48e2fb1ea01 100644 (file)
@@ -1649,6 +1649,8 @@ namespace Mono.CSharp {
 
                public override bool Define ()
                {
+                       CheckProtectedModifier ();
+
                        if (compiler_generated != null) {
                                foreach (CompilerGeneratedClass c in compiler_generated) {
                                        if (!c.Define ())
@@ -2966,7 +2968,7 @@ namespace Mono.CSharp {
                                }
 
                                if ((m.ModFlags & Modifiers.PROTECTED) != 0) {
-                                       Report.Error (1057, m.Location, "`{0}': Static classes cannot contain protected members", m.GetSignatureForError ());
+                                       m.CheckProtectedModifier ();
                                        continue;
                                }
 
@@ -4822,16 +4824,9 @@ namespace Mono.CSharp {
                                                "Structs cannot contain explicit parameterless constructors");
                                        return false;
                                }
-
-                               if ((ModFlags & Modifiers.PROTECTED) != 0) {
-                                       Report.Error (666, Location, "`{0}': new protected member declared in struct", GetSignatureForError ());
-                                       return false;
-                               }
                        }
 
-                       if ((Parent.ModFlags & Modifiers.SEALED) != 0 && (ModFlags & Modifiers.PROTECTED) != 0) {
-                               Report.Warning (628, 4, Location, "`{0}': new protected member declared in sealed class", GetSignatureForError ());
-                       }
+                       CheckProtectedModifier ();
                        
                        return true;
                }
@@ -5519,18 +5514,9 @@ namespace Mono.CSharp {
 
                protected virtual bool CheckBase ()
                {
-                       if ((ModFlags & Modifiers.PROTECTED) != 0 && Parent.PartialContainer.Kind == Kind.Struct) {
-                               Report.Error (666, Location, "`{0}': new protected member declared in struct", GetSignatureForError ());
-                               return false;
-                       }
-   
-                       if (Report.WarningLevel >= 4 &&
-                           ((Parent.ModFlags & Modifiers.SEALED) != 0) &&
-                           ((ModFlags & Modifiers.PROTECTED) != 0) &&
-                           ((ModFlags & Modifiers.OVERRIDE) == 0) && (Name != "Finalize")) {
-                               Report.Warning (628, 4, Location, "`{0}': new protected member declared in sealed class", GetSignatureForError ());
-                       }
-                               return true;
+                       CheckProtectedModifier ();
+
+                       return true;
                }
 
                protected virtual bool DoDefine ()
index 04c1616f22c2c396315ef9e97bf77e214e696526..190a3988364ef564356516bd0e19903872c366d5 100644 (file)
@@ -167,7 +167,7 @@ namespace Mono.CSharp {
                public string FullName {
                        get {
                                if (TypeArguments != null)
-                                       return Name + "<" + TypeArguments + ">";
+                                       return Name + "<" + TypeArguments.ToString () + ">";
                                else
                                        return Name;
                        }
@@ -385,7 +385,32 @@ namespace Mono.CSharp {
                        }
 
                        return true;
-               }               
+               }
+
+               public void CheckProtectedModifier ()
+               {
+                       if ((ModFlags & Modifiers.PROTECTED) == 0)
+                               return;
+
+                       if (Parent.PartialContainer.Kind == Kind.Struct) {
+                               Report.Error (666, Location, "`{0}': Structs cannot contain protected members",
+                                       GetSignatureForError ());
+                               return;
+                       }
+
+                       if ((Parent.ModFlags & Modifiers.STATIC) != 0) {
+                               Report.Error (1057, Location, "`{0}': Static classes cannot contain protected members",
+                                       GetSignatureForError ());
+                               return;
+                       }
+
+                       if (((Parent.ModFlags & Modifiers.SEALED) != 0) &&
+                               ((ModFlags & Modifiers.OVERRIDE) == 0) && (Name != "Finalize")) {
+                               Report.Warning (628, 4, Location, "`{0}': new protected member declared in sealed class",
+                                       GetSignatureForError ());
+                               return;
+                       }
+               }
 
                public abstract bool Define ();
 
index 5e2c222095a86abcdd551aa05e25d8c8feb9fab3..393dd5ce15223a000620836760b8b16610e487a0 100644 (file)
@@ -227,6 +227,8 @@ namespace Mono.CSharp {
                                return false;
                        }
 
+                       CheckProtectedModifier ();
+
                        if (RootContext.StdLib && (ret_type == TypeManager.arg_iterator_type || ret_type == TypeManager.typed_reference_type)) {
                                Method.Error1599 (Location, ret_type);
                                return false;
index df9014613f41f38269ba40f6125a5b8e91666ac3..3d759a42fb30a7dcb62bec45af742acf35fad8c9 100644 (file)
@@ -23,7 +23,7 @@ namespace Mono.CSharp {
 
                private static SymbolWriterImpl symwriter;
 
-               protected class SymbolWriterImpl : MonoSymbolWriter {
+               class SymbolWriterImpl : MonoSymbolWriter {
                        delegate int GetILOffsetFunc (ILGenerator ig);
                        delegate Guid GetGuidFunc (ModuleBuilder mb);