2002-02-20 Ravi Pratap <ravi@ximian.com>
authorRavi Pratap M <ravi@mono-cvs.ximian.com>
Wed, 20 Feb 2002 23:03:57 +0000 (23:03 -0000)
committerRavi Pratap M <ravi@mono-cvs.ximian.com>
Wed, 20 Feb 2002 23:03:57 +0000 (23:03 -0000)
* decl.cs (CheckMethodAgainstBase): Do not allow overriding if
the parent implementation is sealed.

* ../errors/cs0239.cs : Add.

* attribute.cs (ApplyAttributes): Handle Modulebuilders too.

* typemanager.cs (unverifiable_code_type): Corresponds to
System.Security.UnverifiableCodeAttribute. We need to emit this for modules
which have unsafe code in them.

* rootcontext.cs (EmitCode): Emit the above attribute when we are in an
unsafe context.

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

mcs/mcs/ChangeLog
mcs/mcs/attribute.cs
mcs/mcs/decl.cs
mcs/mcs/rootcontext.cs
mcs/mcs/typemanager.cs

index fa6a0c6e3506559cb3e757d1191a9e7f57fbabe0..09165521aa25ced95ed0eb3ba42df4596d268e44 100755 (executable)
@@ -1,7 +1,22 @@
 2002-02-20  Ravi Pratap  <ravi@ximian.com>
 
        * expression.cs (Binary.ResolveOperator): Ensure that we are
-       not trying to operate on a void type - this fixes Dan's bug.
+       not trying to operate on a void type - this fixes the reported
+       bug.
+
+       * decl.cs (CheckMethodAgainstBase): Do not allow overriding if
+       the parent implementation is sealed.
+
+       * ../errors/cs0239.cs : Add.
+
+       * attribute.cs (ApplyAttributes): Handle Modulebuilders too.
+
+       * typemanager.cs (unverifiable_code_type): Corresponds to 
+       System.Security.UnverifiableCodeAttribute. We need to emit this for modules
+       which have unsafe code in them.
+
+       * rootcontext.cs (EmitCode): Emit the above attribute when we are in an 
+       unsafe context.
 
 2002-02-19  Miguel de Icaza  <miguel@ximian.com>
 
index 9bd0bc67f190a84361805d2249ce5e7ce2cfb48e..fdaf4d0789810dbc47004dfead0dc8f4e7c1361c 100644 (file)
@@ -476,6 +476,8 @@ namespace Mono.CSharp {
                                                \r
                                        } else if (kind is AssemblyBuilder){\r
                                                ((AssemblyBuilder) builder).SetCustomAttribute (cb);\r
+                                       } else if (kind is ModuleBuilder) {\r
+                                               ((ModuleBuilder) builder).SetCustomAttribute (cb);\r
                                        } else\r
                                                throw new Exception ("Unknown kind: " + kind);\r
                                }\r
index 813cc295c5666a6b93f5ca4d0837f1c95fd5fce5..012a246f161f78867b769cf192375255d8e3d649 100755 (executable)
@@ -72,11 +72,20 @@ namespace Mono.CSharp {
                                if (!(mb.IsAbstract || mb.IsVirtual)){
                                        Report.Error (
                                                506, Location, parent.MakeName (Name) +
-                                               ": cannot override inherited member `" +
-                                               mb.ReflectedType.Name + "' because it is not " +
+                                               ": cannot override inherited member " +
+                                               MethodBaseName (mb) + " because it is not " +
                                                "virtual, abstract or override");
                                        ok = false;
                                }
+                               
+                               // Now we check that the overriden method is not final
+                               
+                               if (mb.IsFinal) {
+                                       Report.Error (239, Location, parent.MakeName (Name) + " : cannot " +
+                                                     "override inherited member " + MethodBaseName (mb) +
+                                                     " because it is sealed.");
+                                       ok = false;
+                               }
                        }
 
                        if (mb.IsVirtual || mb.IsAbstract){
index db7b57d76db0249841feb1ee788e109ec4a63159..c3a6ac55f67c5ec1c4c2266c0222e69f7b7c65f1 100755 (executable)
@@ -378,6 +378,18 @@ namespace Mono.CSharp {
 
                                Attribute.ApplyAttributes (ec, ab, ab, global_attributes,
                                                           global_attributes.Location);
+                       } 
+
+                       if (Unsafe) {
+                               ConstructorInfo ci = TypeManager.unverifiable_code_type.GetConstructor (new Type [0]);
+                                       
+                               if (ci == null) {
+                                       Console.WriteLine ("Internal error !");
+                                       return;
+                               }
+                               
+                               CustomAttributeBuilder cb = new CustomAttributeBuilder (ci, new object [0]);
+                               mb.SetCustomAttribute (cb);
                        }
                }
                
index 7d18da7e637a521cd1631f428c35c2202dcfa161..4768be96e4e35eedd5cd17a7a58192514d23d9f4 100755 (executable)
@@ -55,6 +55,7 @@ public class TypeManager {
        static public Type runtime_field_handle_type;
        static public Type attribute_usage_type;
        static public Type dllimport_type;
+       static public Type unverifiable_code_type;
        static public Type methodimpl_attr_type;
        static public Type param_array_type;
        static public Type void_ptr_type;
@@ -423,6 +424,8 @@ public class TypeManager {
                methodimpl_attr_type = CoreLookupType ("System.Runtime.CompilerServices.MethodImplAttribute");
                param_array_type     = CoreLookupType ("System.ParamArrayAttribute");
 
+               unverifiable_code_type = CoreLookupType ("System.Security.UnverifiableCodeAttribute");
+
                void_ptr_type        = CoreLookupType ("System.Void*");
                
                //