Added target 'clean' so as make clean in the parent directory does not fail.
[mono.git] / mcs / mcs / modifiers.cs
index 781a6705bc11188dddb0bd009ed480154c73d510..a5ad3d3646e823006305d3a8f846ebc5fc59f19a 100755 (executable)
@@ -23,7 +23,9 @@ namespace Mono.CSharp {
                public const int VIRTUAL   = 0x0200;
                public const int OVERRIDE  = 0x0400;
                public const int EXTERN    = 0x0800;
-               public const int TOP       = 0x0800;
+               public const int VOLATILE  = 0x1000;
+               public const int UNSAFE    = 0x2000;
+               public const int TOP       = 0x2000;
 
                public const int Accessibility =
                        PUBLIC | PROTECTED | INTERNAL | PRIVATE;
@@ -57,6 +59,8 @@ namespace Mono.CSharp {
                                s = "override"; break;
                        case Modifiers.EXTERN:
                                s = "extern"; break;
+                       case Modifiers.VOLATILE:
+                               s = "volatile"; break;
                        }
 
                        return s;
@@ -66,7 +70,7 @@ namespace Mono.CSharp {
                {
                        TypeAttributes t = 0;
                        bool top_level = caller.IsTopLevel;
-                       
+
                        if (top_level){
                                if ((mod_flags & PUBLIC) != 0)
                                        t |= TypeAttributes.Public;
@@ -129,27 +133,34 @@ namespace Mono.CSharp {
                                ma |= MethodAttributes.Public;
                        if ((mod_flags & PRIVATE) != 0)
                                ma |= MethodAttributes.Private;
-                       if ((mod_flags & PROTECTED) != 0 && (mod_flags & INTERNAL) != 0)
-                               ma |= MethodAttributes.FamORAssem;
-                       if ((mod_flags & PROTECTED) != 0)
-                               ma |= MethodAttributes.Family;
-                       if ((mod_flags & INTERNAL) != 0)
-                               ma |= MethodAttributes.Assembly;
-                       
+                       if ((mod_flags & PROTECTED) != 0){
+                               if ((mod_flags & INTERNAL) != 0)
+                                       ma |= MethodAttributes.FamORAssem;
+                               else 
+                                       ma |= MethodAttributes.Family;
+                       } else {
+                               if ((mod_flags & INTERNAL) != 0)
+                                       ma |= MethodAttributes.Assembly;
+                       }
 
                        if ((mod_flags & STATIC) != 0)
                                ma |= MethodAttributes.Static;
                        if ((mod_flags & ABSTRACT) != 0){
                                ma |= MethodAttributes.Abstract | MethodAttributes.Virtual |
-                                       MethodAttributes.NewSlot;
+                                       MethodAttributes.HideBySig;
                        }
                        if ((mod_flags & SEALED) != 0)
                                ma |= MethodAttributes.Final;
+
                        if ((mod_flags & VIRTUAL) != 0)
                                ma |= MethodAttributes.Virtual;
 
                        if ((mod_flags & OVERRIDE) != 0)
-                               ma |= MethodAttributes.Virtual;
+                               ma |= MethodAttributes.Virtual | MethodAttributes.HideBySig;
+                       else {
+                               if ((ma & MethodAttributes.Virtual) != 0)
+                                       ma |= MethodAttributes.NewSlot;
+                       }
                        
                        if ((mod_flags & NEW) != 0)
                                ma |= MethodAttributes.HideBySig;
@@ -162,7 +173,7 @@ namespace Mono.CSharp {
                //   Returns the new mask.  Side effect: reports any
                //   incorrect attributes. 
                // </summary>
-               public static int Check (int allowed, int mod, int def_access)
+               public static int Check (int allowed, int mod, int def_access, Location l)
                {
                        int invalid_flags  = (~allowed) & mod;
                        int i;
@@ -170,6 +181,14 @@ namespace Mono.CSharp {
                        if (invalid_flags == 0){
                                int a = mod;
 
+                               if ((mod & Modifiers.UNSAFE) != 0){
+                                       if (!RootContext.Unsafe){
+                                               Report.Error (227, l,
+                                                             "Unsafe code requires the --unsafe command " +
+                                                             "line option to be specified");
+                                       }
+                               }
+                               
                                //
                                // If no accessibility bits provided
                                // then provide the defaults.
@@ -190,7 +209,7 @@ namespace Mono.CSharp {
                                a = ((a & 2) >> 1) + (a & 5);
                                a = ((a & 4) >> 2) + (a & 3);
                                if (a > 1)
-                                       CSharpParser.error (107, "More than one protection modifier specified");
+                                       Report.Error (107, l, "More than one protection modifier specified");
                                
                                return mod;
                        }
@@ -199,7 +218,8 @@ namespace Mono.CSharp {
                                if ((i & invalid_flags) == 0)
                                        continue;
 
-                               CSharpParser.error (106, "the modifier `" + Name (i) + "' is not valid for this item");
+                               Report.Error (106, l, "the modifier `" + Name (i) +
+                                             "' is not valid for this item");
                        }
 
                        return allowed & mod;