On Tue, 25 Jun 2002, Andrew Birkett wrote:
> One problem: I created a new file at mcs/errors/ChangeLog but I can't get
> it to be in my patch since I can't "cvs add" it without write permission
> on the CVS server. So, I've attached it seperately to this mail. It
> should be added as 'errors/ChangeLog'.
I've just checked the patch on a windows box, and there's two changes to
make it work: Change the TODO attribute in driver.cs to a // TODO
comment, and remove the unreferenced variable which csc complains about.
These are obvious once you apply the patch and try to build mcs. I do all
my development on my home linux box, and can only check stuff on windows
during the day at work!
I've included a revised patch with this email to simplify things.
Andrew
- www.tardis.ed.ac.uk/~adb -
? patch
? class/corlib/Test/StreamWriterTest.temp
? errors/ChangeLog
? errors/cs1021.cs
? mcs/a
Index: errors/cs0176.cs
===================================================================
RCS file: /mono/mcs/errors/cs0176.cs,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 cs0176.cs
--- errors/cs0176.cs 8 Jun 2001 18:45:35 -0000 1.1.1.1
+++ errors/cs0176.cs 25 Jun 2002 13:58:25 -0000
@@ -1,7 +1,7 @@
// cs0176.cs: cannot be accessed with an instance reference, use typename instead
// Line: 12
class X {
- static void void_method ()
+ public static void void_method ()
{
}
}
Index: errors/cs0196.cs
===================================================================
RCS file: /mono/mcs/errors/cs0196.cs,v
retrieving revision 1.1
diff -u -r1.1 cs0196.cs
--- errors/cs0196.cs 21 Feb 2002 02:35:01 -0000 1.1
+++ errors/cs0196.cs 25 Jun 2002 13:58:25 -0000
@@ -6,6 +6,6 @@
int *p = null;
if (p [10,4] == 4)
- ;
+ return;
}
}
Index: errors/cs0242.cs
===================================================================
RCS file: /mono/mcs/errors/cs0242.cs,v
retrieving revision 1.1
diff -u -r1.1 cs0242.cs
--- errors/cs0242.cs 21 Feb 2002 02:35:01 -0000 1.1
+++ errors/cs0242.cs 25 Jun 2002 13:58:25 -0000
@@ -6,6 +6,6 @@
void *p = null;
if (p [10] == 4)
- ;
+ return;
}
}
Index: errors/cs0255.cs
===================================================================
RCS file: /mono/mcs/errors/cs0255.cs,v
retrieving revision 1.1
diff -u -r1.1 cs0255.cs
--- errors/cs0255.cs 21 Feb 2002 18:58:37 -0000 1.1
+++ errors/cs0255.cs 25 Jun 2002 13:58:25 -0000
@@ -1,13 +1,13 @@
// cs0255.cs: Can not use stackalloc in finally or catch
// Line: 10
unsafe class X {
- string s;
static void Main ()
{
try {
} catch {
- char *ptr = stackalloc char [10U];
-}
+ char *ptr = stackalloc char [10];
+ ptr = ptr;
+ }
}
}
Index: errors/fail
===================================================================
RCS file: /mono/mcs/errors/fail,v
retrieving revision 1.3
diff -u -r1.3 fail
--- errors/fail 19 Jan 2002 04:27:34 -0000 1.3
+++ errors/fail 25 Jun 2002 13:58:25 -0000
@@ -1,53 +1,30 @@
The following tests failed:
-cs0051.cs, cs0060.cs, cs0111.cs
-
+cs0051.cs: We don't complain about inconsistent accessibility.
+cs0060.cs: We don't complain about inconsistent accessibility.
cs0108.cs: We should re-enable the test code in the compiler
cs0110.cs: Stack overflow in the compiler
-
-cs0118.cs:
- We report the error, but the CSC error gives more information.
-
-cs0121.cs: Function deambiguator does not work here
-cs0136-2.cs cs0136.cs: Similar error reported (reuse of variable name, 128)
-cs0157.cs: Internal compiler error (null pointer reference)
+cs0111.cs: We don't complain about second occurance of method definition.
+cs0118.cs: We report the error, but the CSC error gives more information.
+cs0136.cs: Similar error reported (reuse of variable name, 128)
+cs0136-2.cs: Similar error reported (reuse of variable name, 128)
cs0164.cs: We dont emit the warning for an unused label
-cs0165-2.cs cs0165.cs:
- We need data flow analysis
-
-cs0171.cs
- We do not track unassigned struct fields on struct constructors
-
-cs0216.cs:
- We do not report missing operators.
-
-cs0234.cs:
- Will be hard to fix;
-
-cs0654.cs:
- Compiler crash
-
-cs1001.cs:
- Compiler emits syntax error; Its ok.
-
- Compiler crashes
-cs1501.cs:
- Compiler crashes. Easy to fix
-
-cs1513.cs:
- Syntax error; We could provide better message
-
-cs1518.cs:
- Syntax error; We could provide better message
-
-cs1525.cs:
- Syntax error; We could provide better message
-
-cs1528.cs:
- Syntax error; We could provide better message
-
-cs1529.cs:
- Syntax error; We could provide better message
+cs0165.cs: We need data flow analysis
+cs0165-2.cs: We need data flow analysis
+cs0171.cs: We do not track unassigned struct fields on struct constructors
+cs0216.cs: We do not report missing operators.
+cs0234.cs: Will be hard to fix;
+cs0255.cs: Error isn't flagged.
+cs0523.cs: Error isn't flagged.
+cs0529.cs: We get error CS0146 instead
+cs0654.cs: Compiler crash
+cs1001.cs: Compiler emits syntax error; Its ok.
+cs1513.cs: Syntax error; We could provide better message
+cs1518.cs: Syntax error; We could provide better message
+cs1525.cs: Syntax error; We could provide better message
+cs1528.cs: Syntax error; We could provide better message
+cs1529.cs: Syntax error; We could provide better message
+cs1552.cs: Syntax error; We could provide better message
+cs1604.cs: Error isn't flagged.
+cs-20.cs: Attribute error isn't flagged
-cs1552.cs:
- Syntax error; We could provide better message
Index: errors/makefile
===================================================================
RCS file: /mono/mcs/errors/makefile,v
retrieving revision 1.4
diff -u -r1.4 makefile
--- errors/makefile 18 Jan 2002 02:09:53 -0000 1.4
+++ errors/makefile 25 Jun 2002 13:58:25 -0000
@@ -1,10 +1,12 @@
#
# Compile at the maximum warning level to probe for warnings
#
-MCS=../mcs/mcs.exe --wlevel 4
+#MCS=mono ../mcs/mcs.exe --wlevel 4 # for linux
+MCS=../mcs/mcs.exe --wlevel 4 # for windows
+
all:
- failed=false; \
+ @ failed=false; \
for i in cs*.cs; do \
case $$i in \
cs[0-9]*-[0-9]*cs) \
@@ -14,20 +16,12 @@
error=`echo $$i | sed -e 's/cs*//' -e 's/.cs//'`; \
;;\
esac; \
- echo $(MCS) --probe $$error $$i; \
- $(MCS) --probe $$error 1 $$i > /dev/null; \
- code=$$?; \
- if test $$code != 123; then \
- echo Code is: $$code; \
- if [ x$$code = x124 ]; then \
- echo "Compiler failed to flag $$i"; \
- else \
- echo "Compiler failed to compile $$i"; \
- fi; \
- flist="$$flist $$i"; \
- failed=true; \
- else \
- echo test $$i ok; \
+ echo -n "Running test $$i ... "; \
+ if $(MCS) --unsafe --expect-error $$error $$i > /dev/null; \
+ then echo OK; \
+ else echo FAILED; \
+ flist="$$flist $$i"; \
+ failed=true; \
fi; \
done; \
if $$failed; then \
Index: mbas/mb-parser.jay
===================================================================
RCS file: /mono/mcs/mbas/mb-parser.jay,v
retrieving revision 1.5
diff -u -r1.5 mb-parser.jay
--- mbas/mb-parser.jay 8 Jun 2002 15:34:46 -0000 1.5
+++ mbas/mb-parser.jay 25 Jun 2002 13:58:25 -0000
@@ -482,7 +482,7 @@
}
}
-public override int parse ()
+public override void parse ()
{
current_namespace = new Namespace (null, "");
current_container = RootContext.Tree.Types;
@@ -493,7 +493,6 @@
lexer = new Tokenizer (input, name, defines);
StringBuilder value = new StringBuilder ();
- global_errors = 0;
try
{
if (yacc_verbose_flag)
@@ -505,10 +504,7 @@
{
Console.WriteLine (lexer.location + " : Parsing error ");
Console.WriteLine (e);
- global_errors++;
}
-
- return global_errors;
}
/* end end end */
Index: mcs/ChangeLog
===================================================================
RCS file: /mono/mcs/mcs/ChangeLog,v
retrieving revision 1.529
diff -u -r1.529 ChangeLog
--- mcs/ChangeLog 22 Jun 2002 19:36:32 -0000 1.529
+++ mcs/ChangeLog 25 Jun 2002 13:58:27 -0000
@@ -1,3 +1,29 @@
+2002-06-25 Andrew Birkett <[EMAIL PROTECTED]>
+
+ * driver.cs: Made error handling more consistent. Errors now
+ tracked by Report class, so many methods which used to return int
+ now return void. Main() now prints success/failure and
+ errors/warnings message.
+
+ Renamed '--probe' compiler argument to '--expect-error'. Removed
+ the magic number return values (123 and 124). Now, if the
+ expected error occurs, the compiler exits with success (exit value
+ 0). If the compilation completes without seeing that particular
+ error, the compiler exits with failure (exit value 1). The
+ makefile in mcs/errors has been changed to handle the new behaviour.
+
+ * report.cs: Made 'expected error' number a property and renamed
+ it from 'Probe' to 'ExpectedError'.
+
+ * genericparser.cs: Removed error handling support, since it is
+ now all done by Report class.
+
+ * cs-parser.jay, mb-parser.jay: Errors are tracked by Report
+ class, so parse() no longer returns an int.
+
+ * namespace.cs: Use Report.Error instead of GenericParser.error
+
+
2002-06-22 Miguel de Icaza <[EMAIL PROTECTED]>
* class.cs (TypeContainer.AddMethod, TypeContainer.AddIndexer,
Index: mcs/cs-parser.jay
===================================================================
RCS file: /mono/mcs/mcs/cs-parser.jay,v
retrieving revision 1.178
diff -u -r1.178 cs-parser.jay
--- mcs/cs-parser.jay 20 Jun 2002 12:21:43 -0000 1.178
+++ mcs/cs-parser.jay 25 Jun 2002 13:58:28 -0000
@@ -3933,28 +3933,20 @@
lexer = new Tokenizer (input, name, defines);
}
-public override int parse ()
+public override void parse ()
{
- global_errors = 0;
try {
if (yacc_verbose_flag)
yyparse (lexer, new yydebug.yyDebugSimple ());
else
yyparse (lexer);
} catch (Exception e){
- // Console.WriteLine ("Fatal error: " + name);
- // Console.WriteLine (lexer.location);
-
- //
// Please do not remove this, it is used during debugging
// of the grammar
//
Console.WriteLine (lexer.location + " : Parsing error ");
Console.WriteLine (e);
- global_errors++;
}
-
- return global_errors;
}
/* end end end */
Index: mcs/driver.cs
===================================================================
RCS file: /mono/mcs/mcs/driver.cs,v
retrieving revision 1.92
diff -u -r1.92 driver.cs
--- mcs/driver.cs 13 Jun 2002 00:16:03 -0000 1.92
+++ mcs/driver.cs 25 Jun 2002 13:58:28 -0000
@@ -49,8 +49,6 @@
// Whether we want to only run the tokenizer
static bool tokenize = false;
- static int error_count = 0;
-
static string first_source;
static Target target = Target.Exe;
@@ -95,16 +93,15 @@
(int) span.TotalSeconds, span.Milliseconds, msg);
}
- static int tokenize_file (string input_file)
+ static void tokenize_file (string input_file)
{
Stream input;
try {
input = File.OpenRead (input_file);
-
} catch {
Report.Error (2001, "Source file '" + input_file + "'
could not be opened");
- return 1;
+ return;
}
using (input){
@@ -120,72 +117,66 @@
Console.WriteLine ("Tokenized: " + tokens + " found "
+ errors + " errors");
}
- return 0;
+ return;
}
-
- static int parse (string input_file)
+
+ // MonoTODO("Change error code for aborted compilation to something
+reasonable")]
+ static void parse (string input_file)
{
CSharpParser parser;
Stream input;
- int errors;
try {
input = File.OpenRead (input_file);
} catch {
Report.Error (2001, "Source file '" + input_file + "'
could not be opened");
- return 1;
+ return;
}
parser = new CSharpParser (input_file, input, defines);
parser.yacc_verbose = yacc_verbose;
try {
- errors = parser.parse ();
+ parser.parse ();
} catch (Exception ex) {
- Console.WriteLine (ex);
- Console.WriteLine ("Compilation aborted");
- return 1;
+ Report.Error(666, "Compilation aborted: " + ex);
} finally {
input.Close ();
}
-
- return errors;
}
- static void Usage (bool is_error)
+ static void Usage ()
{
Console.WriteLine (
"Mono C# compiler, (C) 2001 Ximian, Inc.\n" +
"mcs [options] source-files\n" +
- " --about About the Mono C# compiler\n" +
- " --checked Set default context to checked\n"
+
- " --define SYM Defines the symbol SYM\n" +
- " --debug Generate debugging information\n"
+
- " -g Generate debugging information\n"
+
- " --debug-args X Specify additional arguments for
the\n" +
- " symbol writer.\n" +
- " --fatal Makes errors fatal\n" +
- " -L PATH Adds PATH to the assembly link
path\n" +
- " --noconfig Disables implicit references to
assemblies\n" +
- " --nostdlib Does not load core libraries\n" +
- " --nowarn XXX Ignores warning number XXX\n" +
- " -o FNAME Specifies output file\n" +
- " -g, --debug Write symbolic debugging
information to FILE-debug.s\n" +
- " --parse Only parses the source file\n" +
- " --probe X Probes for the source to generate
code X on line L\n" +
- " --recurse SPEC Recursively compiles the files in
SPEC ([dir]/file)\n" +
- " --resource FILE Addds FILE as a resource\n" +
- " --stacktrace Shows stack trace at error
location\n" +
- " --target KIND Specifies the target (KIND is one
of: exe, winexe, " +
- "library, module)\n" +
- " --timestamp Displays time stamps of various
compiler events\n" +
- " --unsafe Allows unsafe code\n" +
- " --werror Treat warnings as errors\n" +
- " --wlevel LEVEL Sets warning level (the highest is
4, the default)\n" +
- " -r References an assembly\n" +
- " -v Verbose parsing (for debugging the
parser)\n" +
- " @file Read response file for more
options");
- if (is_error)
- error_count++;
+ " --about About the Mono C# compiler\n" +
+ " --checked Set default context to checked\n"
++
+ " --define SYM Defines the symbol SYM\n" +
+ " --debug Generate debugging information\n"
++
+ " -g Generate debugging information\n"
++
+ " --debug-args X Specify additional arguments for
+the\n" +
+ " symbol writer.\n" +
+ " --fatal Makes errors fatal\n" +
+ " -L PATH Adds PATH to the assembly link
+path\n" +
+ " --noconfig Disables implicit references to
+assemblies\n" +
+ " --nostdlib Does not load core libraries\n" +
+ " --nowarn XXX Ignores warning number XXX\n" +
+ " -o FNAME Specifies output file\n" +
+ " -g, --debug Write symbolic debugging
+information to FILE-debug.s\n" +
+ " --parse Only parses the source file\n" +
+ " --expect-error X Expect that error X will be
+encountered\n" +
+ " --recurse SPEC Recursively compiles the files in
+SPEC ([dir]/file)\n" +
+ " --resource FILE Addds FILE as a resource\n" +
+ " --stacktrace Shows stack trace at error
+location\n" +
+ " --target KIND Specifies the target (KIND is one
+of: exe, winexe, " +
+ "library, module)\n" +
+ " --timestamp Displays time stamps of various
+compiler events\n" +
+ " --unsafe Allows unsafe code\n" +
+ " --werror Treat warnings as errors\n" +
+ " --wlevel LEVEL Sets warning level (the highest
+is 4, the default)\n" +
+ " -r References an assembly\n" +
+ " -v Verbose parsing (for debugging
+the parser)\n" +
+ " @file Read response file for more
+options");
}
static void About ()
@@ -200,27 +191,25 @@
"The compiler was written by Miguel de Icaza and Ravi
Pratap");
}
- static void error (string msg)
- {
- Console.WriteLine ("Error: " + msg);
- }
-
- static void notice (string msg)
- {
- Console.WriteLine (msg);
- }
-
public static int Main (string[] args)
{
- //args = new string [1];
- //args [0] = "@list";
+ bool ok = MainDriver (args);
- MainDriver (args);
-
- return (error_count + Report.Errors) != 0 ? 1 : 0;
+ if (ok && Report.Errors == 0) {
+ Console.Write("Compilation succeeded");
+ if (Report.Warnings > 0) {
+ Console.Write(" - {0} warning(s)",
+Report.Warnings);
+ }
+ Console.WriteLine();
+ return 0;
+ } else {
+ Console.WriteLine("Compilation failed: {0} error(s),
+{1} warnings",
+ Report.Errors, Report.Warnings);
+ return 1;
+ }
}
- static public int LoadAssembly (string assembly, bool soft)
+ static public void LoadAssembly (string assembly, bool soft)
{
Assembly a;
string total_log = "";
@@ -228,12 +217,13 @@
try {
char[] path_chars = { '/', '\\', '.' };
- if (assembly.IndexOfAny (path_chars) != -1)
+ if (assembly.IndexOfAny (path_chars) != -1) {
a = Assembly.LoadFrom (assembly);
- else
+ } else {
a = Assembly.Load (assembly);
+ }
TypeManager.AddAssembly (a);
- return 0;
+
} catch (FileNotFoundException){
foreach (string dir in link_paths){
string full_path = dir + "/" + assembly +
".dll";
@@ -241,47 +231,37 @@
try {
a = Assembly.LoadFrom (full_path);
TypeManager.AddAssembly (a);
- return 0;
+ return;
} catch (FileNotFoundException ff) {
total_log += ff.FusionLog;
continue;
}
}
- if (soft)
- return 0;
+ if (!soft) {
+ Report.Error (6, "Cannot find assembly `" +
+assembly + "'" );
+ Console.WriteLine ("Log: \n" + total_log);
+ }
} catch (BadImageFormatException f) {
- error ("// Bad file format while loading assembly");
- error ("Log: " + f.FusionLog);
- return 1;
+ Report.Error(6, "Cannot load assembly (bad file
+format)" + f.FusionLog);
} catch (FileLoadException f){
- error ("File Load Exception: " + assembly);
- error ("Log: " + f.FusionLog);
- return 1;
+ Report.Error(6, "Cannot load assembly " +
+f.FusionLog);
} catch (ArgumentNullException){
- error ("// Argument Null exception ");
- return 1;
+ Report.Error(6, "Cannot load assembly (null
+argument)");
}
-
- Report.Error (6, "Can not find assembly `" + assembly + "'" );
- Console.WriteLine ("Log: \n" + total_log);
-
- return 0;
}
/// <summary>
/// Loads all assemblies referenced on the command line
/// </summary>
- static public int LoadReferences ()
+ static public void LoadReferences ()
{
- int errors = 0;
-
foreach (string r in references)
- errors += LoadAssembly (r, false);
+ LoadAssembly (r, false);
foreach (string r in soft_references)
- errors += LoadAssembly (r, true);
+ LoadAssembly (r, true);
- return errors;
+ return;
}
static void SetupDefaultDefines ()
@@ -364,7 +344,7 @@
pattern = spec;
}
- static int ProcessFile (string f)
+ static void ProcessFile (string f)
{
if (first_source == null)
first_source = f;
@@ -377,21 +357,21 @@
} else
source_files.Add (f, f);
- if (tokenize)
+ if (tokenize) {
tokenize_file (f);
- else
- return parse (f);
- return 0;
+ } else {
+ parse (f);
+ }
}
- static int CompileFiles (string spec, bool recurse)
+ static void CompileFiles (string spec, bool recurse)
{
string path, pattern;
- int errors = 0;
SplitPathAndPattern (spec, out path, out pattern);
if (pattern.IndexOf ("*") == -1){
- return ProcessFile (spec);
+ ProcessFile (spec);
+ return;
}
string [] files = null;
@@ -399,16 +379,17 @@
files = Directory.GetFiles (path, pattern);
} catch (System.IO.DirectoryNotFoundException) {
Report.Error (2001, "Source file `" + spec + "' could
not be found");
- return 1;
+ return;
} catch (System.IO.IOException){
Report.Error (2001, "Source file `" + spec + "' could
not be found");
- return 1;
+ return;
+ }
+ foreach (string f in files) {
+ ProcessFile (f);
}
- foreach (string f in files)
- errors += ProcessFile (f);
if (!recurse)
- return errors;
+ return;
string [] dirs = null;
@@ -421,11 +402,8 @@
// Don't include path in this string, as each
// directory entry already does
- errors += CompileFiles (d + "/" + pattern, true);
+ CompileFiles (d + "/" + pattern, true);
}
-
-
- return errors;
}
static void DefineDefaultConfig ()
@@ -476,9 +454,10 @@
/// TODO: Mostly structured to debug the compiler
/// now, needs to be turned into a real driver soon.
/// </remarks>
- static void MainDriver (string [] args)
+ // [MonoTODO("Change error code for unknown argument to something
+reasonable")]
+ static bool MainDriver (string [] args)
{
- int errors = 0, i;
+ int i;
string output_file = null;
bool parsing_options = true;
@@ -520,7 +499,7 @@
if (extra_args == null){
Report.Error (2011, "Unable to open
response file: " +
response_file);
- return;
+ return false;
}
new_args = new string [extra_args.Length +
argc];
@@ -551,8 +530,8 @@
case "--main": case "-m":
if ((i + 1) >= argc){
- Usage (true);
- return;
+ Usage ();
+ return false;
}
RootContext.MainClass = args [++i];
continue;
@@ -563,24 +542,24 @@
case "/?": case "/h": case "/help":
case "--help":
- Usage (false);
- return;
+ Usage ();
+ return false;
case "--define":
if ((i + 1) >= argc){
- Usage (true);
- return;
+ Usage ();
+ return false;
}
defines.Add (args [++i]);
continue;
- case "--probe": {
+ case "--expect-error": {
int code = 0;
try {
code = Int32.Parse (
args [++i],
NumberStyles.AllowLeadingSign);
- Report.SetProbe (code);
+ Report.ExpectedError = code;
} catch {
Report.Error (-14, "Invalid
number specified");
}
@@ -595,8 +574,8 @@
case "-o":
case "--output":
if ((i + 1) >= argc){
- Usage (true);
- return;
+ Usage ();
+ return false;
}
output_file = args [++i];
string bname = CodeGen.Basename
(output_file);
@@ -614,9 +593,9 @@
case "--resource":
if ((i + 1) >= argc){
- Usage (true);
+ Usage ();
Console.WriteLine("Missing
argument to --resource");
- return;
+ return false;
}
if (resources == null)
resources = new ArrayList ();
@@ -626,8 +605,8 @@
case "--target":
if ((i + 1) >= argc){
- Usage (true);
- return;
+ Usage ();
+ return false;
}
string type = args [++i];
@@ -650,15 +629,15 @@
target_ext = ".dll";
break;
default:
- Usage (true);
- return;
+ Usage ();
+ return false;
}
continue;
case "-r":
if ((i + 1) >= argc){
- Usage (true);
- return;
+ Usage ();
+ return false;
}
references.Add (args [++i]);
@@ -666,8 +645,8 @@
case "-L":
if ((i + 1) >= argc){
- Usage (true);
- return;
+ Usage ();
+ return false;
}
link_paths.Add (args [++i]);
continue;
@@ -686,16 +665,16 @@
case "--nowarn":
if ((i + 1) >= argc){
- Usage (true);
- return;
+ Usage ();
+ return false;
}
int warn;
try {
warn = Int32.Parse (args
[++i]);
} catch {
- Usage (true);
- return;
+ Usage ();
+ return false;
}
Report.SetIgnoreWarning (warn);
continue;
@@ -705,8 +684,7 @@
Report.Error (
1900,
"--wlevel requires an
value from 0 to 4");
- error_count++;
- return;
+ return false;
}
int level;
@@ -716,26 +694,25 @@
Report.Error (
1900,
"--wlevel requires an
value from 0 to 4");
- return;
+ return false;
}
if (level < 0 || level > 4){
Report.Error (1900, "Warning
level must be 0 to 4");
- return;
+ return false;
} else
RootContext.WarningLevel =
level;
continue;
case "--about":
About ();
- return;
+ return true;
case "--recurse":
if ((i + 1) >= argc){
Console.WriteLine ("--recurse
requires an argument");
- error_count++;
- return;
+ return false;
}
- errors += CompileFiles (args [++i],
true);
+ CompileFiles (args [++i], true);
continue;
case "--timestamp":
@@ -751,8 +728,7 @@
case "--debug-args":
if ((i + 1) >= argc){
Console.WriteLine
("--debug-args requires an argument");
- error_count++;
- return;
+ return false;
}
char[] sep = { ',' };
debug_arglist.AddRange (args
[++i].Split (sep));
@@ -763,28 +739,27 @@
continue;
default:
- Console.WriteLine ("Unknown option: "
+ arg);
- errors++;
+ Report.Warning(666, "Unknown option: "
++ arg);
continue;
}
}
- errors += CompileFiles (arg, false);
+ CompileFiles (arg, false);
}
if (tokenize)
- return;
+ return true;
if (first_source == null){
Report.Error (2008, "No files to compile were
specified");
- return;
+ return false;
}
if (Report.Errors > 0)
- return;
+ return false;
if (parse_only)
- return;
+ return true;
//
// Load Core Library for default compilation
@@ -795,9 +770,8 @@
if (load_default_config)
DefineDefaultConfig ();
- if (errors > 0){
- error ("Parsing failed");
- return;
+ if (Report.Errors > 0){
+ return false;
}
//
@@ -805,17 +779,15 @@
//
if (timestamps)
ShowTime ("Loading references");
- errors += LoadReferences ();
+ LoadReferences ();
+
if (timestamps)
ShowTime (" References loaded");
- if (errors > 0){
- error ("Could not load one or more assemblies");
- return;
+ if (Report.Errors > 0){
+ return false;
}
- error_count = errors;
-
//
// Quick hack
//
@@ -844,7 +816,7 @@
if (!RootContext.StdLib){
RootContext.ResolveCore ();
if (Report.Errors > 0)
- return;
+ return false;
}
TypeManager.InitCoreTypes ();
@@ -866,8 +838,7 @@
TypeManager.InitCodeHelpers ();
if (Report.Errors > 0){
- error ("Compilation failed");
- return;
+ return false;
}
//
@@ -880,8 +851,7 @@
ShowTime (" done");
if (Report.Errors > 0){
- error ("Compilation failed");
- return;
+ return false;
}
if (timestamps)
@@ -904,7 +874,7 @@
if (ep == null){
Report.Error (5001, "Program " + output_file +
" does not have an entry
point defined");
- return;
+ return false;
}
CodeGen.AssemblyBuilder.SetEntryPoint (ep, k);
@@ -928,13 +898,13 @@
ShowTime ("Saved symbols");
}
- if (Report.Errors > 0){
- error ("Compilation failed");
- return;
- } else if (Report.ProbeCode != 0){
- error ("Failed to report code " + Report.ProbeCode);
- Environment.Exit (124);
+ if (Report.ExpectedError != 0){
+ Console.WriteLine("Failed to report expected error " +
+Report.ExpectedError);
+ Environment.Exit (1);
+ return false;
}
+
+ return (Report.Errors == 0);
}
}
Index: mcs/genericparser.cs
===================================================================
RCS file: /mono/mcs/mcs/genericparser.cs,v
retrieving revision 1.6
diff -u -r1.6 genericparser.cs
--- mcs/genericparser.cs 19 Nov 2001 00:44:09 -0000 1.6
+++ mcs/genericparser.cs 25 Jun 2002 13:58:28 -0000
@@ -19,15 +19,13 @@
/// </summary>
public abstract class GenericParser
{
- static protected int global_errors;
-
// Name of the file we are parsing
public string name;
// Input stream to parse from.
public System.IO.Stream input;
- public abstract int parse ();
+ public abstract void parse ();
public virtual string[] extensions()
{
@@ -35,28 +33,6 @@
return list;
}
- /// <summary>
- /// Emits error messages and increments a global count of them
- /// </summary>
- /// <param name="code"></param>
- /// <param name="desc"></param>
- static public void error (int code, string desc)
- {
- Console.WriteLine ("Error "+code+": "+ desc);
- global_errors++;
- }
-
- // Emits error messages with location info.
- // FIXME : Ideally, all error reporting should happen
- // with Report.Error but how do you get at that non-static
- // method everywhere you need it ?
- static public void error (int code, Mono.CSharp.Location l, string
text)
- {
- Console.WriteLine (l.Name + "(" + l.Row + "," +
- "): Error CS" + code + ": " + text);
- global_errors++;
- }
-
public GenericParser()
{
//
Index: mcs/mb-parser.jay
===================================================================
RCS file: /mono/mcs/mcs/mb-parser.jay,v
retrieving revision 1.1
diff -u -r1.1 mb-parser.jay
--- mcs/mb-parser.jay 11 Oct 2001 18:12:12 -0000 1.1
+++ mcs/mb-parser.jay 25 Jun 2002 13:58:28 -0000
@@ -444,7 +444,7 @@
Tokenizer lexer;
-public override int parse ()
+public override void parse ()
{
current_namespace = new Namespace (null, "");
this.tree = rc.Tree;
@@ -456,7 +456,6 @@
lexer = new Tokenizer (input, name);
StringBuilder value = new StringBuilder ();
- global_errors = 0;
try
{
if (yacc_verbose_flag)
@@ -468,10 +467,7 @@
{
Console.WriteLine (lexer.location + " : Parsing error ");
Console.WriteLine (e);
- global_errors++;
}
-
- return global_errors;
}
/* end end end */
Index: mcs/namespace.cs
===================================================================
RCS file: /mono/mcs/mcs/namespace.cs,v
retrieving revision 1.7
diff -u -r1.7 namespace.cs
--- mcs/namespace.cs 15 Jun 2002 23:35:04 -0000 1.7
+++ mcs/namespace.cs 25 Jun 2002 13:58:28 -0000
@@ -73,7 +73,7 @@
public void Using (string ns)
{
if (decl_found){
- GenericParser.error (1529, "A using clause must
precede all other namespace elements");
+ Report.Error (1529, "A using clause must precede all
+other namespace elements");
return;
}
@@ -127,7 +127,7 @@
if (de.Value == null){
string name = (string) de.Key;
- GenericParser.error (234, "The type or
namespace `" +
+ Report.Error (234, "The type or namespace `" +
name + "' does not exist
in the " +
"class or namespace `" +
name + "'");
}
Index: mcs/report.cs
===================================================================
RCS file: /mono/mcs/mcs/report.cs,v
retrieving revision 1.23
diff -u -r1.23 report.cs
--- mcs/report.cs 27 Mar 2002 23:42:51 -0000 1.23
+++ mcs/report.cs 25 Jun 2002 13:58:28 -0000
@@ -45,12 +45,12 @@
static public bool Stacktrace;
//
- // If the error code is reported on the given line,
- // then the process exits with a unique error code.
+ // If the 'expected' error code is reported then the
+ // compilation succeeds.
//
// Used for the test suite to excercise the error codes
//
- static int probe_error = 0;
+ static int expected_error = 0;
//
// Keeps track of the warnings that we are ignoring
@@ -59,11 +59,11 @@
static void Check (int code)
{
- if (code == probe_error){
+ if (code == expected_error){
if (Fatal)
throw new Exception ();
- Environment.Exit (123);
+ Environment.Exit (0);
}
}
@@ -147,16 +147,14 @@
warning_ignore_table [code] = true;
}
- static public void SetProbe (int code)
- {
- probe_error = code;
- }
-
- static public int ProbeCode {
- get {
- return probe_error;
- }
- }
+ static public int ExpectedError {
+ set {
+ expected_error = value;
+ }
+ get {
+ return expected_error;
+ }
+ }
}
public class Message {
Index: tests/ChangeLog
===================================================================
RCS file: /mono/mcs/tests/ChangeLog,v
retrieving revision 1.80
diff -u -r1.80 ChangeLog
--- tests/ChangeLog 13 Jun 2002 13:07:53 -0000 1.80
+++ tests/ChangeLog 25 Jun 2002 13:58:28 -0000
@@ -1,3 +1,14 @@
+2002-06-25 Andrew Birkett <[EMAIL PROTECTED]>
+
+ * makefile: The following tests fail under linux and have been
+ moved to TEST_NOPASS: 40, 45, 52, 53, 91, 106, 107, 122, 132, 133
+
+ Windows-specific tests have been extracted, and are now run by the
+ test-windows rule (it'll be run under linux but fail)
+
+ The output format has been made less noisy, and is basically the
+ same as the tests in mcs/errors - like "Running test-1 ... OK".
+
2002-06-13 Ravi Pratap <[EMAIL PROTECTED]>
* test-131.cs : Add to test enum member attribute application.
Index: tests/makefile
===================================================================
RCS file: /mono/mcs/tests/makefile,v
retrieving revision 1.122
diff -u -r1.122 makefile
--- tests/makefile 22 Jun 2002 06:14:13 -0000 1.122
+++ tests/makefile 25 Jun 2002 13:58:28 -0000
@@ -7,69 +7,93 @@
test-1 test-2 test-3 test-4 test-5 test-6 test-7 test-8 test-9
test-10 \
test-11 test-12 test-13 test-14 test-15 test-16 test-17 test-18
test-19 test-20 \
test-21 test-22 test-23 test-24 test-25 test-26 test-27 test-28
test-30 \
- test-31 test-32 test-33 test-34 test-35 test-36 test-37
test-39 test-40 \
- test-41 test-42 test-43 test-44 test-45 test-46 test-47 test-48
test-49 test-50 \
- test-51 test-52 test-53 test-54 test-55 test-56 test-57
test-59 test-60 \
- test-61 test-62 test-63 test-64 test-65 test-66 test-67 test-68
test-69 test-70 \
+ test-31 test-32 test-33 test-34 test-35 test-36 test-37
+test-39 \
+ test-41 test-42 test-43 test-44 test-46 test-47 test-48 test-49 \
+ test-51 test-54 test-55 test-56 test-57 test-59 test-60 \
+ test-61 test-62 test-63 test-64 test-65 test-66 test-68 test-69
+test-70 \
test-71 test-72 test-73 test-74 test-75 test-76 test-77 test-78
test-79 test-80 \
test-81 test-82 test-83 test-84 test-85 test-86 test-87 test-88
test-89 test-90 \
- test-91 test-92 test-93 test-94 test-95 test-96 test-97 test-98
test-99 test-100\
- test-101 test-102 test-103 test-104 test-105 test-106 test-107 test-108
test-109 test-110\
+ test-92 test-93 test-94 test-95 test-96 test-97 test-98 test-99
+test-100\
+ test-101 test-102 test-103 test-104 test-105 test-108 test-109 test-110\
test-111 test-112 test-113 test-114 test-115 test-116 test-117 test-118
test-119 \
- test-121 test-122 test-123 test-125 test-126 test-127 test-128
test-129 test-130 \
- test-131 test-132 test-133 test-134 test-135
+ test-121 test-123 test-125 test-126 test-127 test-128 test-129
+test-130 \
+ test-131 test-134 test-135
UNSAFE_SOURCES = \
unsafe-1 unsafe-2 unsafe-3
-TEST_NOPASS = \
- test-29 test-38 \
- test-120
+WINDOWS_SOURCES = \
+ test-50 test-67
+# A test is a 'no pass' if it fails on either windows or linux
# Test 120 does not pass because the MS.NET runtime is buggy.
+TEST_NOPASS = \
+ test-29 test-38 test-40 test-45 test-52 test-53 test-91 test-106 test-107 \
+ test-120 test-122 test-132 test-133
+
+all: test-compiler test-unsafe test-windows
-all: test-compiler test-unsafe
+# Compile with mono, run with MS jit
test-compiler:
- -rm *.exe
+ @rm -f *.exe; \
for i in $(TEST_SOURCES); do \
+ echo -n "Running $$i ... "; \
if $(MCS) $$i.cs > /dev/null; then \
- if ./$$i.exe; then \
- echo $$i: ok; \
+ if ./$$i.exe > /dev/null; then \
+ echo OK; \
else \
- echo test $$i failed; exit; \
+ echo FAILED; exit 1; \
fi; \
else \
- echo compiler failed on $$i; exit; \
+ echo FAILED TO COMPILE; exit 1; \
fi \
done
+# Compile with mono, run with MS jit
test-unsafe:
- for i in $(UNSAFE_SOURCES); do \
+ @for i in $(UNSAFE_SOURCES); do \
+ echo -n "Running (unsafe) $$i ... "; \
if $(MCS) --unsafe $$i.cs > /dev/null; then \
- if ./$$i.exe; then \
- echo $$i: ok; \
+ if ./$$i.exe > /dev/null; then \
+ echo OK; \
else \
- echo test $$i failed; exit; \
+ echo FAILED; exit 1; \
fi; \
else \
- echo compiler failed on $$i; exit; \
+ echo FAILED WHILE COMPILING; exit 1; \
fi \
done
+# Compiled (previously) with mono, run with mono jit
test-jit:
- for i in $(TEST_SOURCES:.cs=.exe); do \
- if mono ./$$i.exe; then \
- echo $$i: ok; \
+ @for i in $(TEST_SOURCES:.cs=.exe); do \
+ echo -n "Running jit $$i ... "; \
+ if mono ./$$i.exe > /dev/null; then \
+ echo OK; \
else \
- echo test $$i failed; exit; \
+ echo FAILED; exit 1; \
fi \
done
-
+# Compiled with mono, run with MS jit
+test-windows:
+ @echo Running windows-only tests - these will fail on linux; \
+ for i in $(WINDOWS_SOURCES); do \
+ echo -n "Running $$i ... "; \
+ if $(MCS) $$i.cs > /dev/null; then \
+ if ./$$i.exe > /dev/null; then \
+ echo OK; \
+ else \
+ echo FAILED; exit 1; \
+ fi; \
+ else \
+ echo FAILED TO COMPILE; exit 1; \
+ fi \
+ done
verify:
- for i in $(TEST_SOURCES); do \
+ @for i in $(TEST_SOURCES); do \
if $(MCS) -o mcs-gen-code.exe $$i.cs > /dev/null; then \
if $(CSC) /out:csc-gen-code.exe $$i.cs > /dev/null; then \
if $(VERIFY) mcs-gen-code.exe csc-gen-code.exe >
/dev/null; then \
@@ -79,7 +103,8 @@
fi; \
fi \
fi \
- done
+ done; \
+ echo Verification passed
casts.cs: gen-cast-test.cs
2002-06-24 Andrew Birkett <[EMAIL PROTECTED]>
* fail: cs0121.cs, cs0157.cs and cs1501.cs no longer fail.
* cs0176.cs: Method has to be public for correct test
* cs0196.cs, cs0242.cs: Do 'return' to stop null statement warning.
* cs0255.cs: Add assignment to stop 'unused variable' warning.
* makefile: Output is now like "Running test 42 .. OK". Added --unsafe to
make cs0193.cs, cs0196.cs and cs0214-3.cs work.