2003-06-24 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Tue, 24 Jun 2003 23:25:44 +0000 (23:25 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 24 Jun 2003 23:25:44 +0000 (23:25 -0000)
* cs-parser.jay: Applied patch from Jackson that adds support for
extern and unsafe modifiers to destructor declarations.

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

mcs/mcs/ChangeLog
mcs/mcs/cs-parser.jay
mcs/mcs/driver.cs

index 82fd138c7e23f12d6305e3c33ade1f34fca5f428..580a5a6c527544d94d22d6b41b4e73f2b5af2563 100755 (executable)
@@ -1,5 +1,8 @@
 2003-06-24  Miguel de Icaza  <miguel@ximian.com>
 
+       * cs-parser.jay: Applied patch from Jackson that adds support for
+       extern and unsafe modifiers to destructor declarations.
+
        * expression.cs: Report error 21 if the user is trying to index a
        System.Array.
 
index 8d2bbf4e74315394661866ce982861f1e625c142..5ff68dbb48f285019f22e00261558605c7b755df 100755 (executable)
@@ -1,4 +1,5 @@
-%{
+
+        %{
 //
 // cs-parser.jay: The Parser for the C# compiler
 //
@@ -1487,27 +1488,41 @@ constructor_initializer
          }
        ;
 
+opt_finalizer
+        : /* EMPTY */           { $$ = 0; }
+        | UNSAFE               { $$ = Modifiers.UNSAFE; }
+       | EXTERN                { $$ = Modifiers.EXTERN; }
+        ;
+        
 destructor_declaration
-       : opt_attributes TILDE IDENTIFIER OPEN_PARENS CLOSE_PARENS block
+       : opt_attributes opt_finalizer TILDE IDENTIFIER OPEN_PARENS CLOSE_PARENS block
          {
-               if ((string) $3 != current_container.Basename){
+               if ((string) $4 != current_container.Basename){
                        Report.Error (574, lexer.Location, "Name of destructor must match name of class");
                } else if (!(current_container is Class)){
                        Report.Error (575, lexer.Location, "Destructors are only allowed in class types");
                } else {
                        Location l = lexer.Location;
 
-                       int m;
+                       int m = (int) $2;
                        if (!RootContext.StdLib && current_container.Name == "System.Object")
-                               m = Modifiers.PROTECTED | Modifiers.VIRTUAL;
+                               m |= Modifiers.PROTECTED | Modifiers.VIRTUAL;
                        else
-                               m = Modifiers.PROTECTED | Modifiers.OVERRIDE;
-
+                               m |= Modifiers.PROTECTED | Modifiers.OVERRIDE;
+                        
+                        if ((m & Modifiers.UNSAFE) != 0){
+                                if (!RootContext.Unsafe){
+                                        Report.Error (227, l,
+                                             "Unsafe code requires the --unsafe command " +
+                                             "line option to be specified");
+                                }
+                        }
+                        
                        Method d = new Method (
                                TypeManager.system_void_expr, m, "Finalize", 
                                new Parameters (null, null, l), (Attributes) $1, l);
                  
-                       d.Block = (Block) $6;
+                       d.Block = (Block) $7;
                        CheckDef (current_container.AddMethod (d), d.Name, d.Location);
                }
          }
index 8a17d923b480343471dfdd541295000b046bb834..06c13584db40ef4997b3547f3d7da6f3a728d034 100755 (executable)
@@ -1052,6 +1052,10 @@ namespace Mono.CSharp
                        case "/fullpaths":
                                return true;
 
+                       case "/win32icon":
+                               Report.Error (5, "/win32icon is currently not supported");
+                               return true;
+                               
                        case "/v2":
                                SetupV2 ();
                                return true;