//
Encoding encoding;
+ static readonly char[] argument_value_separator = new char [] { ';', ',' };
+
static public void Reset ()
{
embedded_resources = null;
Console.WriteLine (
"Mono C# compiler, Copyright 2001 - 2008 Novell, Inc.\n" +
"mcs [options] source-files\n" +
- " --about About the Mono C# compiler\n" +
- " -addmodule:M1[,Mn] Adds the module to the generated assembly\n" +
- " -checked[+|-] Sets default aritmetic overflow context\n" +
- " -codepage:ID Sets code page to the one in ID (number, utf8, reset)\n" +
- " -clscheck[+|-] Disables CLS Compliance verifications\n" +
- " -define:S1[;S2] Defines one or more conditional symbols (short: -d)\n" +
- " -debug[+|-], -g Generate debugging information\n" +
- " -delaysign[+|-] Only insert the public key into the assembly (no signing)\n" +
- " -doc:FILE Process documentation comments to XML file\n" +
- " -help Lists all compiler options (short: -?)\n" +
- " -keycontainer:NAME The key pair container used to sign the output assembly\n" +
- " -keyfile:FILE The key file used to strongname the ouput assembly\n" +
- " -langversion:TEXT Specifies language version modes: ISO-1, ISO-2, or Default\n" +
- " -lib:PATH1[,PATHn] Specifies the location of referenced assemblies\n" +
- " -main:CLASS Specifies the class with the Main method (short: -m)\n" +
- " -noconfig Disables implicitly referenced assemblies\n" +
- " -nostdlib[+|-] Does not reference mscorlib.dll library\n" +
- " -nowarn:W1[,Wn] Suppress one or more compiler warnings\n" +
- " -optimize[+|-] Enables advanced compiler optimizations (short: -o)\n" +
- " -out:FILE Specifies output assembly name\n" +
+ " --about About the Mono C# compiler\n" +
+ " -addmodule:M1[,Mn] Adds the module to the generated assembly\n" +
+ " -checked[+|-] Sets default aritmetic overflow context\n" +
+ " -codepage:ID Sets code page to the one in ID (number, utf8, reset)\n" +
+ " -clscheck[+|-] Disables CLS Compliance verifications\n" +
+ " -define:S1[;S2] Defines one or more conditional symbols (short: -d)\n" +
+ " -debug[+|-], -g Generate debugging information\n" +
+ " -delaysign[+|-] Only insert the public key into the assembly (no signing)\n" +
+ " -doc:FILE Process documentation comments to XML file\n" +
+ " -help Lists all compiler options (short: -?)\n" +
+ " -keycontainer:NAME The key pair container used to sign the output assembly\n" +
+ " -keyfile:FILE The key file used to strongname the ouput assembly\n" +
+ " -langversion:TEXT Specifies language version modes: ISO-1, ISO-2, or Default\n" +
+ " -lib:PATH1[,PATHn] Specifies the location of referenced assemblies\n" +
+ " -main:CLASS Specifies the class with the Main method (short: -m)\n" +
+ " -noconfig Disables implicitly referenced assemblies\n" +
+ " -nostdlib[+|-] Does not reference mscorlib.dll library\n" +
+ " -nowarn:W1[,Wn] Suppress one or more compiler warnings\n" +
+ " -optimize[+|-] Enables advanced compiler optimizations (short: -o)\n" +
+ " -out:FILE Specifies output assembly name\n" +
#if !SMCS_SOURCE
- " -pkg:P1[,Pn] References packages P1..Pn\n" +
+ " -pkg:P1[,Pn] References packages P1..Pn\n" +
#endif
- " -recurse:SPEC Recursively compiles files according to SPEC pattern\n" +
- " -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" +
- " -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" +
- " -target:KIND Specifies the format of the output assembly (short: -t)\n" +
- " KIND can be one of: exe, winexe, library, module\n" +
- " -unsafe[+|-] Allows to compile code which uses unsafe keyword\n" +
- " -warnaserror[+|-] Treats all warnings as errors\n" +
- " -warn:0-4 Sets warning level, the default is 4 (short -w:)\n" +
- " -help2 Shows internal compiler options\n" +
+ " -recurse:SPEC Recursively compiles files according to SPEC pattern\n" +
+ " -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" +
+ " -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" +
+ " -target:KIND Specifies the format of the output assembly (short: -t)\n" +
+ " KIND can be one of: exe, winexe, library, module\n" +
+ " -unsafe[+|-] Allows to compile code which uses unsafe keyword\n" +
+ " -warnaserror[+|-] Treats all warnings as errors\n" +
+ " -warnaserror:W1[,Wn] Treats one or more compiler warnings as errors\n" +
+ " -warn:0-4 Sets warning level, the default is 4 (short -w:)\n" +
+ " -help2 Shows internal compiler options\n" +
"\n" +
"Resources:\n" +
" -linkresource:FILE[,ID] Links FILE as a resource (short: -linkres)\n" +
Environment.Exit (1);
}
- foreach (string d in value.Split (';', ',')){
+ foreach (string d in value.Split (argument_value_separator)) {
if (!Tokenizer.IsValidIdentifier (d)) {
Report.Warning (2029, 1, "Invalid conditional define symbol `{0}'", d);
continue;
embedded_resources = new Resources ();
bool embeded = arg.StartsWith ("/r");
- string[] s = value.Split (',');
+ string[] s = value.Split (argument_value_separator);
switch (s.Length) {
case 1:
if (s[0].Length == 0)
Environment.Exit (1);
}
- string [] refs = value.Split (new char [] { ';', ',' });
+ string[] refs = value.Split (argument_value_separator);
foreach (string r in refs){
string val = r;
int index = val.IndexOf ('=');
Environment.Exit (1);
}
- string [] refs = value.Split (new char [] { ';', ',' });
+ string[] refs = value.Split (argument_value_separator);
foreach (string r in refs){
modules.Add (r);
}
Environment.Exit (1);
}
- libdirs = value.Split (new Char [] { ',' });
+ libdirs = value.Split (argument_value_separator);
foreach (string dir in libdirs)
link_paths.Add (dir);
return true;
return true;
case "/warnaserror":
+ if (value.Length == 0) {
+ Report.WarningsAreErrors = true;
+ } else {
+ foreach (string wid in value.Split (argument_value_separator))
+ Report.AddWarningAsError (wid);
+ }
+ return true;
+
case "/warnaserror+":
Report.WarningsAreErrors = true;
return true;
Report.Error (5, "/nowarn requires an argument");
Environment.Exit (1);
}
-
- warns = value.Split (new Char [] {','});
+
+ warns = value.Split (argument_value_separator);
foreach (string wc in warns){
try {
int warn = Int32.Parse (wc);
/// Whether warnings should be considered errors
/// </summary>
static public bool WarningsAreErrors;
-
+ static ArrayList warnings_as_error;
/// <summary>
/// Whether to dump a stack trace on errors.
warning_regions_table = null;
reporting_disabled = false;
error_stack = warning_stack = null;
+ warnings_as_error = null;
}
public static void DisableReporting ()
return regions.IsWarningEnabled (code, location.Row);
}
+ bool IsErrorWarning {
+ get {
+ if (WarningsAreErrors)
+ return true;
+
+ if (warnings_as_error == null)
+ return false;
+
+ return warnings_as_error.Contains (code);
+ }
+ }
+
public override void Print ()
{
if (!IsEnabled ())
return;
- if (WarningsAreErrors) {
+ if (IsErrorWarning) {
new ErrorMessage (this).Print ();
return;
}
Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
}
- public static bool IsValidWarning (int code)
+ static bool IsValidWarning (int code)
{
return Array.BinarySearch (AllWarnings, code) >= 0;
}
extra_information.Add (msg);
}
+ public static void AddWarningAsError (string warningId)
+ {
+ int id;
+ try {
+ id = int.Parse (warningId);
+ } catch {
+ id = -1;
+ }
+
+ if (!CheckWarningCode (id, warningId, Location.Null))
+ return;
+
+ if (warnings_as_error == null)
+ warnings_as_error = new ArrayList ();
+
+ warnings_as_error.Add (id);
+ }
+
+ public static bool CheckWarningCode (int code, Location loc)
+ {
+ return CheckWarningCode (code, code.ToString (), loc);
+ }
+
+ public static bool CheckWarningCode (int code, string scode, Location loc)
+ {
+ if (IsValidWarning (code))
+ return true;
+
+ Report.Warning (1691, 1, loc, "`{0}' is not a valid warning number", scode);
+ return false;
+ }
+
public static void ExtraInformation (Location loc, string msg)
{
extra_information.Add (String.Format ("{0} {1}", loc, msg));
public void WarningDisable (Location location, int code)
{
- if (CheckWarningCode (code, location))
+ if (Report.CheckWarningCode (code, location))
regions.Add (new Disable (location.Row, code));
}
public void WarningEnable (Location location, int code)
{
- if (CheckWarningCode (code, location))
+ if (Report.CheckWarningCode (code, location))
regions.Add (new Enable (location.Row, code));
}
}
return result;
}
-
- static bool CheckWarningCode (int code, Location loc)
- {
- if (Report.IsValidWarning (code))
- return true;
-
- Report.Warning (1691, 1, loc, "`{0}' is not a valid warning number", code.ToString ());
- return false;
- }
}
}