Fix warning.
[mono.git] / mcs / gmcs / driver.cs
index eaea1af2101c1427060d659cbeacd20ef4a9c408..63d95d355c1fca7c30265f44e6ea8c372a90ff5b 100644 (file)
@@ -94,7 +94,7 @@ namespace Mono.CSharp
                //
                // Encoding.
                //
-               static Encoding defaultEncoding;
+               static Encoding default_encoding;
                static Encoding encoding;
 
                static public void Reset ()
@@ -109,7 +109,7 @@ namespace Mono.CSharp
                        win32ResourceFile = win32IconFile = null;
                        defines = null;
                        output_file = null;
-                       encoding = defaultEncoding = null;
+                       encoding = default_encoding = null;
                        first_source = null;
                }
 
@@ -279,9 +279,11 @@ namespace Mono.CSharp
 
                public static int counter1, counter2;
                
-       public static int Main (string[] args)
+               public static int Main (string[] args)
                {
                        RootContext.Version = LanguageVersion.Default;
+                       Location.InEmacs = Environment.GetEnvironmentVariable ("EMACS") == "t";
+
                        bool ok = MainDriver (args);
                        
                        if (ok && Report.Errors == 0) {
@@ -1305,12 +1307,12 @@ namespace Mono.CSharp
                                        encoding = new UTF8Encoding();
                                        break;
                                case "reset":
-                                       encoding = defaultEncoding;
+                                       encoding = default_encoding;
                                        break;
                                default:
                                        try {
                                                encoding = Encoding.GetEncoding (
-                                                       Int32.Parse (value));
+                                               Int32.Parse (value));
                                        } catch {
                                                Report.Error (2016, "Code page `{0}' is invalid or not installed", value);
                                        }
@@ -1318,11 +1320,15 @@ namespace Mono.CSharp
                                }
                                return true;
                        }
-                       //Report.Error (2007, String.Format ("Unrecognized command-line option: `{0}'", option));
-                       //Environment.Exit (1);
+
                        return false;
                }
                
+               static void Error_WrongOption (string option)
+               {
+                       Report.Error (2007, "Unrecognized command-line option: `{0}'", option);
+               }
+
                static string [] AddArgs (string [] args, string [] extra_args)
                {
                        string [] new_args;
@@ -1364,12 +1370,12 @@ namespace Mono.CSharp
 
                        try {
                                // Latin1
-                               defaultEncoding = Encoding.GetEncoding (28591);
+                               default_encoding = Encoding.GetEncoding (28591);
                        } catch (Exception) {
                                // iso-8859-1
-                               defaultEncoding = Encoding.GetEncoding (1252);
+                               default_encoding = Encoding.GetEncoding (1252);
                        }
-                       encoding = defaultEncoding;
+                       encoding = default_encoding;
 
                        references = new ArrayList ();
                        soft_references = new ArrayList ();
@@ -1433,10 +1439,19 @@ namespace Mono.CSharp
                                                string csc_opt = "/" + arg.Substring (1);
                                                if (CSCParseOption (csc_opt, ref args, ref i))
                                                        continue;
+
+                                               Error_WrongOption (arg);
+                                               return false;
                                        } else {
-                                               if (arg.StartsWith ("/")){
+                                               if (arg [0] == '/'){
                                                        if (CSCParseOption (arg, ref args, ref i))
                                                                continue;
+
+                                                       // Need to skip `/home/test.cs' however /test.cs is considered as error
+                                                       if (arg.Length < 2 || arg.IndexOf ('/', 2) == -1) {
+                                                               Error_WrongOption (arg);
+                                                               return false;
+                                                       }
                                                }
                                        }
                                }
@@ -1608,7 +1623,6 @@ namespace Mono.CSharp
                                if (CodeGen.Assembly.IsClsCompliant) {
                                AttributeTester.VerifyModulesClsCompliance ();
                                TypeManager.LoadAllImportedTypes ();
-                                       AttributeTester.VerifyTopLevelNameClsCompliance ();
                                }
                        }
                        if (Report.Errors > 0)
@@ -1650,7 +1664,7 @@ namespace Mono.CSharp
 
                                if (ep == null) {
                                        if (RootContext.MainClass != null) {
-                                               DeclSpace main_cont = RootContext.Tree.GetDecl (MemberName.FromDotted (RootContext.MainClass));
+                                               DeclSpace main_cont = RootContext.Tree.GetDecl (MemberName.FromDotted (RootContext.MainClass, Location.Null));
                                                if (main_cont == null) {
                                                        Report.Error (1555, "Could not find `{0}' specified for Main method", RootContext.MainClass); 
                                                        return false;