diff options
Diffstat (limited to 'mcs/errors')
229 files changed, 3830 insertions, 10 deletions
diff --git a/mcs/errors/ChangeLog b/mcs/errors/ChangeLog new file mode 100644 index 00000000000..3bd594231f3 --- /dev/null +++ b/mcs/errors/ChangeLog @@ -0,0 +1,128 @@ +2002-12-24 Alejandro Sánchez Acosta <raciel@gnome.org> + + * cs0208.cs: Added new test. + +2002-12-24 Alejandro Sánchez Acosta <raciel@gnome.org> + + * cs0202.cs: Added new test. + +2002-12-24 Alejandro Sánchez Acosta <raciel@gnome.org> + + * cs0197.cs: Added new test. + +2002-12-23 Alejandro Sánchez Acosta <raciel@gnome.org> + + * cs0192.cs: Added new test. + +2002-12-23 Alejandro Sánchez Acosta <raciel@gnome.org> + + * cs0170.cs: Added new test. + +2002-12-23 Alejandro Sánchez Acosta <raciel@gnome.org> + + * cs0156.cs: Added new test. + +2002-12-21 Alejandro Sánchez Acosta <raciel@gnome.org> + + * cs0163.cs: Added new test file. + +2002-12-21 Alejandro Sánchez Acosta <raciel@gnome.org> + + * cs0161.cs: Added new test file. + +2002-12-19 Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx> + + * cs0230.cs: Added this test file. + +2002-12-19 Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx> + + * cs0225.cs: Added this file + +2002-12-18 Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx> + + * cs0201.cs: Added this new test. + +2002-12-18 Ravi Pratap <ravi@ximian.com> + + * errors.txt : Update for error # -24. + +2002-12-17 Alejandro Sánchez Acosta <raciel@gnome.org> + + * cs0154.cs: New test. + +2002-12-17 Alejandro Sánchez Acosta <raciel@gnome.org> + + * cs0138.cs: New test. + +2002-12-07 Ravi Pratap <ravi@ximian.com> + + * cs0579.cs : Add. + +2002-12-01 Alejandro Sánchez Acosta <raciel@es.gnu.org> + + * cs0140.cs, + cs0143.cs: New test. + +2002-12-01 Alejandro Sánchez Acosta <raciel@es.gnu.org> + + * cs0100.cs, + cs0105.cs, + cs0112.cs, + cs0116.cs: New test. + +2002-09-12 Martin Baulig <martin@gnome.org> + + * cs0038.cs: New test. + +2002-08-27 Martin Baulig <martin@gnome.org> + + * cs0120-3.cs: New test. + +2002-08-19 Ravi Pratap <ravi@ximian.com> + + * error-4.cs : New test. + + * error-5.cs : New test. + +2002-08-11 Martin Baulig <martin@gnome.org> + + * error-3.cs: New test. + +2002-08-08 Martin Baulig <martin@gnome.org> + + * cs1540.cs: New test. + +2002-08-08 Martin Baulig <martin@gnome.org> + + * cs0236.cs: New test. + +2002-08-05 Martin Baulig <martin@gnome.org> + + * runtest.pl: This is a perl script which runs a testcase, parses the + MCS output and checks whether all errors are reported. + + * error-1.cs, error-2.cs: Moved here from ../tests/. + + * README.tests: Added (empty) list of all test cases. + +2002-08-02 Martin Baulig <martin@gnome.org> + + * cs0155.cs, cs0155-2.cs: New tests. + +2002-07-06 Andrew Birkett <adb@tardis.ed.ac.uk> + + * cs1039.cs, cs1033.cs, cs1010.cs: New tests. + +2002-06-26 <adb@tardis.ed.ac.uk> + + * cs1501-3.cs: Added new test for struct ctr typechecks. + +2002-06-24 Andrew Birkett <adb@tardis.ed.ac.uk> + + * 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. + diff --git a/mcs/errors/README.tests b/mcs/errors/README.tests new file mode 100644 index 00000000000..d8d1e384071 --- /dev/null +++ b/mcs/errors/README.tests @@ -0,0 +1,33 @@ +Test cases listed by Category: +============================== + +* Flow Analysis + + error-1.cs error-3.cs + +* Type Containers + + error-2.cs + +Test cases listed by Number: +============================ + +error-1.cs +---------- +Flow analysis: Check whether mcs correctly reports all errors. + +error-2.cs +---------- +Base types are less accessible than the current type. + +error-3.cs +---------- +Flow analysis: Check struct members. + +error-4.cs +---------- +Ensure that we do not allow void types to be converted to anything else + +error-5.cs +---------- +Catch invalid access to a private event of a class diff --git a/mcs/errors/bug1.cs b/mcs/errors/bug1.cs new file mode 100755 index 00000000000..934f0f9bce2 --- /dev/null +++ b/mcs/errors/bug1.cs @@ -0,0 +1,17 @@ +// +// FIXED +// +interface A { + void B (); +} + +interface X { + void B (); +} + + +class B : A, X { + void X.B () {} + void A.B () {} + +} diff --git a/mcs/errors/bug10.cs b/mcs/errors/bug10.cs new file mode 100644 index 00000000000..5b2ff627ffa --- /dev/null +++ b/mcs/errors/bug10.cs @@ -0,0 +1,30 @@ +// +// fixed +// +using System; + +public class Blah { + + public void Connect () + { + } + + public void Button1_Click (int i, int j) + { + Console.WriteLine ("Button1 was clicked !"); + Console.WriteLine ("Answer : " + (i+j)); + } + + public static int Main () + { + Blah b = new Blah (); + + b.Connect (); + + b.OnClick (); + + Console.WriteLine ("Test passes"); + return 0; + } + +} diff --git a/mcs/errors/bug11.cs b/mcs/errors/bug11.cs new file mode 100755 index 00000000000..b48bc1893f7 --- /dev/null +++ b/mcs/errors/bug11.cs @@ -0,0 +1,23 @@ +// +// fixed +// +class Location { + static public int Null { + get { + return 1; + } + } +} + +class X { + Location Location; + X () + { + int a = Location.Null; + } + + static void Main () {} +} + + + diff --git a/mcs/errors/bug12.cs b/mcs/errors/bug12.cs new file mode 100755 index 00000000000..27c24e93eb7 --- /dev/null +++ b/mcs/errors/bug12.cs @@ -0,0 +1,19 @@ +using System.Collections; + + class PtrHashtable : Hashtable { + class PtrComparer : IComparer { + public int Compare (object x, object y) + { + if (x == y) + return 0; + else + return 1; + } + } + + public PtrHashtable () + { + comparer = new PtrComparer (); + } + } + diff --git a/mcs/errors/bug13.cs b/mcs/errors/bug13.cs new file mode 100755 index 00000000000..91016d0a7c7 --- /dev/null +++ b/mcs/errors/bug13.cs @@ -0,0 +1,11 @@ +using System; + +class X { + static void Main () + { + Type t = null; + + if (t.GetType () == null) + return; + } +} diff --git a/mcs/errors/bug14.cs b/mcs/errors/bug14.cs new file mode 100755 index 00000000000..9167d9afbbf --- /dev/null +++ b/mcs/errors/bug14.cs @@ -0,0 +1,15 @@ +// +// fixed +// +using System; + +class X { + + static void Main () + { + string msg = String.Format ("{0} {1} {2} {3}", "one", 3, 3, "two"); + + Console.WriteLine (msg); + } +} + diff --git a/mcs/errors/bug15.cs b/mcs/errors/bug15.cs new file mode 100755 index 00000000000..d233407af32 --- /dev/null +++ b/mcs/errors/bug15.cs @@ -0,0 +1,25 @@ +// +// fixed +// +using System; + +class X { + + void A () + { + } + + static void Main () + { + int loop = 0; + + goto a; + b: + loop++; + a: + Console.WriteLine ("Hello"); + for (;;){ + goto b; + } + } +} diff --git a/mcs/errors/bug16.cs b/mcs/errors/bug16.cs new file mode 100644 index 00000000000..4b8503cf127 --- /dev/null +++ b/mcs/errors/bug16.cs @@ -0,0 +1,24 @@ +// +// Fixed +// + +using System; + +public class Blah { + + public static void Main () + { + ushort i; + sbyte j; + + i = 10; + j = 20; + + Console.WriteLine (i); + Console.WriteLine (j); + + Console.WriteLine ("Hello there !"); + } +} + + diff --git a/mcs/errors/bug17.cs b/mcs/errors/bug17.cs new file mode 100755 index 00000000000..d922487cf34 --- /dev/null +++ b/mcs/errors/bug17.cs @@ -0,0 +1,10 @@ +// +// Fixed +// +class X { + static void Main () + { +double x = 64.0; +System.Console.WriteLine("x = " + x.ToBoolean(null)); +} +} diff --git a/mcs/errors/bug18.cs b/mcs/errors/bug18.cs new file mode 100755 index 00000000000..61e0f0af006 --- /dev/null +++ b/mcs/errors/bug18.cs @@ -0,0 +1,16 @@ +namespace A { + interface B { + } +} + +class X { + static void A (object A) + { + object x = (A.B) A; + } + + static void Main () + { + } +} + diff --git a/mcs/errors/bug19.cs b/mcs/errors/bug19.cs new file mode 100755 index 00000000000..15755b6faaa --- /dev/null +++ b/mcs/errors/bug19.cs @@ -0,0 +1,18 @@ +namespace N1 +{ + public enum A + { + A_1, A_2, A_3 + } + + public class B + { + const A b = A.A_1; + } +} + + + + + + diff --git a/mcs/errors/bug2.cs b/mcs/errors/bug2.cs new file mode 100755 index 00000000000..61f6eea2bce --- /dev/null +++ b/mcs/errors/bug2.cs @@ -0,0 +1,29 @@ +// +// fixed +// +class X { + + static void A (ref int a) + { + a++; + } + + // Int32& + static void B (ref int a) + { + // Int32&& + A (ref a); + } + + static int Main () + { + int a = 10; + + B (ref a); + + if (a == 11) + return 0; + else + return 1; + } +} diff --git a/mcs/errors/bug3.cs b/mcs/errors/bug3.cs new file mode 100755 index 00000000000..af24ecc011b --- /dev/null +++ b/mcs/errors/bug3.cs @@ -0,0 +1,36 @@ +// +// Fixed, incorporated into test +// +using System; + +using System.Runtime.InteropServices; + +[StructLayout (LayoutKind.Explicit)] +struct A { + [FieldOffset (0)] + public int a; + [FieldOffset (0)] + public byte b1; + [FieldOffset (1)] + public byte b2; + [FieldOffset (2)] + public byte b3; + [FieldOffset (3)] + public byte b4; +} + +class X { + static void Main () + { + A a = new A (); + + a.a = 0x12345678; + + Console.WriteLine ("b1: " + a.b1); + Console.WriteLine ("b2: " + a.b2); + Console.WriteLine ("b3: " + a.b3); + Console.WriteLine ("b4: " + a.b4); + + } +} + diff --git a/mcs/errors/bug4.cs b/mcs/errors/bug4.cs new file mode 100755 index 00000000000..775cfe30349 --- /dev/null +++ b/mcs/errors/bug4.cs @@ -0,0 +1,18 @@ +// +// Fixed +// +using System; + +class X { + static void Main () + { + try { + throw new Exception (); + } catch (Exception e) { + Console.WriteLine ("Caught"); + throw; + } catch { + Console.WriteLine ("Again"); + } + } +} diff --git a/mcs/errors/bug5.cs b/mcs/errors/bug5.cs new file mode 100755 index 00000000000..03fce159750 --- /dev/null +++ b/mcs/errors/bug5.cs @@ -0,0 +1,23 @@ +// +// fixed +// +interface I { + void a (); +} + +abstract class X : I { + public abstract void a (); +} + +class Y : X { + override public void a () { + System.Console.WriteLine ("Hello!"); + return; + } + + static void Main () { + Y y = new Y (); + + ((I) y ).a (); + } +} diff --git a/mcs/errors/bug6.cs b/mcs/errors/bug6.cs new file mode 100755 index 00000000000..9cbf071393d --- /dev/null +++ b/mcs/errors/bug6.cs @@ -0,0 +1,14 @@ +// +// fixed +// +public class X { + + public enum Blah { A } + +} + +public class Y : X { + + Blah x; + +} diff --git a/mcs/errors/bug7.cs b/mcs/errors/bug7.cs new file mode 100755 index 00000000000..fcd35bc6cdb --- /dev/null +++ b/mcs/errors/bug7.cs @@ -0,0 +1,13 @@ +public enum X :byte { + a, b +} + +public class Y { + + const X myconst = X.a; + + static void Main () + { + } +} + diff --git a/mcs/errors/bug8.cs b/mcs/errors/bug8.cs new file mode 100755 index 00000000000..47846f7c4c9 --- /dev/null +++ b/mcs/errors/bug8.cs @@ -0,0 +1,20 @@ +using System; + +// +// The problem here is that `(Type)' is being recognized as a Property +// but inside a Cast expression this is invalid. +// +class X { + + int Type { + get { + return 1; + } + } + + static void Main () + { + Type t = (Type) null; + } + +} diff --git a/mcs/errors/bug9.cs b/mcs/errors/bug9.cs new file mode 100755 index 00000000000..f0c436a1ad0 --- /dev/null +++ b/mcs/errors/bug9.cs @@ -0,0 +1,7 @@ +enum A { +a, b +} + +class X { + const A a = A.a; +} diff --git a/mcs/errors/cs-11.cs b/mcs/errors/cs-11.cs new file mode 100644 index 00000000000..5adc40a2573 --- /dev/null +++ b/mcs/errors/cs-11.cs @@ -0,0 +1,20 @@ +// cs-11.cs : Delegate creation expression takes only one argument +// Line : 17 + +public class Blah { + + public delegate int MyDelegate (int i, int j); + + public int Foo (int i, int j) + { + return i+j; + } + + public static void Main () + { + Blah i = new Blah (); + + MyDelegate del = new MyDelegate (); + } +} + diff --git a/mcs/errors/cs-12.cs b/mcs/errors/cs-12.cs new file mode 100755 index 00000000000..fe4b09b37a2 --- /dev/null +++ b/mcs/errors/cs-12.cs @@ -0,0 +1,34 @@ +class Y { + byte b; + + public static implicit operator int (Y i) + { + return i.b; + } + +// public static implicit operator byte (Y i) +// { +// return i.b; +// } + + public Y (byte b) + { + this.b = b; + } +} + +class X { + static void Main () + { + Y y = new Y (1); + + switch (y){ + case 0: + break; + case 1: + break; + } + + int a = y; + } +} diff --git a/mcs/errors/cs0017.cs b/mcs/errors/cs0017.cs new file mode 100755 index 00000000000..7942594be2f --- /dev/null +++ b/mcs/errors/cs0017.cs @@ -0,0 +1,9 @@ +// cs0017.cs: Program has more than one entry point
+// Line: 7
+class X {
+static void Main () {}
+}
+class Y {
+static void Main () {
+}
+}
diff --git a/mcs/errors/cs0019-2.cs b/mcs/errors/cs0019-2.cs new file mode 100755 index 00000000000..d9753a29a1c --- /dev/null +++ b/mcs/errors/cs0019-2.cs @@ -0,0 +1,20 @@ +// cs0019.cs : Operator + cannot be applied to operands of type `int' and `Test.Zub' +// Line : 11 +using System; + +class Test { + + enum Zub :byte { + Foo = 99, + Bar, + Baz + } + + + static void Main () + { + int v = 1; + object foo = (v + Zub.Foo); + } +} + diff --git a/mcs/errors/cs0019-3.cs b/mcs/errors/cs0019-3.cs new file mode 100755 index 00000000000..e49fde2ab13 --- /dev/null +++ b/mcs/errors/cs0019-3.cs @@ -0,0 +1,19 @@ +// cs0019.cs : Operator + cannot be applied to operands of type `int' and `Test.Zub' +// Line : 11 +using System; + +class Test { + + enum Zub :byte { + Foo = 99, + Bar, + Baz + } + + + static void Main () + { + object v = (Zub.Foo + Zub.Foo); + } +} + diff --git a/mcs/errors/cs0019-4.cs b/mcs/errors/cs0019-4.cs new file mode 100755 index 00000000000..938735e69a2 --- /dev/null +++ b/mcs/errors/cs0019-4.cs @@ -0,0 +1,20 @@ +// cs0019.cs : Operator + cannot be applied to operands of type `int' and `Test.Zub' +// Line : 11 +using System; + +class Test { + + enum Zub :byte { + Foo = 99, + Bar, + Baz + } + + + static void Main () + { + Zub a = Zub.Foo, b = Zub.Bar; + object v = (a + b); + } +} + diff --git a/mcs/errors/cs0019-5.cs b/mcs/errors/cs0019-5.cs new file mode 100755 index 00000000000..6b8da99ef80 --- /dev/null +++ b/mcs/errors/cs0019-5.cs @@ -0,0 +1,16 @@ +class X { +} + +class Y { +} + +class T { + static void Main () + { + X x = new X (); + Y y = new Y (); + + if (x == y){ + } + } +} diff --git a/mcs/errors/cs0019.cs b/mcs/errors/cs0019.cs new file mode 100644 index 00000000000..c3dbd4f9b93 --- /dev/null +++ b/mcs/errors/cs0019.cs @@ -0,0 +1,14 @@ +// cs0019.cs : Operator + cannot be applied to operands of type `Foo' and `int' +// Line : 11 + +public class Foo { + + public static void Main () + { + + Foo k = new Foo (); + + int i = k + 6; + + } +} diff --git a/mcs/errors/cs0020.cs b/mcs/errors/cs0020.cs new file mode 100755 index 00000000000..228401b453c --- /dev/null +++ b/mcs/errors/cs0020.cs @@ -0,0 +1,12 @@ +// cs0020.cs : Division by constant zero. +// Line : 999999999 + +using System; + +public class X { + static void Main () + { + int i = 1 / 0; + Console.WriteLine (i); + } +} diff --git a/mcs/errors/cs0021.cs b/mcs/errors/cs0021.cs new file mode 100644 index 00000000000..8650b540e11 --- /dev/null +++ b/mcs/errors/cs0021.cs @@ -0,0 +1,12 @@ +// cs0021.cs: You can't use and indexer with a type that doesn't support it. +// Line: 9 +using System; + +class ErrorCS0021 { + public static void Main () { + int i = 0; + Console.WriteLine ("Test for ERROR CS0021: You can't use the indexer operator with a type that doesn't support it"); + Console.WriteLine ("Get i[2]: {0}", i[2]); + } +} + diff --git a/mcs/errors/cs0022.cs b/mcs/errors/cs0022.cs new file mode 100644 index 00000000000..a0319016e3e --- /dev/null +++ b/mcs/errors/cs0022.cs @@ -0,0 +1,11 @@ +// cs0022.cs: Wrong number of fields inside the indexer. +// Line: 9 +using System; + +class ErrorCS0022 { + static void Main () { + int[] integer_array = {0, 1}; + Console.WriteLine ("Test for Error CS0022: The compiler should say wrong number of fields inside the indexer"); + Console.WriteLine ("Trying to access integer_array[2, 3] in a one-dimensional array: {0}", integer_array[2,3]); + } +} diff --git a/mcs/errors/cs0023.cs b/mcs/errors/cs0023.cs new file mode 100644 index 00000000000..6a2cd5518c9 --- /dev/null +++ b/mcs/errors/cs0023.cs @@ -0,0 +1,13 @@ +// cs0023.cs : Operator ~ cannot be applied to operand of type `Foo' +// Line : 10 + +public class Foo { + + public static void Main () + { + Foo k = new Foo (); + + int i = ~ k; + + } +} diff --git a/mcs/errors/cs0026-2.cs b/mcs/errors/cs0026-2.cs new file mode 100755 index 00000000000..a4f41cdb51d --- /dev/null +++ b/mcs/errors/cs0026-2.cs @@ -0,0 +1,10 @@ +// cs0026: use of this is not allowed in a static field initializer +// +class X { + static object o = this; + + static int Main () + { + return 1; + } +} diff --git a/mcs/errors/cs0026.cs b/mcs/errors/cs0026.cs new file mode 100755 index 00000000000..e4b5ca7e580 --- /dev/null +++ b/mcs/errors/cs0026.cs @@ -0,0 +1,8 @@ +// cs0026: use of this is not allowed in static methods +// Line: 6 +class X { + static void A () + { + this = null; + } +} diff --git a/mcs/errors/cs0027-2.cs b/mcs/errors/cs0027-2.cs new file mode 100644 index 00000000000..d1af6ef887e --- /dev/null +++ b/mcs/errors/cs0027-2.cs @@ -0,0 +1,18 @@ +// cs0027-2.cs: Keyword 'this' can't be used outside a constructor, a method or a property. +// Line: 10 + +// Attention: Here the compiler complains saying that cannot convert implicitly from 'Error0027' to 'int' but +// should also say that the use of keyword 'this' is out of context since it's used outside a constructor, method +// or property. +using System; + +class Error0027 { + int i = this; + int x = 0; + + public static void Main () { + Console.WriteLine ("The compiler should complain: Error CS0027 trying to use 'this' outside context."); + Console.WriteLine ("Trying to assign i to 'this' outside a method, property or ctr."); + } +} + diff --git a/mcs/errors/cs0027.cs b/mcs/errors/cs0027.cs new file mode 100644 index 00000000000..35aee1b9cc8 --- /dev/null +++ b/mcs/errors/cs0027.cs @@ -0,0 +1,15 @@ +// cs0027.cs: Keyword 'this' can't be used outside a constructor, a method or a property. +// Line: 7 + +using System; + +class Error0027 { + int i = this.x; + int x = 0; + + public static void Main () { + Console.WriteLine ("The compiler should complain: Error CS0027 trying to use 'this' outside context."); + Console.WriteLine ("Trying to assign i to 'this.x' outside a method, property or ctr."); + } +} + diff --git a/mcs/errors/cs0028.cs b/mcs/errors/cs0028.cs new file mode 100755 index 00000000000..5cbf73f5130 --- /dev/null +++ b/mcs/errors/cs0028.cs @@ -0,0 +1,12 @@ +// cs0028: has the wrong signature to be an entry point +// Line: 8 + +class T { + public static int Main () + { + } + public static int Main (int foo) + { + } +} + diff --git a/mcs/errors/cs0030.cs b/mcs/errors/cs0030.cs new file mode 100644 index 00000000000..7226eb2855c --- /dev/null +++ b/mcs/errors/cs0030.cs @@ -0,0 +1,15 @@ +// cs0030.cs : Cannot convert type 'Blah' to 'float' +// Line : 12 + +public class Blah { + + public static int Main () + { + Blah k; + + k = new Blah (); + + float f = (float) k; + + } +} diff --git a/mcs/errors/cs0031.cs b/mcs/errors/cs0031.cs new file mode 100644 index 00000000000..c79ba6975de --- /dev/null +++ b/mcs/errors/cs0031.cs @@ -0,0 +1,14 @@ +// cs0031.cs : Constant value '256' cannot be converted to a byte +// Line : 7 + +public class Blah { + + public enum MyEnum : byte { + Foo = 256, + Bar + } + + public static void Main () + { + } +} diff --git a/mcs/errors/cs0034.cs b/mcs/errors/cs0034.cs new file mode 100755 index 00000000000..2d5917abee5 --- /dev/null +++ b/mcs/errors/cs0034.cs @@ -0,0 +1,15 @@ +// cs0034: operator >= is ambiguous on types ulong and sbyte +// Line: 7 +class X { + + bool ret (ulong u, sbyte s) + { + return (u >= s); + } + + bool ret (ulong u, short s) + { + return (u >= s); + } + +} diff --git a/mcs/errors/cs0035.cs b/mcs/errors/cs0035.cs new file mode 100644 index 00000000000..c536f7d1402 --- /dev/null +++ b/mcs/errors/cs0035.cs @@ -0,0 +1,27 @@ +// cs0035.cs: Ambiguous 'operator' on an operand of type 'foo' +// Line: 23 + +using System; + +class ErrorCS0035 { + int i; + public ErrorCS0035 (int x) { + i = x; + } + + public static implicit operator long (ErrorCS0035 x) { + return (long) x.i; + } + + public static implicit operator ulong (ErrorCS0035 x) { + return (ulong) x.i; + } + + public static void Main () { + object o; + ErrorCS0035 error = new ErrorCS0035 (10); + Console.WriteLine ("o = -i = {0}", - error); + + } +} + diff --git a/mcs/errors/cs0036.cs b/mcs/errors/cs0036.cs new file mode 100644 index 00000000000..5270de6ac44 --- /dev/null +++ b/mcs/errors/cs0036.cs @@ -0,0 +1,20 @@ +// cs0036.cs: Attibute [In] cannot be accompaning the an 'out' parameter. +// Line: 10 + +using System; +using System.Runtime.InteropServices; + +class ErrorCS0036 { + int i; + + static void SetInteger ([In] out int i) { + i = 10; + } + + public static void Main () { + int x; + SetInteger (out x); + Console.WriteLine ("The compiler should say: ErrorCS0036: {0}", x); + } +} + diff --git a/mcs/errors/cs0037.cs b/mcs/errors/cs0037.cs new file mode 100644 index 00000000000..32d0b542e9f --- /dev/null +++ b/mcs/errors/cs0037.cs @@ -0,0 +1,12 @@ +//cs0037.cs: Can not convert null to struct because its a value type +// Line: 10 +struct S { + int a; +} + +class X { + static void Main () + { + S s = (S) null; + } +} diff --git a/mcs/errors/cs0038.cs b/mcs/errors/cs0038.cs new file mode 100644 index 00000000000..8062934e340 --- /dev/null +++ b/mcs/errors/cs0038.cs @@ -0,0 +1,22 @@ +// cs0038.cs: Cannot access a nonstatic member of outer type `X' via nested type `X.Y'. +// line: 15 +using System; + +class X +{ + int a = 5; + + class Y + { + public long b; + + public Y () + { + Console.WriteLine (a); + } + } + + static void Main () + { + } +} diff --git a/mcs/errors/cs0039.cs b/mcs/errors/cs0039.cs new file mode 100755 index 00000000000..494fe68f956 --- /dev/null +++ b/mcs/errors/cs0039.cs @@ -0,0 +1,16 @@ +// cs0039.cs: as operator can not convert explicitly from type to type +// line: 8 +class A { + public static void Main () + { + decimal tryDec; + tryDec = 1234.2345M; + + object a = tryDec as string; + } +} + + + + + diff --git a/mcs/errors/cs0050.cs b/mcs/errors/cs0050.cs new file mode 100644 index 00000000000..de4fce66a53 --- /dev/null +++ b/mcs/errors/cs0050.cs @@ -0,0 +1,15 @@ +// cs0050.cs: Inconsistent accessibility. Return type less accessible than method. +// Line: 7 + +using System; + +class Foo { + public static Foo Bar () { + return new Foo (); + } + + public static void Main () { + Foo x = Bar (); + } +} + diff --git a/mcs/errors/cs0052.cs b/mcs/errors/cs0052.cs new file mode 100644 index 00000000000..08d5c821486 --- /dev/null +++ b/mcs/errors/cs0052.cs @@ -0,0 +1,15 @@ +// cs0052.cs: Accessibility levels inconsistent. Method type is less accessible than method. +// Line: 10 + +using System; + +class ErrorCS0052 { +} + +public class Foo { + public ErrorCS0052 Method () { + Console.WriteLine ("The compile should advice the return type of this method is less accessible than the method."); + } + public static void Main () {} +} + diff --git a/mcs/errors/cs0053.cs b/mcs/errors/cs0053.cs new file mode 100644 index 00000000000..6a719af89df --- /dev/null +++ b/mcs/errors/cs0053.cs @@ -0,0 +1,19 @@ +// cs0053.cs: Inconsistent accessibility. Property type is less accessible than property. +// Line: 10 + +using System; + +class ErrorCS0053 { +} + +class Foo { + public ErrorCS0053 Property { + get { return new ErrorCS0053 (); } + } + + public static void Main () { + } + + ErrorCS0053 error; +} + diff --git a/mcs/errors/cs0054.cs b/mcs/errors/cs0054.cs new file mode 100644 index 00000000000..22fcbc24092 --- /dev/null +++ b/mcs/errors/cs0054.cs @@ -0,0 +1,19 @@ +// cs0054.cs: Inconsistent accessibility. Indexer return type is less accessible than indexer. +// Line: + +using System; + +class ErrorCS0054 { +} + +class Foo { + ErrorCS0054[] errors; + + public ErrorCS0054 this[int i] { + get { return new ErrorCS0054 (); } + } + + public static void Main () { + } +} + diff --git a/mcs/errors/cs0055.cs b/mcs/errors/cs0055.cs new file mode 100644 index 00000000000..1ba12ae0a8d --- /dev/null +++ b/mcs/errors/cs0055.cs @@ -0,0 +1,17 @@ +// cs0055.cs: Inconsistent accessibility. Parameter type is less accessible than indexer. +// Line: 10 + +using System; + +class ErrorCS0055 { +} + +class Foo { + public ErrorCS0055 this[ErrorCS0055 e] { + get { return new ErrorCS0055 (); } + } + + public static void Main () { + } +} + diff --git a/mcs/errors/cs0056.cs b/mcs/errors/cs0056.cs new file mode 100644 index 00000000000..4029dda4509 --- /dev/null +++ b/mcs/errors/cs0056.cs @@ -0,0 +1,15 @@ +// cs0056.cs: Incompatible accessibility. Operator return type is less accessible than operator. +// Line: 10 + +using System; + +class ErrorCS0056 { +} + +class Foo { + public static implicit operator ErrorCS0056(Foo foo) { + return new ErrorCS0056 (); + } + public static void Main () { + } +} diff --git a/mcs/errors/cs0057.cs b/mcs/errors/cs0057.cs new file mode 100644 index 00000000000..5fdd86ceab5 --- /dev/null +++ b/mcs/errors/cs0057.cs @@ -0,0 +1,17 @@ +// cs0057.cs: Inconsisten accessibility. Parameter type is less accessible than operator. +// Line: 10 + +using System; + +class ErrorCS0057 { +} + +class Foo { + public static implicit operator ErrorCS0057(Foo bar) { + return new ErrorCS0057 (); + } + + public static void Main () { + } +} + diff --git a/mcs/errors/cs0058.cs b/mcs/errors/cs0058.cs new file mode 100644 index 00000000000..dce4fa3aed0 --- /dev/null +++ b/mcs/errors/cs0058.cs @@ -0,0 +1,15 @@ +// cs0058.cs: Incompatible accessibility. Parameter type is less accessible than delegate. +// Line: 10 + +using System; + +class ErrorCS0058 { +} + +class Foo { + public delegate ErrorCS0058 Delegate (); + + public static void Main () { + } +} + diff --git a/mcs/errors/cs0059.cs b/mcs/errors/cs0059.cs new file mode 100644 index 00000000000..6ce96ab66fd --- /dev/null +++ b/mcs/errors/cs0059.cs @@ -0,0 +1,15 @@ +// cs0059.cs: Iconsisten accessibility. Parameter type less accessible than delegate. +// Line: 10 + +using System; + +class ErrorCS0059 { +} + +class Foo { + public delegate void ErrorCS0059Delegate (ErrorCS0059 e); + + public static void Main () { + } +} + diff --git a/mcs/errors/cs0061.cs b/mcs/errors/cs0061.cs new file mode 100644 index 00000000000..6866cc38a33 --- /dev/null +++ b/mcs/errors/cs0061.cs @@ -0,0 +1,16 @@ +// cs0061.cs: Inconsistent accessibility. Base interface less accessible than interface. +// Line: 9 + +using System; + +protected interface IFoo { +} + +public interface IBar : IFoo { +} + +class ErrorCS0061 { + public static void Main () { + } +} + diff --git a/mcs/errors/cs0066.cs b/mcs/errors/cs0066.cs new file mode 100644 index 00000000000..e7e6f5e3479 --- /dev/null +++ b/mcs/errors/cs0066.cs @@ -0,0 +1,25 @@ +// cs0066.cs : 'Button.Click' : event must be of a delegate type +// Line : 10 + +using System; + +public delegate void EventHandler (object sender, EventArgs e); + +public class Button { + + public event Blah Click; + + public void Reset () + { + Click = null; + } +} + +public class Blah { + + public static void Main () + { + Blah b = new Blah (); + } + +} diff --git a/mcs/errors/cs0067.cs b/mcs/errors/cs0067.cs new file mode 100644 index 00000000000..8438892e435 --- /dev/null +++ b/mcs/errors/cs0067.cs @@ -0,0 +1,16 @@ +// cs0067.cs: The event is never used. +// Line: 11 + +using System; + +class ErrorCS0067 { + public delegate void FooHandler (); +} + +class Foo { + public event ErrorCS0067.FooHandler OnFoo; + + public static void Main () { + } +} + diff --git a/mcs/errors/cs0068.cs b/mcs/errors/cs0068.cs new file mode 100644 index 00000000000..f9565ad4a8e --- /dev/null +++ b/mcs/errors/cs0068.cs @@ -0,0 +1,15 @@ +// cs0068.cs: Event in interface can't have initializer. +// Line: 14 + +using System; + +class ErrorCS0068 { + public delegate void FooHandler (); + public void method () {} + public static void Main () { + } +} + +interface IFoo { + event ErrorCS0068.FooHandler OnFoo = new ErrorCS0068.FooHandler (ErrorCS0068.method); +} diff --git a/mcs/errors/cs0069.cs b/mcs/errors/cs0069.cs new file mode 100644 index 00000000000..dfbe7fc3094 --- /dev/null +++ b/mcs/errors/cs0069.cs @@ -0,0 +1,18 @@ +// cs0069.cs: Event cannot have add or remove accessors in an interface. +// Line: 13 + +using System; + +class ErrorCS0069 { + public delegate void FooHandler (); + public static void Main () { + } +} + +interface IBar { + event OnFoo { + add { } + remove { } + } +} + diff --git a/mcs/errors/cs0070.cs b/mcs/errors/cs0070.cs new file mode 100644 index 00000000000..826c97b301a --- /dev/null +++ b/mcs/errors/cs0070.cs @@ -0,0 +1,30 @@ +// cs0070.cs : The event 'Click' can only appear on the left-side of a += or -= (except when used from within the type 'Button') +// Line : 20 + +using System; + +public delegate void EventHandler (int i, int j); + +public class Button { + + public event EventHandler Click; + +} + +public class Blah { + + Button Button1 = new Button (); + + public void Connect () + { + Button1.Click = new EventHandler (Button1_Click); + } + + public void Button1_Click (int i, int j) + { + } + + public static void Main () + { + } +} diff --git a/mcs/errors/cs0071.cs b/mcs/errors/cs0071.cs new file mode 100644 index 00000000000..2ebccf4c67c --- /dev/null +++ b/mcs/errors/cs0071.cs @@ -0,0 +1,17 @@ +// cs0071.cs: An explicit implementation of an event must use property syntax. +// Line: 13 + +using System; + +public delegate void Foo (object source); + +interface IFoo { + event Foo OnFoo; +} + +class ErrorCS0071 : IFoo { + event Foo IFoo.OnFoo () { } + public static void Main () { + } +} + diff --git a/mcs/errors/cs0072.cs b/mcs/errors/cs0072.cs new file mode 100644 index 00000000000..b297e6daae9 --- /dev/null +++ b/mcs/errors/cs0072.cs @@ -0,0 +1,31 @@ +// cs0072.cs: An event can override anything but another event. +// Line: 16 + +using System; + +class ErrorCS0072 { + delegate void FooHandler (); + protected void Callback () { + } + protected virtual event FooHandler OnFoo; +} + +class Child : ErrorCS0072 { + // We are trying to override a method with an event. + // To get this right comment the next line and uncomment the others below. + protected override event FooHandler Callback { + //protected override event FooHandler OnFoo { + add { + Callback += value; + //OnFoo += value; + } + remove { + Callback -= value; + //OnFoo -= value; + } + } + + public static void Main () { + } +} + diff --git a/mcs/errors/cs0073.cs b/mcs/errors/cs0073.cs new file mode 100644 index 00000000000..b2793dffc3c --- /dev/null +++ b/mcs/errors/cs0073.cs @@ -0,0 +1,17 @@ +// cs0073.cs: An add or remove accessor must have a body. +// Line: 9 + +using System; + +class ErrorCS0073 { + delegate void Handler (); + event Handler OnFoo { + add; + remove { + OnFoo -= value; + } + } + public static void Main () { + } +} + diff --git a/mcs/errors/cs0074.cs b/mcs/errors/cs0074.cs new file mode 100644 index 00000000000..d644e1aaf1f --- /dev/null +++ b/mcs/errors/cs0074.cs @@ -0,0 +1,12 @@ +// cs0074.cs: Abstracts events can't have initializers. +// Line: 8 + +using System; + +abstract class ErrorCS0074 { + delegate void Handler (); + public abstract event Handler OnFoo = null; + public static void Main () { + } +} + diff --git a/mcs/errors/cs0075.cs b/mcs/errors/cs0075.cs new file mode 100644 index 00000000000..3a40c4e4d48 --- /dev/null +++ b/mcs/errors/cs0075.cs @@ -0,0 +1,12 @@ +// cs0075.cs: Casting a negative value needs to have the value in parentheses. +// Line: 9 + +using System; + +class ErrorCS0075 { + static double x; + public static void Main () { + x = (double) -1; + } +} + diff --git a/mcs/errors/cs0076.cs b/mcs/errors/cs0076.cs new file mode 100644 index 00000000000..7b236678a31 --- /dev/null +++ b/mcs/errors/cs0076.cs @@ -0,0 +1,13 @@ +// cs0076.cs: An item in an enumeration can't have an identifier 'value__'. +// Line: 8 + +using System; + +class ErrorCS0076 { + enum Foo { + value__ = 0 + } + public static void Main () { + } +} + diff --git a/mcs/errors/cs0077.cs b/mcs/errors/cs0077.cs new file mode 100644 index 00000000000..88dae1d0f04 --- /dev/null +++ b/mcs/errors/cs0077.cs @@ -0,0 +1,13 @@ +// cs0077.cs: As operator can only be used with reference types. +// Line: 10 + +using System; + +class ErrorCS0077 { + struct Foo { } + public static void Main () { + Foo s1, s2; + s1 = s2 as ErrorCS0077.Foo; + } +} + diff --git a/mcs/errors/cs0078.cs b/mcs/errors/cs0078.cs new file mode 100644 index 00000000000..80c8efadb0a --- /dev/null +++ b/mcs/errors/cs0078.cs @@ -0,0 +1,11 @@ +// cs0078.cs: Compiler Warning level 4. 'l' is easily confused with digit '1'. +// Line: 12 + +using System; + +class ErrorCS0078 { + public static void Main () { + long a = 1l; + } +} + diff --git a/mcs/errors/cs0079.cs b/mcs/errors/cs0079.cs new file mode 100644 index 00000000000..413a1413c04 --- /dev/null +++ b/mcs/errors/cs0079.cs @@ -0,0 +1,29 @@ +// cs0079.cs: Events can only appear on the left hand side of += or -= +// Line: 19 + +using System; + +class ErrorCS0079 { + delegate void Handler (); + event Handler privateEvent; + public event Handler OnFoo { + add { + privateEvent += value; + } + remove { + privateEvent -= value; + } + } + void Callback() { + if (privateEvent != null) + OnFoo(); + } + + public static void Main () { + ErrorCS0079 error = new ErrorCS0079 (); + error.OnFoo += new Handler (error.Callback); + error.privateEvent (); + } +} + + diff --git a/mcs/errors/cs0100.cs b/mcs/errors/cs0100.cs new file mode 100644 index 00000000000..959bf9382a9 --- /dev/null +++ b/mcs/errors/cs0100.cs @@ -0,0 +1,24 @@ +// cs0100.cs: same parameters name in a method declaration. +// Line: 6 +// +// Author: +// Alejandro Sánchez Acosta <raciel@es.gnu.org> +// +// (C) Alejandro Sánchez Acosta +// + +public class X +{ + public void Add (int a, int a) + { + int c; + c= a + a; + Console.WriteLine (c); + } + + static void Main () + { + this.Add (3, 5); + } +} + diff --git a/mcs/errors/cs0101.cs b/mcs/errors/cs0101.cs new file mode 100644 index 00000000000..3ed5566decf --- /dev/null +++ b/mcs/errors/cs0101.cs @@ -0,0 +1,28 @@ +// cs0101: namespace already contains a definition for this enum +// Line: 10 +using System; + +public enum SomeEnum { + Something1, + Something2 +} + +public enum SomeEnum { + Dog, + Fish, + Cat +} + +public class DupeEnumTest { + public static void Main(string[] args) { + SomeEnum someEnum = SomeEnum.Dog; + Console.WriteLine("SomeEnum Result: " + someEnum.ToString +()); + } +} + + + + + + diff --git a/mcs/errors/cs0104.cs b/mcs/errors/cs0104.cs new file mode 100755 index 00000000000..7192c8ab9cf --- /dev/null +++ b/mcs/errors/cs0104.cs @@ -0,0 +1,20 @@ +// cs0104.cs: Ambiguous type reference +// Line: 16 +namespace A { + class X { + } +} + +namespace B { + class X { + } +} + +namespace C { + using A; + using B; + class D : X { + + static void Main () {} + } +} diff --git a/mcs/errors/cs0105.cs b/mcs/errors/cs0105.cs new file mode 100644 index 00000000000..7e32e92c2d4 --- /dev/null +++ b/mcs/errors/cs0105.cs @@ -0,0 +1,11 @@ +using System; +using System; + +public class X +{ + static int Main () + { + int a=5; + return a; + } +} diff --git a/mcs/errors/cs0106.cs b/mcs/errors/cs0106.cs new file mode 100755 index 00000000000..22a7dabeb58 --- /dev/null +++ b/mcs/errors/cs0106.cs @@ -0,0 +1,12 @@ +// cs0106: virtual, abstract or public are not valid for explicit interface implementations +// Line: 8 +interface A { + void B (); +} + +class X : A { + public virtual void A.B () {} + + static void Main () {} +} + diff --git a/mcs/errors/cs0107.cs b/mcs/errors/cs0107.cs index c3b1405093f..fd02f7e2c2a 100755 --- a/mcs/errors/cs0107.cs +++ b/mcs/errors/cs0107.cs @@ -1,6 +1,6 @@ // cs0107.cs: More than one protection modifier // Line: 4 class X { - public private X { + public private class X { } } diff --git a/mcs/errors/cs0108.cs b/mcs/errors/cs0108.cs new file mode 100755 index 00000000000..a516acc7d38 --- /dev/null +++ b/mcs/errors/cs0108.cs @@ -0,0 +1,10 @@ +// cs0108.cs: The new keyword is required on MEMBER because it hides MEMBER2 +// Line: + +class Base { + public void F () {} +} + +class Derived : Base { + void F () {} +} diff --git a/mcs/errors/cs0111.cs b/mcs/errors/cs0111.cs new file mode 100644 index 00000000000..968e204f64a --- /dev/null +++ b/mcs/errors/cs0111.cs @@ -0,0 +1,21 @@ +// cs111.cs : Class `Blah' already contains a definition with the same return value and parameter types for method `Foo' +// Line : 10 + +public class Blah { + + static public void Foo (int i, int j) + { + } + + static public void Foo (int i, int j) + { + } + + public static void Main () + { + int i = 1; + int j = 2; + + Foo (i, j); + } +} diff --git a/mcs/errors/cs0112.cs b/mcs/errors/cs0112.cs new file mode 100644 index 00000000000..e1412d53764 --- /dev/null +++ b/mcs/errors/cs0112.cs @@ -0,0 +1,25 @@ +// cs0112.cs: A static method can not be marked as virtual, abstract or override. +// Line: 13 + +namespace X +{ + public abstract class Foo + { + public abstract int Add (int a, int b); + } + + public class Bar: Foo + { + virtual public static int Add (int a, int b) + { + int c; + c = a + b; + return c; + } + + static int Main () + { + return a; + } + } +} diff --git a/mcs/errors/cs0113.cs b/mcs/errors/cs0113.cs new file mode 100755 index 00000000000..6ddf367cf5d --- /dev/null +++ b/mcs/errors/cs0113.cs @@ -0,0 +1,3 @@ +class X { + public virtual override void Y () {} +} diff --git a/mcs/errors/cs0114.cs b/mcs/errors/cs0114.cs index b3c1f028e24..a617710997d 100755 --- a/mcs/errors/cs0114.cs +++ b/mcs/errors/cs0114.cs @@ -5,5 +5,5 @@ public abstract class X { } class Y : X { - void XX (); + void XX () {} } diff --git a/mcs/errors/cs0115.cs b/mcs/errors/cs0115.cs new file mode 100755 index 00000000000..f3ae9aa468d --- /dev/null +++ b/mcs/errors/cs0115.cs @@ -0,0 +1,5 @@ +class X { + public override void Bla () + { + } +} diff --git a/mcs/errors/cs0116.cs b/mcs/errors/cs0116.cs new file mode 100644 index 00000000000..f4c2644b947 --- /dev/null +++ b/mcs/errors/cs0116.cs @@ -0,0 +1,7 @@ +// cs0116.cs: A namespace cant have members that dont correspond to a class, delegate, interface, union, struct or enum. +// Line: 6 + +namespace Bar +{ + float a; +} diff --git a/mcs/errors/cs0117.cs b/mcs/errors/cs0117.cs index d07e5cf0e52..7b942b47625 100755 --- a/mcs/errors/cs0117.cs +++ b/mcs/errors/cs0117.cs @@ -5,5 +5,6 @@ class T { public static int Main (string [] args ) { int x = 1.E; + return 0; } } diff --git a/mcs/errors/cs0120-2.cs b/mcs/errors/cs0120-2.cs new file mode 100755 index 00000000000..68899fc9e80 --- /dev/null +++ b/mcs/errors/cs0120-2.cs @@ -0,0 +1,26 @@ +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; + +public class Test { + + public Test () : this (Add8(4), 6) { + string hostName = System.Net.Dns.GetHostName (); + Console.WriteLine ("Hostname: " + hostName); + } + + public Test (int i, int j) { + Console.WriteLine ("GOT : " + i + " : " + j); + } + + + public static void Main (String[] args) { + Test t = new Test (); + } + + private int Add8 (int i) { + return i + 8; + } + +} diff --git a/mcs/errors/cs0120-3.cs b/mcs/errors/cs0120-3.cs new file mode 100644 index 00000000000..66faa809f50 --- /dev/null +++ b/mcs/errors/cs0120-3.cs @@ -0,0 +1,14 @@ +// cs0120: `An object reference is required for the nonstatic field, method or property test.method() +// Line: 11 + +class X { + + void method () + { + } + + public static int Main (string [] args){ + X.method (); + return 1; + } +} diff --git a/mcs/errors/cs0120-4.cs b/mcs/errors/cs0120-4.cs new file mode 100644 index 00000000000..bd8e84ad1a7 --- /dev/null +++ b/mcs/errors/cs0120-4.cs @@ -0,0 +1,23 @@ +using System; + +class X { + // Public properties and variables. + public string Y; + + // Constructors. + public X() + { + } + + // Public static methods. + public static void Main(string[] Arguments) + { + X.Y = ""; + } +} + + + + + + diff --git a/mcs/errors/cs0121.cs b/mcs/errors/cs0121.cs new file mode 100755 index 00000000000..7a8797ee680 --- /dev/null +++ b/mcs/errors/cs0121.cs @@ -0,0 +1,17 @@ +// cs0121.cs: ambigous call when selecting function due to implicit casts +// Line: 15 + +class X { + static void a (int i, double d) + { + } + + static void a (double d, int i) + { + } + + public static void Main () + { + a (0, 0); + } +} diff --git a/mcs/errors/cs0122-2.cs b/mcs/errors/cs0122-2.cs new file mode 100644 index 00000000000..264342c6a29 --- /dev/null +++ b/mcs/errors/cs0122-2.cs @@ -0,0 +1,19 @@ +// cs0122.cs: prop is not accessible due to its protection level +// +class A +{ + int i; + + int prop + { + set { i = value; } + } +} + +class B : A +{ + void M () + { + prop = 2; + } +} diff --git a/mcs/errors/cs0122.cs b/mcs/errors/cs0122.cs new file mode 100755 index 00000000000..47078b0fdf8 --- /dev/null +++ b/mcs/errors/cs0122.cs @@ -0,0 +1,18 @@ +// cs0122.cs: y.x is inaccessible due to its protection level +// Line: 15 +using System; + +class Y { + void x () {} + +} + +class X { + static int Main () + { + Y y = new Y (); + + y.x (); + return 0; + } +} diff --git a/mcs/errors/cs0126.cs b/mcs/errors/cs0126.cs new file mode 100644 index 00000000000..f17d4d39607 --- /dev/null +++ b/mcs/errors/cs0126.cs @@ -0,0 +1,9 @@ +// cs0126: an object of type `int' is expected in the return statement +// Line: 7 + +class X { + int Y () + { + return; + } +} diff --git a/mcs/errors/cs0131.cs b/mcs/errors/cs0131.cs new file mode 100755 index 00000000000..ef025a2039a --- /dev/null +++ b/mcs/errors/cs0131.cs @@ -0,0 +1,8 @@ +// cs0131.cs: left hand side of an assignment must be variable, property access or indexer +// Line: +class X { + void A () + { + 5 = 4; + } +} diff --git a/mcs/errors/cs0132.cs b/mcs/errors/cs0132.cs new file mode 100755 index 00000000000..1b4ebf2c7b4 --- /dev/null +++ b/mcs/errors/cs0132.cs @@ -0,0 +1,7 @@ +// cs0132.cs: A static parameter must not have any parameters +// Line: 4 +class X { + static X (int x) + { + } +} diff --git a/mcs/errors/cs0136-2.cs b/mcs/errors/cs0136-2.cs new file mode 100755 index 00000000000..4dc9d547e32 --- /dev/null +++ b/mcs/errors/cs0136-2.cs @@ -0,0 +1,9 @@ +// cs0136.cs: local variable j can not be declared, because there is something with that name already +// Line: 5 +class X { + public static void Bar (int j, params int [] args) + { + foreach (int j in args) + ; + } +} diff --git a/mcs/errors/cs0138.cs b/mcs/errors/cs0138.cs new file mode 100644 index 00000000000..ea95cd91e11 --- /dev/null +++ b/mcs/errors/cs0138.cs @@ -0,0 +1,14 @@ +// cs0138.cs: Using keyword only let you specify a namespace, +// Console is a class not a namespace. +// Line: 5 + +using System; +using System.Console; + +class A +{ + static void Main () + { + Console.WriteLine ("Test cs0138"); + } +} diff --git a/mcs/errors/cs0139.cs b/mcs/errors/cs0139.cs new file mode 100644 index 00000000000..11eb5d7f750 --- /dev/null +++ b/mcs/errors/cs0139.cs @@ -0,0 +1,8 @@ +// cs0139.cs: No loop to exit to in continue or break. +// Line: 6 +class X { + void A () + { + continue; + } +} diff --git a/mcs/errors/cs0140.cs b/mcs/errors/cs0140.cs new file mode 100644 index 00000000000..03a2fc55af2 --- /dev/null +++ b/mcs/errors/cs0140.cs @@ -0,0 +1,17 @@ +// cs0140: A duplicated Label. +// Line: 11 + +namespace cs0140Test +{ + public class A + { + static int Main () + { + L1: int a=0; + L1: a++; + if (a < 3) + goto L1; + return 0; + } + } +} diff --git a/mcs/errors/cs0143.cs b/mcs/errors/cs0143.cs new file mode 100644 index 00000000000..2a448522c42 --- /dev/null +++ b/mcs/errors/cs0143.cs @@ -0,0 +1,16 @@ +// cs0143: Can't find the constructor for a determinated class. +// Line: 11 + +namespace cs0143Test +{ + public class A + { + static void Main () + { + string b="text"; + int c=2; + + A a = new A (b, c); + } + } +} diff --git a/mcs/errors/cs0144-2.cs b/mcs/errors/cs0144-2.cs new file mode 100755 index 00000000000..d6a94543115 --- /dev/null +++ b/mcs/errors/cs0144-2.cs @@ -0,0 +1,13 @@ +// cs0144.cs: can not create instances of abstract classes or interfaces +// Line: 11 +interface X { + void A (); + +} + +class Demo { + static void Main () + { + object x = new X (); + } +} diff --git a/mcs/errors/cs0144.cs b/mcs/errors/cs0144.cs new file mode 100755 index 00000000000..4b754ce5750 --- /dev/null +++ b/mcs/errors/cs0144.cs @@ -0,0 +1,13 @@ +// cs0144.cs: can not create instances of abstract classes or interfaces +// Line: 11 +abstract class X { + public abstract void B (); + +} + +class Demo { + static void Main () + { + object x = new X (); + } +} diff --git a/mcs/errors/cs0146.cs b/mcs/errors/cs0146.cs new file mode 100644 index 00000000000..8b81c046864 --- /dev/null +++ b/mcs/errors/cs0146.cs @@ -0,0 +1,7 @@ +// cs0146.cs: circular class definition +// Line: 6 +class A : B { +} + +class B : A { +} diff --git a/mcs/errors/cs0150.cs b/mcs/errors/cs0150.cs new file mode 100644 index 00000000000..fc67a91086e --- /dev/null +++ b/mcs/errors/cs0150.cs @@ -0,0 +1,14 @@ +// cs0150.cs : +// Line : + +using System; + +public class Blah { + + public static void Main () + { + int foo = 6; + + int [] i = new int [foo] { 0, 1, 2, 3, 4, 5 }; + } +} diff --git a/mcs/errors/cs0151.cs b/mcs/errors/cs0151.cs new file mode 100755 index 00000000000..03ef7c2e9a9 --- /dev/null +++ b/mcs/errors/cs0151.cs @@ -0,0 +1,19 @@ +// cs0151.cs: An integral value expected +// Line: 12 +class Y { + byte b; +} + +class X { + static void Main () + { + Y y = new Y (); + + switch (y){ + case 0: + break; + case 1: + break; + } + } +} diff --git a/mcs/errors/cs0153.cs b/mcs/errors/cs0153.cs new file mode 100755 index 00000000000..c102bfa4672 --- /dev/null +++ b/mcs/errors/cs0153.cs @@ -0,0 +1,8 @@ +// cs0153.cs: goto default only allowed in switch statement +// Line: +class X { + void Main () + { + goto default; + } +} diff --git a/mcs/errors/cs0154.cs b/mcs/errors/cs0154.cs new file mode 100644 index 00000000000..9f53ed8ab9a --- /dev/null +++ b/mcs/errors/cs0154.cs @@ -0,0 +1,24 @@ +// cs0154.cs: The property 'name' can not be used in this context because +// it lacks a get accessor. +// Line: 21 + +public class A +{ + public string name + { + set + { + name = value; + } + } +} + +public class B +{ + public static void Main () + { + A a = new A (); + string b = a.name; + } +} + diff --git a/mcs/errors/cs0155-2.cs b/mcs/errors/cs0155-2.cs new file mode 100644 index 00000000000..c9cdad5d38d --- /dev/null +++ b/mcs/errors/cs0155-2.cs @@ -0,0 +1,12 @@ +// cs0155-2.cs: The type caught or thrown must be derived from System.Exception +// Line: 8 +class X { + static void Main () + { + try { + ; + } catch (int e) { + throw; + } + } +} diff --git a/mcs/errors/cs0155.cs b/mcs/errors/cs0155.cs new file mode 100644 index 00000000000..48f5641434c --- /dev/null +++ b/mcs/errors/cs0155.cs @@ -0,0 +1,9 @@ +// cs0155.cs: The type caught or thrown must be derived from System.Exception +// Line: 7 +class X { + static void Main () + { + int a = 9; + throw a; + } +} diff --git a/mcs/errors/cs0156.cs b/mcs/errors/cs0156.cs new file mode 100644 index 00000000000..18fc9e36fb4 --- /dev/null +++ b/mcs/errors/cs0156.cs @@ -0,0 +1,17 @@ +// CS0156: A throw statement with no argument is only allowed in a catch clause +// Line: 12 + +using System; + +class Foo +{ + static void Main () + { + try { + Console.WriteLine ("Test cs0156"); + throw; + } + catch { + } + } +} diff --git a/mcs/errors/cs0157.cs b/mcs/errors/cs0157.cs new file mode 100755 index 00000000000..a56dd964da0 --- /dev/null +++ b/mcs/errors/cs0157.cs @@ -0,0 +1,12 @@ +// cs0157.cs: Control can not leave the body of a finally clause +// Line: 9 + +class X { + void A () + { + try { + } finally { + return; + } + } +} diff --git a/mcs/errors/cs0159-2.cs b/mcs/errors/cs0159-2.cs new file mode 100755 index 00000000000..aeb30d78a35 --- /dev/null +++ b/mcs/errors/cs0159-2.cs @@ -0,0 +1,16 @@ +// cs0159-2.cs: No such case 20 + +class y { + enum X { A = 1, B = 1, C = 1 } + + static void Main () + { + int x = 1; + + switch (x){ + case 1: break; + case 2: goto case 20; + } + } +} + diff --git a/mcs/errors/cs0159.cs b/mcs/errors/cs0159.cs new file mode 100755 index 00000000000..65aa5cb2dfb --- /dev/null +++ b/mcs/errors/cs0159.cs @@ -0,0 +1,23 @@ +// cs0159.cs: No default target for goto default +// Line: + +class X { + + static int m (int n) + { + switch (n){ + case 0: + goto default; + + case 1: + return 1; + } + + return 10; + } + + static void Main () + { + m (1); + } +} diff --git a/mcs/errors/cs0161.cs b/mcs/errors/cs0161.cs new file mode 100644 index 00000000000..e9e419d032e --- /dev/null +++ b/mcs/errors/cs0161.cs @@ -0,0 +1,9 @@ +// CS0161: Not all code paths return a value +// Line: + +class A +{ + public static int Main () + { + } +} diff --git a/mcs/errors/cs0163.cs b/mcs/errors/cs0163.cs new file mode 100644 index 00000000000..bdf2f9b8a58 --- /dev/null +++ b/mcs/errors/cs0163.cs @@ -0,0 +1,24 @@ +// cs0163.cs: Control cannot fall through from one case label to another +// Line: 17 + + +public class Foo +{ + public static void Main() + { + int a=5; + int b=10; + int c; + + switch (a) + { + case 1: c=a+b; + return; + + case 2: c=a-b; + return; + + case 3: c=a*b; + } + } +} diff --git a/mcs/errors/cs0164.cs b/mcs/errors/cs0164.cs index dbb530460a9..5fc48c41eac 100755 --- a/mcs/errors/cs0164.cs +++ b/mcs/errors/cs0164.cs @@ -1,9 +1,8 @@ // cs0164.cs: This label has not been referenced // Line: 5 class X { - void D () { + static void Main () { a: - return; } } diff --git a/mcs/errors/cs0165.cs b/mcs/errors/cs0165.cs index 48b7c52558d..b3f89b240b9 100755 --- a/mcs/errors/cs0165.cs +++ b/mcs/errors/cs0165.cs @@ -2,7 +2,7 @@ // Line: 9 class T { - public T () + static void Main () { int errors; diff --git a/mcs/errors/cs0169.cs b/mcs/errors/cs0169.cs index 5337e099f00..bcd47c81491 100755 --- a/mcs/errors/cs0169.cs +++ b/mcs/errors/cs0169.cs @@ -6,4 +6,6 @@ class X { void blah () { } + + static void Main () {} } diff --git a/mcs/errors/cs0170.cs b/mcs/errors/cs0170.cs new file mode 100644 index 00000000000..9d7f5a67ee7 --- /dev/null +++ b/mcs/errors/cs0170.cs @@ -0,0 +1,27 @@ +// CS0170: Use of possibly unassigned field `a' +// Line: 23 + +using System; + +namespace cs0170 +{ + public struct Foo { + public int a; + } + + public class Bar + { + public void Inc (int x) + { + ++x; + } + + static void Main () + { + Foo f; + Bar b = new Bar(); + b.Inc (f.a); + Console.WriteLine (f.a); + } + } +} diff --git a/mcs/errors/cs0171.cs b/mcs/errors/cs0171.cs new file mode 100755 index 00000000000..5b2b2343b2a --- /dev/null +++ b/mcs/errors/cs0171.cs @@ -0,0 +1,11 @@ +// cs0171.cs: field x must be initialized before constructor X ends. +// Line: +struct X { + public readonly int x; + + X (int a) + { + } + + static void Main () {} +} diff --git a/mcs/errors/cs0172.cs b/mcs/errors/cs0172.cs new file mode 100755 index 00000000000..2ae816f8eb5 --- /dev/null +++ b/mcs/errors/cs0172.cs @@ -0,0 +1,25 @@ +class X { + public static implicit operator X (Y y) + { + return null; + } +} + +class Y { + public static implicit operator Y (X x) + { + return null; + } +} + +class Z +{ + static void Main () + { + X x = new X (); + Y y = new Y (); + + object d = (x == x) ? x : y; + } + +} diff --git a/mcs/errors/cs0176.cs b/mcs/errors/cs0176.cs index 160d301788e..889971fc117 100755 --- a/mcs/errors/cs0176.cs +++ b/mcs/errors/cs0176.cs @@ -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 () { } } diff --git a/mcs/errors/cs0178.cs b/mcs/errors/cs0178.cs new file mode 100644 index 00000000000..47be8ec08a7 --- /dev/null +++ b/mcs/errors/cs0178.cs @@ -0,0 +1,12 @@ +// cs0178.cs : +// Line : + +using System; + +public class Blah { + + public static void Main () + { + int [,] i = new int [4,2] { 0, 1, 2, 3, 4, 5 }; + } +} diff --git a/mcs/errors/cs0179.cs b/mcs/errors/cs0179.cs new file mode 100755 index 00000000000..ed7eee8895b --- /dev/null +++ b/mcs/errors/cs0179.cs @@ -0,0 +1,14 @@ +// cs0179.cs: member can not be declared extern and have a body +// Line: + +class X { + + public extern int extern_method () + { + } + + public static void Main () + { + } +} + diff --git a/mcs/errors/cs0180.cs b/mcs/errors/cs0180.cs new file mode 100755 index 00000000000..7f1714e7331 --- /dev/null +++ b/mcs/errors/cs0180.cs @@ -0,0 +1,12 @@ +// cs0179.cs: member can not be declared extern and abstract +// Line: + +class X { + + public extern abstract int extern_method (); + + public static void Main () + { + } +} + diff --git a/mcs/errors/cs0182.cs b/mcs/errors/cs0182.cs new file mode 100644 index 00000000000..20ddac44aad --- /dev/null +++ b/mcs/errors/cs0182.cs @@ -0,0 +1,14 @@ +// cs0182.cs : An attribute argument must be a constant expression, typeof expression or array creation expression +// Line : 10 + +using System; + +class My : Attribute { + public My (object obj) { } +} + +[My (null)] +class T { + static void Main() {} +} + diff --git a/mcs/errors/cs0183.cs b/mcs/errors/cs0183.cs new file mode 100755 index 00000000000..781e693dbd0 --- /dev/null +++ b/mcs/errors/cs0183.cs @@ -0,0 +1,13 @@ +// cs0183.cs: the expression is always of the type `x' +// Line: + +class X { + + static void Main () + { + int i = 5; + + if (i is int){ + } + } +} diff --git a/mcs/errors/cs0184.cs b/mcs/errors/cs0184.cs new file mode 100755 index 00000000000..4ff379f6005 --- /dev/null +++ b/mcs/errors/cs0184.cs @@ -0,0 +1,13 @@ +// cs0184.cs: The expression is never of the provided type +// Line: + +class X { + + static void Main () + { + int a = 1; + + if (a is byte){ + } + } +} diff --git a/mcs/errors/cs0185.cs b/mcs/errors/cs0185.cs new file mode 100755 index 00000000000..6efb95560a6 --- /dev/null +++ b/mcs/errors/cs0185.cs @@ -0,0 +1,11 @@ +// cs0185.cs: object is not a reference type (as expected by lock) +// Line: + +class X { + static void Main () + { + lock (5) { + } + } +} + diff --git a/mcs/errors/cs0187.cs b/mcs/errors/cs0187.cs new file mode 100755 index 00000000000..dd9562abd70 --- /dev/null +++ b/mcs/errors/cs0187.cs @@ -0,0 +1,8 @@ +class X { + static void Main () + { + X x = new X(); + + x++; + } +} diff --git a/mcs/errors/cs0191.cs b/mcs/errors/cs0191.cs new file mode 100755 index 00000000000..6b3cc5df250 --- /dev/null +++ b/mcs/errors/cs0191.cs @@ -0,0 +1,12 @@ +// cs0191: can not assign to readonly variable outside constructor +// Line: 8 +class X { + readonly int a; + + void Y () + { + a = 1; + } +} + + diff --git a/mcs/errors/cs0192.cs b/mcs/errors/cs0192.cs new file mode 100644 index 00000000000..17ecc59fa29 --- /dev/null +++ b/mcs/errors/cs0192.cs @@ -0,0 +1,24 @@ +// cs0192.cs: You cannot pass a readonly field by ref or out (except in a constructor) +// Line: 17 + +using System; + +class A +{ + public readonly int a=5; + + public void Inc (ref int a) + { + ++a; + } + + public void IncCall () + { + Inc (ref a); + } + + static void Main () + { + Console.WriteLine ("Test cs0192.cs"); + } +} diff --git a/mcs/errors/cs0193.cs b/mcs/errors/cs0193.cs new file mode 100755 index 00000000000..fe2662a82af --- /dev/null +++ b/mcs/errors/cs0193.cs @@ -0,0 +1,13 @@ +// cs0193.cs: * or -> operator can only be applied to pointer types. +// Line: 8 + +unsafe class X { + static void Main () + { + int a = 0; + if (*a == 0) + return 1; + + return 0; + } +} diff --git a/mcs/errors/cs0196.cs b/mcs/errors/cs0196.cs new file mode 100755 index 00000000000..57dd9c2b7b1 --- /dev/null +++ b/mcs/errors/cs0196.cs @@ -0,0 +1,11 @@ +// cs0196.cs: pointers must be indexed by a single value +// line: 8 +using System; +unsafe class ZZ { + static void Main () { + int *p = null; + + if (p [10,4] == 4) + return; + } +} diff --git a/mcs/errors/cs0197.cs b/mcs/errors/cs0197.cs new file mode 100644 index 00000000000..b80c580f26d --- /dev/null +++ b/mcs/errors/cs0197.cs @@ -0,0 +1,26 @@ +// cs0197.cs: You cant pass by ref or out a member or field of a MarshalByRefObjectClass. +// Line: 14 + +namespace cs0197 +{ + public class A: MarshalByRefObject + { + public string s; + } + + public class B + { + public class ConCat (ref string s) + { + s += ' Error'; + } + + static void Main() + { + A Foo = new A (); + Foo.s = 'cs0197'; + this.ConCat (ref Foo.s); + Console.WriteLine (Foo.s); + } + } +} diff --git a/mcs/errors/cs0198.cs b/mcs/errors/cs0198.cs new file mode 100755 index 00000000000..60bce195511 --- /dev/null +++ b/mcs/errors/cs0198.cs @@ -0,0 +1,12 @@ +// cs0198: can not assign to static readonly variable outside static constructor +// Line: 8 +class X { + static readonly int a; + + static void Y () + { + a = 1; + } +} + + diff --git a/mcs/errors/cs0200.cs b/mcs/errors/cs0200.cs new file mode 100755 index 00000000000..87ec5c6786f --- /dev/null +++ b/mcs/errors/cs0200.cs @@ -0,0 +1,15 @@ +// cs0200: can not assign to property X.P -- it is readonly +// line: 12 +class X { + static int P { + get { + return 1; + } + } + + static int Main () + { + P = 10; + return 1; + } +} diff --git a/mcs/errors/cs0201.cs b/mcs/errors/cs0201.cs new file mode 100644 index 00000000000..a5e3a00c04c --- /dev/null +++ b/mcs/errors/cs0201.cs @@ -0,0 +1,13 @@ +// +// cs0201.cs: if a meaningless statement is encountered error cs0201 have to be thrown +// + +using System; + +public class X +{ + public static void Main () + { + 2 * 3; + } +} diff --git a/mcs/errors/cs0202.cs b/mcs/errors/cs0202.cs new file mode 100644 index 00000000000..4222e17874b --- /dev/null +++ b/mcs/errors/cs0202.cs @@ -0,0 +1,9 @@ +// cs0202.cs: GetEnumerator cant return a pointer, only an instance. +// Line: 6 + +public class Foo +{ + int P* GetEnumerator () + { + } +} diff --git a/mcs/errors/cs0205-2.cs b/mcs/errors/cs0205-2.cs new file mode 100644 index 00000000000..5642245ce63 --- /dev/null +++ b/mcs/errors/cs0205-2.cs @@ -0,0 +1,22 @@ +using System; + +public abstract class A +{ + public abstract int Foobar { get; } +} + +public class B: A +{ + public override int Foobar { + get { + return base.Foobar; + } + } + + static void Main () + { + B b = new B (); + if (b.Foobar == 1) + ; + } +} diff --git a/mcs/errors/cs0205.cs b/mcs/errors/cs0205.cs new file mode 100644 index 00000000000..52c18960321 --- /dev/null +++ b/mcs/errors/cs0205.cs @@ -0,0 +1,22 @@ +// cs0205: can not call abstract base method +// +using System; + +public abstract class A +{ + public abstract void Foobar (); +} + +public class B: A +{ + public override void Foobar () + { + base.Foobar (); + } + + static void Main () + { + B b = new B (); + b.Foobar (); + } +} diff --git a/mcs/errors/cs0206.cs b/mcs/errors/cs0206.cs new file mode 100755 index 00000000000..03c79bf1a9a --- /dev/null +++ b/mcs/errors/cs0206.cs @@ -0,0 +1,16 @@ +// cs0206.cs: indexers or properties can not be used as ref or out arguments +// Line: +class X { + static int P { get { return 1; } set { } } + + static int m (out int v) + { + v = 1; + return 1; + } + + static void Main () + { + m (out P); + } +} diff --git a/mcs/errors/cs0208.cs b/mcs/errors/cs0208.cs new file mode 100644 index 00000000000..b78f1b0e201 --- /dev/null +++ b/mcs/errors/cs0208.cs @@ -0,0 +1,22 @@ +// cs0208.cs: Cannot take the address or size of a variable of a managed type ('cs208.Foo') +// Line: 19 + +namespace cs208 +{ + public class Foo + { + public int Add (int a, int b) + { + return a + b; + } + } + + public class Bar + { + unsafe static void Main () + { + Foo f = new Foo (); + Foo *s = &f; + } + } +} diff --git a/mcs/errors/cs0209.cs b/mcs/errors/cs0209.cs new file mode 100644 index 00000000000..8aa58b38872 --- /dev/null +++ b/mcs/errors/cs0209.cs @@ -0,0 +1,13 @@ +// cs0209.cs: variable in a fixed statement must be a pointer +// Line: 7 +public class A +{ + unsafe static void Main () + { + fixed (string s = null) + { + } + } +} + + diff --git a/mcs/errors/cs0214-2.cs b/mcs/errors/cs0214-2.cs new file mode 100755 index 00000000000..2526a9fc682 --- /dev/null +++ b/mcs/errors/cs0214-2.cs @@ -0,0 +1,7 @@ +class X { + static void Main () + { + int b = 0; + int a = (int *) b; + } +} diff --git a/mcs/errors/cs0214-3.cs b/mcs/errors/cs0214-3.cs new file mode 100755 index 00000000000..e40bbfb7247 --- /dev/null +++ b/mcs/errors/cs0214-3.cs @@ -0,0 +1,12 @@ +struct X { + static unsafe void *a () + { + return null; + } + + static void Main () + { + a (); + } + +} diff --git a/mcs/errors/cs0214.cs b/mcs/errors/cs0214.cs new file mode 100644 index 00000000000..08eb088af39 --- /dev/null +++ b/mcs/errors/cs0214.cs @@ -0,0 +1,5 @@ +// cs0214: Pointer can only be used in unsafe context +// Line: 4 +class X { + void *a; +} diff --git a/mcs/errors/cs0215.cs b/mcs/errors/cs0215.cs new file mode 100644 index 00000000000..3c875505e94 --- /dev/null +++ b/mcs/errors/cs0215.cs @@ -0,0 +1,13 @@ +// cs0215.cs : The return type of operator True or False must be bool +// Line : 11 + +class Blah { + + public static void Main () + { + + } + + public static int operator true (Blah i) {} + +} diff --git a/mcs/errors/cs0216.cs b/mcs/errors/cs0216.cs new file mode 100644 index 00000000000..ca7db926d23 --- /dev/null +++ b/mcs/errors/cs0216.cs @@ -0,0 +1,12 @@ +// cs0216.cs: If you define operator <, you also need to define > +// Line: +class X { + public static X operator < (X a, int b) + { + return null; + } + + static void Main () { + } +} + diff --git a/mcs/errors/cs0221.cs b/mcs/errors/cs0221.cs new file mode 100644 index 00000000000..932272ea7b8 --- /dev/null +++ b/mcs/errors/cs0221.cs @@ -0,0 +1,11 @@ +// cs0221.cs: cannot convert constant value to type, use in checked context +// Line: 5 + +class X { + int a = (int) 0xffffffff; + + static void Main () + { + + } +} diff --git a/mcs/errors/cs0225.cs b/mcs/errors/cs0225.cs new file mode 100755 index 00000000000..4aaf1b20430 --- /dev/null +++ b/mcs/errors/cs0225.cs @@ -0,0 +1,15 @@ +// +// cs0225.cs: params parameter have to be a single dimensional array. +// + +public class X +{ + public static void Test (params int a) + { + } + + public static void Main() + { + Test (1); + } +} diff --git a/mcs/errors/cs0230.cs b/mcs/errors/cs0230.cs new file mode 100755 index 00000000000..d79d153a357 --- /dev/null +++ b/mcs/errors/cs0230.cs @@ -0,0 +1,17 @@ +// +// CS0230.cs: foreach statement must contain the type and the variable identifier +// + +using System; + +class X +{ + public static void Main() + { + int [] a = new int [5] {5, 4, 3, 2, 1}; + + foreach (int in a) { + Console.WriteLine (x); + } + } +} diff --git a/mcs/errors/cs0234.cs b/mcs/errors/cs0234.cs index 3ef7cfab0bc..046394a6d9a 100755 --- a/mcs/errors/cs0234.cs +++ b/mcs/errors/cs0234.cs @@ -1,4 +1,10 @@ //cs0243: NonExistant does not exist in this namespace +using System; using Nonexistant; +class X +{ + static void Main () { + } +} diff --git a/mcs/errors/cs0236.cs b/mcs/errors/cs0236.cs new file mode 100644 index 00000000000..6908792fb22 --- /dev/null +++ b/mcs/errors/cs0236.cs @@ -0,0 +1,15 @@ +//cs0236: A field initializer cannot reference the non-static field, method or property `X.Foo'. + +class X +{ + int Foo { + get { + return 9; + } + } + + long Bar = Foo; + + static void Main () { + } +} diff --git a/mcs/errors/cs0239.cs b/mcs/errors/cs0239.cs new file mode 100644 index 00000000000..0f3608643bc --- /dev/null +++ b/mcs/errors/cs0239.cs @@ -0,0 +1,34 @@ +// cs0239.cs : `X.MyMethod' : cannot override inherited member `Bar.MyMethod' because it is sealed. +// Line : 25 + +using System; + +public class Foo { + + public virtual void MyMethod () + { + Console.WriteLine ("This is me !"); + } +} + +public class Bar : Foo { + + public sealed override void MyMethod () + { + + } + +} + +public class X : Bar { + + public override void MyMethod () + { + + } + + public static void Main () + { + + } +} diff --git a/mcs/errors/cs0242.cs b/mcs/errors/cs0242.cs new file mode 100755 index 00000000000..c775f17342e --- /dev/null +++ b/mcs/errors/cs0242.cs @@ -0,0 +1,11 @@ +// cs0242: operation is not defined for void * +// Line: 8 +using System; +unsafe class ZZ { + static void Main () { + void *p = null; + + if (p [10] == 4) + return; + } +} diff --git a/mcs/errors/cs0246.cs b/mcs/errors/cs0246.cs new file mode 100644 index 00000000000..dfa20eef8ac --- /dev/null +++ b/mcs/errors/cs0246.cs @@ -0,0 +1,9 @@ +// cs0246.cs: can not find type `B' +// Line: 4 +interface A : B { +} + +class X { + static void Main () { + } +} diff --git a/mcs/errors/cs0255.cs b/mcs/errors/cs0255.cs new file mode 100755 index 00000000000..5319b82f5e1 --- /dev/null +++ b/mcs/errors/cs0255.cs @@ -0,0 +1,12 @@ +// cs0255.cs: Can not use stackalloc in finally or catch +// Line: 10 +unsafe class X { + + static void Main () + { + try { + } catch { + char *ptr = stackalloc char [10]; + } + } +} diff --git a/mcs/errors/cs0284.cs b/mcs/errors/cs0284.cs new file mode 100755 index 00000000000..7d867e57120 --- /dev/null +++ b/mcs/errors/cs0284.cs @@ -0,0 +1,9 @@ +// cs0284.cs: Can not create array with negative size +// Line: 7 + +class X { + static void Main () + { + int [] x = new int [-4]; + } +} diff --git a/mcs/errors/cs0500.cs b/mcs/errors/cs0500.cs new file mode 100755 index 00000000000..d59cee21359 --- /dev/null +++ b/mcs/errors/cs0500.cs @@ -0,0 +1,4 @@ +abstract class X { + public abstract void B () { + } +} diff --git a/mcs/errors/cs0503.cs b/mcs/errors/cs0503.cs index 5f05f6af8fb..e8e8e048568 100755 --- a/mcs/errors/cs0503.cs +++ b/mcs/errors/cs0503.cs @@ -1,5 +1,5 @@ // cs0503.cs: The abstract method `Class.X' cannot be marked virtual // Line: 4 -class Class { +abstract class Class { virtual abstract public void X (); } diff --git a/mcs/errors/cs0509.cs b/mcs/errors/cs0509.cs new file mode 100644 index 00000000000..f89988f2cb3 --- /dev/null +++ b/mcs/errors/cs0509.cs @@ -0,0 +1,8 @@ +// cs0509.cs: base class is sealed +// Line: 7 +struct V { + int v; +} + +class X : V { +} diff --git a/mcs/errors/cs0514.cs b/mcs/errors/cs0514.cs new file mode 100644 index 00000000000..86747c11ae8 --- /dev/null +++ b/mcs/errors/cs0514.cs @@ -0,0 +1,9 @@ +// cs0514: Static constructor can not have arguments +// Line: 4 +class X { + static X () : base () + { + } + + static void Main () {} +} diff --git a/mcs/errors/cs0523.cs b/mcs/errors/cs0523.cs new file mode 100755 index 00000000000..43b016e6264 --- /dev/null +++ b/mcs/errors/cs0523.cs @@ -0,0 +1,12 @@ +// cs0523.cs: circular structure definition +// + +struct A { + B b; +} + +struct B { + A a; +} + +class Y { static void Main () {} } diff --git a/mcs/errors/cs0527-2.cs b/mcs/errors/cs0527-2.cs new file mode 100644 index 00000000000..e312377061b --- /dev/null +++ b/mcs/errors/cs0527-2.cs @@ -0,0 +1,8 @@ +class A1 { +} + +class A2 { +} + +class B : A1, A2 { +} diff --git a/mcs/errors/cs0527.cs b/mcs/errors/cs0527.cs new file mode 100644 index 00000000000..994add02c67 --- /dev/null +++ b/mcs/errors/cs0527.cs @@ -0,0 +1,7 @@ +// cs0527: type in interface list is not an interface +// Line: 6 +class X { +} + +interface A : X { +} diff --git a/mcs/errors/cs0528.cs b/mcs/errors/cs0528.cs new file mode 100755 index 00000000000..84b1d06cef0 --- /dev/null +++ b/mcs/errors/cs0528.cs @@ -0,0 +1,10 @@ +// cs0528: `A' is already listed in interface list +// Line: 6 +interface A { + void stuff (); +} +class C: A, A { + public void stuff () {} + static void Main() {} +} + diff --git a/mcs/errors/cs0529.cs b/mcs/errors/cs0529.cs new file mode 100644 index 00000000000..52e725162d0 --- /dev/null +++ b/mcs/errors/cs0529.cs @@ -0,0 +1,7 @@ +// cs0529: Recursive interface definition +// Line: 3 +interface A : B { +} + +interface B : A { +} diff --git a/mcs/errors/cs0534.cs b/mcs/errors/cs0534.cs index f17b8a070ec..fe865887ce1 100755 --- a/mcs/errors/cs0534.cs +++ b/mcs/errors/cs0534.cs @@ -6,5 +6,6 @@ abstract class X { } class Y : X { +static void Main (){} } diff --git a/mcs/errors/cs0539.cs b/mcs/errors/cs0539.cs new file mode 100755 index 00000000000..a9bf22fc40f --- /dev/null +++ b/mcs/errors/cs0539.cs @@ -0,0 +1,10 @@ +// cs0539.cs: Member in explicit interface declaration is not a member of the interface +// Line: + +interface A { +} + +class X : A { + void A.B () {} + static void Main () {} +} diff --git a/mcs/errors/cs0540.cs b/mcs/errors/cs0540.cs new file mode 100755 index 00000000000..25d5d78ade1 --- /dev/null +++ b/mcs/errors/cs0540.cs @@ -0,0 +1,11 @@ +// cs0540.cs: containing class does not implement interface +// Line: + +interface A { +} + +class B { + void A.B () {} + + static void Main () {} +} diff --git a/mcs/errors/cs0543.cs b/mcs/errors/cs0543.cs new file mode 100644 index 00000000000..b59d0e834f5 --- /dev/null +++ b/mcs/errors/cs0543.cs @@ -0,0 +1,14 @@ +// cs1008.cs : Enumerator value for 'Bar' is too large to fit in its type +// Line : 9 + +public class Blah { + + public enum MyEnum : byte { + Foo = 255, + Bar + } + + public static void Main () + { + } +} diff --git a/mcs/errors/cs0552.cs b/mcs/errors/cs0552.cs new file mode 100755 index 00000000000..7fe395005de --- /dev/null +++ b/mcs/errors/cs0552.cs @@ -0,0 +1,17 @@ +// cs0552.cs: user-defined conversion to/from interface +// Line: 12 +// +using System; +using System.IO; + +// +// +// Implicit conversion to an interface is not permitted +// +class NoIDispose { + public static implicit operator IDisposable (NoIDispose a) + { + return a.x; + } +} + diff --git a/mcs/errors/cs0555.cs b/mcs/errors/cs0555.cs new file mode 100644 index 00000000000..110f952d25f --- /dev/null +++ b/mcs/errors/cs0555.cs @@ -0,0 +1,11 @@ +// cs0555.cs : User-defined conversion cannot take an object of the enclosing type +// and convert to an object of the enclosing type +// Line : 8 + +class Blah { + + public static void Main () {} + + public static implicit operator Blah (Blah i) {} + +} diff --git a/mcs/errors/cs0556.cs b/mcs/errors/cs0556.cs new file mode 100644 index 00000000000..36ff437d65b --- /dev/null +++ b/mcs/errors/cs0556.cs @@ -0,0 +1,10 @@ +// cs0556.cs : User-defined conversion must convert to or from the enclosing type +// Line : 8 + +class Blah { + + public static void Main () {} + + public static implicit operator int (int i) {} + +} diff --git a/mcs/errors/cs0563.cs b/mcs/errors/cs0563.cs new file mode 100644 index 00000000000..af369883b2c --- /dev/null +++ b/mcs/errors/cs0563.cs @@ -0,0 +1,7 @@ +// cs0563.cs: One of the parameters to the binary operator should be the containing type +// Line: 4 +class X { + public static int operator + (int a, int b) + { + } +} diff --git a/mcs/errors/cs0574.cs b/mcs/errors/cs0574.cs new file mode 100755 index 00000000000..1b88bf0173f --- /dev/null +++ b/mcs/errors/cs0574.cs @@ -0,0 +1,13 @@ +// cs0574.cs: Name of destructor must match name of class: +// Line: 6 + +class X { + + ~Y () + { + } + + static void Main () + { + } +} diff --git a/mcs/errors/cs0575.cs b/mcs/errors/cs0575.cs new file mode 100755 index 00000000000..16d0b7aa49e --- /dev/null +++ b/mcs/errors/cs0575.cs @@ -0,0 +1,12 @@ +// cs0575.cs: destructors are only allowed in class types +// Line: 5 +struct X { + + ~X () + { + } + + static void Main () + { + } +} diff --git a/mcs/errors/cs0579.cs b/mcs/errors/cs0579.cs new file mode 100644 index 00000000000..e000014b835 --- /dev/null +++ b/mcs/errors/cs0579.cs @@ -0,0 +1,14 @@ +// cs0579.cs : Duplicate 'AssemblyKeyName' attribute
+// Line :
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+
+[assembly: AssemblyKeyName("")]
+[assembly: AssemblyKeyName("")]
+
+public class Blah {
+
+ public static void Main () { }
+}
diff --git a/mcs/errors/cs0592.cs b/mcs/errors/cs0592.cs new file mode 100644 index 00000000000..02dd459cdbe --- /dev/null +++ b/mcs/errors/cs0592.cs @@ -0,0 +1,29 @@ +// cs0592.cs : Attribute 'Simple' is not valid on this declaration type. It is valid on 'constructor' declarations only. +// Line : 22 + +using System; + +[AttributeUsage (AttributeTargets.Constructor, AllowMultiple = true)] + public class SimpleAttribute : Attribute { + + string name = null; + + public string MyNamedArg; + + public SimpleAttribute (string name) + { + this.name = name; + } + + + } + +[Simple ("Dummy", MyNamedArg = "Dude!")] + public class Blah { + + public static void Main () + { + } + } + + diff --git a/mcs/errors/cs0594-2.cs b/mcs/errors/cs0594-2.cs new file mode 100755 index 00000000000..94b44f43770 --- /dev/null +++ b/mcs/errors/cs0594-2.cs @@ -0,0 +1,8 @@ +//
+// cs0594: Floating-point constant is outside the range for type 'decimal|double|float'
+
+class X {
+ public static void Main() {
+ double dbl = 1.0e99999;
+ }
+}
diff --git a/mcs/errors/cs0594-3.cs b/mcs/errors/cs0594-3.cs new file mode 100755 index 00000000000..e105d22aaf8 --- /dev/null +++ b/mcs/errors/cs0594-3.cs @@ -0,0 +1,8 @@ +//
+// cs0594: Floating-point constant is outside the range for type 'decimal|double|float'
+
+class X {
+ public static void Main() {
+ float f = 1.0e999999f;
+ }
+}
diff --git a/mcs/errors/cs0594.cs b/mcs/errors/cs0594.cs new file mode 100755 index 00000000000..334dd35333a --- /dev/null +++ b/mcs/errors/cs0594.cs @@ -0,0 +1,8 @@ +//
+// cs0594: Floating-point constant is outside the range for type 'decimal|double|float'
+
+class X {
+ public static void Main() {
+ decimal d = 12311111111111111111111111111111111111111111111111m;
+ }
+}
diff --git a/mcs/errors/cs0601.cs b/mcs/errors/cs0601.cs new file mode 100644 index 00000000000..020787e74cf --- /dev/null +++ b/mcs/errors/cs0601.cs @@ -0,0 +1,11 @@ +// cs0601.cs : The DllImport attribute must be specified on a method marked 'static' and 'extern'. +// Line : 9 + +using System; +using System.Runtime.InteropServices; + +class Test { + [DllImport("cygwin1.dll", EntryPoint="puts", CharSet=CharSet.Ansi)] + public extern int puts (string name); + +} diff --git a/mcs/errors/cs0616.cs b/mcs/errors/cs0616.cs new file mode 100755 index 00000000000..ecb7f28cda7 --- /dev/null +++ b/mcs/errors/cs0616.cs @@ -0,0 +1,12 @@ +// cs0616.cs: 'FakeAttribute': is not an attribute class +// Line: 8 + +class FakeAttribute { +} + +class T { + [Fake] + static int Main() { + return 0; + } +} diff --git a/mcs/errors/cs0617.cs b/mcs/errors/cs0617.cs new file mode 100644 index 00000000000..e75266d9d1f --- /dev/null +++ b/mcs/errors/cs0617.cs @@ -0,0 +1,26 @@ +// cs0617,cs : 'MyNamedArg' is not a valid named attribute argument. Named attribute arguments must be fields which are not readonly, static or const, or properties with a set accessor which are not static. +// Line : 20 + +using System; + +[AttributeUsage (AttributeTargets.Class, AllowMultiple = true)] + public class SimpleAttribute : Attribute { + + string name = null; + + public readonly string MyNamedArg; + + public SimpleAttribute (string name) + { + this.name = name; + } + + } + +[Simple ("Dummy", MyNamedArg = "Dude!")] + public class Blah { + + public static void Main () + { + } + } diff --git a/mcs/errors/cs0621.cs b/mcs/errors/cs0621.cs index 014fd39ba92..87bc932088c 100755 --- a/mcs/errors/cs0621.cs +++ b/mcs/errors/cs0621.cs @@ -1,5 +1,5 @@ // cs0621.cs: X.method virtual or abstract methods can not be private // Line: class X { - virtual void method (); + virtual void method () {} } diff --git a/mcs/errors/cs0642.cs b/mcs/errors/cs0642.cs new file mode 100755 index 00000000000..9c73cd6baf1 --- /dev/null +++ b/mcs/errors/cs0642.cs @@ -0,0 +1,6 @@ +class X{ + static void Main () + { + if (true); + } +} diff --git a/mcs/errors/cs0644.cs b/mcs/errors/cs0644.cs new file mode 100755 index 00000000000..5e93f4ef509 --- /dev/null +++ b/mcs/errors/cs0644.cs @@ -0,0 +1,4 @@ +// cs0644.cs: Cannot inherit from special class +// Line: 3 +class X : System.ValueType { +} diff --git a/mcs/errors/cs0645.cs b/mcs/errors/cs0645.cs new file mode 100755 index 00000000000..ff866d9dcad --- /dev/null +++ b/mcs/errors/cs0645.cs @@ -0,0 +1,4 @@ +// cs0645.cs: identifier too long +// Line: 3 +class aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { +} diff --git a/mcs/errors/cs0646.cs b/mcs/errors/cs0646.cs new file mode 100644 index 00000000000..78b7f4e3c77 --- /dev/null +++ b/mcs/errors/cs0646.cs @@ -0,0 +1,26 @@ +// cs0646.cs : Cannot specify the DefaultMember attribute on a type containing an indexer +// Line : 8 + +using System; +using System.Reflection; + +[DefaultMember ("Item")] +public class Foo { + + string bar; + + public static void Main () + { + Console.WriteLine ("foo"); + } + + string this [int idx] { + get { + return "foo"; + } + set { + bar = value; + } + } +} + diff --git a/mcs/errors/cs0647.cs b/mcs/errors/cs0647.cs new file mode 100644 index 00000000000..696e83467cb --- /dev/null +++ b/mcs/errors/cs0647.cs @@ -0,0 +1,9 @@ +// cs0647: Format of GUID is invalid +// Line: 5 +using System.Runtime.InteropServices; + +[Guid ("aaa")] + +class X { +static void Main () {} +} diff --git a/mcs/errors/cs0658.cs b/mcs/errors/cs0658.cs new file mode 100644 index 00000000000..e4da1e82b72 --- /dev/null +++ b/mcs/errors/cs0658.cs @@ -0,0 +1,18 @@ +// cs0658.cs : Invalid attribute location "blah" +// Line : 8 + +public class MyClass { + + delegate int MyDelegate (int i, int j); + + [blah:Help("blah")] + public static MyClass operator/ (MyClass i, MyClass j) + { + + } + + public static implicit operator MyClass (Object o) + { + + } +} diff --git a/mcs/errors/cs0664.cs b/mcs/errors/cs0664.cs new file mode 100755 index 00000000000..daa1f39b717 --- /dev/null +++ b/mcs/errors/cs0664.cs @@ -0,0 +1,8 @@ +// cs0664.cs: Literal of type double cannot be implicity converted to Float, use F suffix +// Line: 6 +class X { + void A () + { + float f = 2.0; + } +} diff --git a/mcs/errors/cs0668.cs b/mcs/errors/cs0668.cs new file mode 100755 index 00000000000..04408a390d2 --- /dev/null +++ b/mcs/errors/cs0668.cs @@ -0,0 +1,28 @@ +// cs0668.cs: Two indexers have different names, they should have the same name across the board. +// Line: + +using System.Runtime.CompilerServices; +class A { + [IndexerName ("Blah")] + int this [int a] { + get { return 1; } + } + + [IndexerName ("Foo")] + int this [string b] { + get { return 2; } + } + + public static int Main () + { + int a = 5; + + if (!(a is object)) + return 3; + + return 0; + } +} + + + diff --git a/mcs/errors/cs0677.cs b/mcs/errors/cs0677.cs new file mode 100755 index 00000000000..822724a9b53 --- /dev/null +++ b/mcs/errors/cs0677.cs @@ -0,0 +1,12 @@ +// cs0677.cs: X.a volatile field can not be of type "A" +// Line: 8 +using System; + +struct A { int a; } + +class X { + public volatile A a; + static void Main () + { + } +} diff --git a/mcs/errors/cs1008.cs b/mcs/errors/cs1008.cs new file mode 100644 index 00000000000..3c49e166dd8 --- /dev/null +++ b/mcs/errors/cs1008.cs @@ -0,0 +1,14 @@ +// cs1008.cs : Type byte, sbyte, short, ushort, int, uint, long, or ulong expected +// Line : 7 + +public class Blah { + + public enum MyEnum { + Foo = "foo", + Bar + } + + public static void Main () + { + } +} diff --git a/mcs/errors/cs1010.cs b/mcs/errors/cs1010.cs new file mode 100644 index 00000000000..f70d4910328 --- /dev/null +++ b/mcs/errors/cs1010.cs @@ -0,0 +1,8 @@ +// cs1010.cs : Newline in constant
+// Line : 6
+
+class X
+{
+ static string s = "Hello
+world!";
+}
\ No newline at end of file diff --git a/mcs/errors/cs1019.cs b/mcs/errors/cs1019.cs new file mode 100644 index 00000000000..4fe30f842f7 --- /dev/null +++ b/mcs/errors/cs1019.cs @@ -0,0 +1,27 @@ +// cs1019.cs : Overloadable unary operator expected +// Line : 18 + +public class MyClass { + + public int this[int ndx] + { + get { } + set { } + } + + public event EventHandler Click + { + add { } + remove { } + } + + public static MyClass operator/ (MyClass i) + { + + } + + public static implicit operator MyClass (Object o) + { + + } +} diff --git a/mcs/errors/cs1020.cs b/mcs/errors/cs1020.cs new file mode 100644 index 00000000000..891a613331f --- /dev/null +++ b/mcs/errors/cs1020.cs @@ -0,0 +1,28 @@ +// cs1020.cs : Overloadable binary operator expected +// Line : 19 + + +public class MyClass { + + public int this[int ndx] + { + get { } + set { } + } + + public event EventHandler Click + { + add { } + remove { } + } + + public static MyClass operator++ (MyClass i, MyClass j) + { + + } + + public static implicit operator MyClass (Object o) + { + + } +} diff --git a/mcs/errors/cs1021-2.cs b/mcs/errors/cs1021-2.cs new file mode 100755 index 00000000000..8507e2737c1 --- /dev/null +++ b/mcs/errors/cs1021-2.cs @@ -0,0 +1,8 @@ +//
+// cs1021: Integral constant is too large
+
+class X {
+ public static void Main() {
+ int h = 0xffffffffffffffffffffffffff;
+ }
+}
diff --git a/mcs/errors/cs1021.cs b/mcs/errors/cs1021.cs new file mode 100755 index 00000000000..50b5f591c1f --- /dev/null +++ b/mcs/errors/cs1021.cs @@ -0,0 +1,8 @@ +//
+// cs1021: Integral constant is too large
+
+class X {
+ public static void Main() {
+ int i = 123821738792178327198;
+ }
+}
diff --git a/mcs/errors/cs1032.cs b/mcs/errors/cs1032.cs new file mode 100755 index 00000000000..e6640a68fe9 --- /dev/null +++ b/mcs/errors/cs1032.cs @@ -0,0 +1,8 @@ +// cs1032: tokens seen before define +// Line: 4 +class X { +#define A + + static void Main () { + } +} diff --git a/mcs/errors/cs1033.cs b/mcs/errors/cs1033.cs new file mode 100644 index 00000000000..09eb11104c2 --- /dev/null +++ b/mcs/errors/cs1033.cs @@ -0,0 +1,7 @@ +// cs1033.cs : @ must be followed by " (or identifier)
+// Line : 6
+
+class X
+{
+ static string s = @ ;
+}
diff --git a/mcs/errors/cs1039.cs b/mcs/errors/cs1039.cs new file mode 100644 index 00000000000..df6c8f7d63f --- /dev/null +++ b/mcs/errors/cs1039.cs @@ -0,0 +1,6 @@ +// cs1039.cs : Unterminated string constant
+// Line : 6
+
+class X
+{
+ static string s = "foo
\ No newline at end of file diff --git a/mcs/errors/cs1501-2.cs b/mcs/errors/cs1501-2.cs new file mode 100755 index 00000000000..18d3b1a381d --- /dev/null +++ b/mcs/errors/cs1501-2.cs @@ -0,0 +1,14 @@ +// cs1501: no match for this argument list +// Line: 11 +class X { + + X (int a) + { + } + + static void Main () + { + new X (); + } +} + diff --git a/mcs/errors/cs1501-3.cs b/mcs/errors/cs1501-3.cs new file mode 100644 index 00000000000..e9a8573c826 --- /dev/null +++ b/mcs/errors/cs1501-3.cs @@ -0,0 +1,8 @@ +// CS1501: No overload for method 'X' takes '2' arguments +public struct X { + public X(int i) { } + + public static void Main() { + X x = new X("foo", "bar"); + } +} diff --git a/mcs/errors/cs1510.cs b/mcs/errors/cs1510.cs new file mode 100755 index 00000000000..4feba3810f6 --- /dev/null +++ b/mcs/errors/cs1510.cs @@ -0,0 +1,13 @@ +// cs1510: an lvalue is required for ref or out argument +// Line: 11 +class X { + public static void m (ref int i) + { + i++; + } + + static void Main () + { + m (ref 4); + } +} diff --git a/mcs/errors/cs1511.cs b/mcs/errors/cs1511.cs new file mode 100755 index 00000000000..4ec26c689b4 --- /dev/null +++ b/mcs/errors/cs1511.cs @@ -0,0 +1,14 @@ +// cs1511.cs: Base modifier not allowed in static code +// Line: + +class Y { + public int a; +} + +class X : Y { + + static void Main () + { + base.a = 1; + } +} diff --git a/mcs/errors/cs1513.cs b/mcs/errors/cs1513.cs new file mode 100755 index 00000000000..819528ced96 --- /dev/null +++ b/mcs/errors/cs1513.cs @@ -0,0 +1,3 @@ +namespace X { + + diff --git a/mcs/errors/cs1518.cs b/mcs/errors/cs1518.cs new file mode 100755 index 00000000000..89036e1ee62 --- /dev/null +++ b/mcs/errors/cs1518.cs @@ -0,0 +1,6 @@ +//cs1518.cs: namespace can only contain class, interface, enum, struct or delegate +// Line: 5 +namespace X { + + sealed fe {} +} diff --git a/mcs/errors/cs1523.cs b/mcs/errors/cs1523.cs new file mode 100755 index 00000000000..fda07fd98f6 --- /dev/null +++ b/mcs/errors/cs1523.cs @@ -0,0 +1,14 @@ +// cs1523: case or default must precede code in switch statement +// Line: 11 + +class X { + + static void Main () + { + int i = 0; + + switch (i){ + i = 4; + } + } +} diff --git a/mcs/errors/cs1524.cs b/mcs/errors/cs1524.cs new file mode 100755 index 00000000000..b43976cc0bd --- /dev/null +++ b/mcs/errors/cs1524.cs @@ -0,0 +1,15 @@ +// cs1524.cs: expected catch or finally +// Line: 12 + +namespace Test { + public class Test { + public static int Main () { + int a; + try { + a = 1; + } + + return 0; + } + } +} diff --git a/mcs/errors/cs1526.cs b/mcs/errors/cs1526.cs new file mode 100755 index 00000000000..582d451ea89 --- /dev/null +++ b/mcs/errors/cs1526.cs @@ -0,0 +1,8 @@ +// cs1526: new expression requires () or [] after type +// Line: 6 +class X { + static void Main () + { + X x = new X; + } +} diff --git a/mcs/errors/cs1527.cs b/mcs/errors/cs1527.cs new file mode 100755 index 00000000000..663f880cd58 --- /dev/null +++ b/mcs/errors/cs1527.cs @@ -0,0 +1,4 @@ +// cs1527.cs: namespace elements cant explicitly be declared protected or private +// Line: +private class X { +} diff --git a/mcs/errors/cs1528.cs b/mcs/errors/cs1528.cs new file mode 100755 index 00000000000..7223adc8f40 --- /dev/null +++ b/mcs/errors/cs1528.cs @@ -0,0 +1,14 @@ +// cs1528.cs: cant specify constructor arguments in declaration +// Line: +class X { + X (int a) + { + } +} + +class Y { + static void Main () + { + X x (4); + } +} diff --git a/mcs/errors/cs1530.cs b/mcs/errors/cs1530.cs new file mode 100755 index 00000000000..7ed13b49dcf --- /dev/null +++ b/mcs/errors/cs1530.cs @@ -0,0 +1,7 @@ +// cs1530.cs: New not allowed on namespace declarations +// Line: +namespace A { + + new class X { + } +} diff --git a/mcs/errors/cs1540.cs b/mcs/errors/cs1540.cs new file mode 100644 index 00000000000..6ba524e4869 --- /dev/null +++ b/mcs/errors/cs1540.cs @@ -0,0 +1,13 @@ +class A +{ + protected int n; +} + +class B : A +{ + public static void Main () + { + A b = new A (); + b.n = 1; + } +} diff --git a/mcs/errors/cs1593.cs b/mcs/errors/cs1593.cs new file mode 100644 index 00000000000..755cd703170 --- /dev/null +++ b/mcs/errors/cs1593.cs @@ -0,0 +1,30 @@ +// cs1593.cs : Delegate 'Blah.MyDelegate' does not take '1' arguments +// Line : 21 + +using System; + +public class Blah { + + public delegate int MyDelegate (int i, int j); + + public int Foo (int i, int j) + { + return i+j; + } + + public static int Main () + { + Blah i = new Blah (); + + MyDelegate del = new MyDelegate (i.Foo); + + int number = del (2); + + if (number == 5) + return 0; + else + return 1; + + } + +} diff --git a/mcs/errors/cs1594.cs b/mcs/errors/cs1594.cs new file mode 100644 index 00000000000..0ffb3d9e761 --- /dev/null +++ b/mcs/errors/cs1594.cs @@ -0,0 +1,30 @@ +// cs1594.cs : Delegate 'Blah.MyDelegate' has some invalid arguments. +// Line : 21 + +using System; + +public class Blah { + + public delegate int MyDelegate (int i, int j); + + public int Foo (int i, int j) + { + return i+j; + } + + public static int Main () + { + Blah i = new Blah (); + + MyDelegate del = new MyDelegate (i.Foo); + + int number = del (2, "a string"); + + if (number == 5) + return 0; + else + return 1; + + } + +} diff --git a/mcs/errors/cs1604.cs b/mcs/errors/cs1604.cs new file mode 100755 index 00000000000..1e87da758a1 --- /dev/null +++ b/mcs/errors/cs1604.cs @@ -0,0 +1,14 @@ +// cs1604.cs: m is a readonly variable +// line: 10 +using System.IO; + +class X { + + static void Main () + { + using (MemoryStream m = new MemoryStream ()){ + m = null; + } + } +} + diff --git a/mcs/errors/cs3005.cs b/mcs/errors/cs3005.cs new file mode 100644 index 00000000000..46c269a886a --- /dev/null +++ b/mcs/errors/cs3005.cs @@ -0,0 +1,16 @@ +// cs3005: Identifier foo differing only in case is not CLS-Compliant. +// Line: 13 + + +using System; + +class ErrorCS3005 { + public int FOO = 0; + public int foo = 1; + + public static void Main ( ) { + ErrorCS3005 error = new ErrorCS3005 (); + Console.WriteLine ("This should make the compiler to complain ERROR CS3005, number: {0}", error.foo); + } +} + diff --git a/mcs/errors/error-1.cs b/mcs/errors/error-1.cs new file mode 100644 index 00000000000..49d084654cd --- /dev/null +++ b/mcs/errors/error-1.cs @@ -0,0 +1,92 @@ +// This test must produce a compilation error in each method. +using System; + +public class X +{ + public static int Main () + { + // This is a compilation-only test. + return 0; + } + + // Must assign out parameter. + // CS0177 + public static void test1 (out float f) + { + } + + // Must assign it before returning. + public static void test2 (int a, out float f) + { + // CS0177 + if (a == 5) + return; + + f = 8.53F; + } + + public static void test3 (out float f) + { + try { + f = 8.53F; + } catch { + return; + } + // CS0177 + } + + public static int test4 () + { + int a; + + try { + a = 3; + } catch { + Console.WriteLine ("EXCEPTION"); + } + + // CS0165 + return a; + } + + public static int test5 () + { + int a; + + try { + Console.WriteLine ("TRY"); + a = 8; + } catch { + a = 9; + } finally { + // CS0165 + Console.WriteLine (a); + } + + return a; + } + + public static void test6 (int a, out float f) + { + do { + // CS0177 + if (a == 8) { + Console.WriteLine ("Hello"); + return; + } + } while (false); + + f = 1.3F; + return; + } + + // CS0177 + public static void test7 (out float f) + { + goto World; + f = 8.0F; + + World: + ; + } +} diff --git a/mcs/errors/error-2.cs b/mcs/errors/error-2.cs new file mode 100644 index 00000000000..1b19718e81b --- /dev/null +++ b/mcs/errors/error-2.cs @@ -0,0 +1,106 @@ +class Internal { } + +public class Public { } + +interface InternalInterface { } + +class X +{ + public class NestedPublic { } + + internal class NestedAssembly { } + + protected internal class NestedFamilyAndAssembly { } + + protected class NestedFamily { } + + protected class NestedPrivate { } + + static void Main () { } +} + +// CS0060 +public class A : Internal { } + +// CS0060 +public class B : X.NestedPublic { } +// CS0060 +public class C : X.NestedAssembly { } +// CS0060 +public class D : X.NestedFamilyAndAssembly { } + +// CS0059 +public delegate void E (Internal i); +// CS0058 +public delegate Internal F (); + +public class Y +{ + // CS0060 + public class YA : Internal { } + // CS0060 + public class YB : X.NestedPublic { } + // CS0060 + public class YC : X.NestedAssembly { } + // CS0060 + public class YD : X.NestedFamilyAndAssembly { } + + // CS0051 + public void YMA (Internal a) { } + // CS0051 + public void YMB (X.NestedPublic a) { } + // CS0051 + public void YMC (X.NestedAssembly a) { } + // CS0051 + public void YMD (X.NestedFamilyAndAssembly a) { } + + // CS0050 + public Internal YME () { } + + // CS0052 + public Internal YE; + + // CS0053 + public Internal YF { + get { return null; } + } + + // CS0054 + public Internal this [int a] { + get { return null; } + } + + // CS0052 + public event Internal YG; + + // CS0055 + public int this [Internal i] { + get { return; } + } +} + +class Z : X +{ + // CS0060 + public class ZA : NestedFamily { } + // CS0060 + internal class ZB : NestedFamily { } +} + +internal interface L +{ + void Hello (string hello); +} + +// CS0061 +public interface M : L +{ + void World (string world); +} + +public class N : M +{ + public void Hello (string hello) { } + + public void World (string world) { } +} diff --git a/mcs/errors/error-3.cs b/mcs/errors/error-3.cs new file mode 100644 index 00000000000..5dfe8996555 --- /dev/null +++ b/mcs/errors/error-3.cs @@ -0,0 +1,60 @@ +using System; + +struct A +{ + public int a; + private long b; + private float c; + + public A (int foo) + // CS0171 + { + a = foo; + // CS0170 + b = (long) c; + } +} + +class X +{ + // CS0177 + static void test1 (out A a) + { + a.a = 5; + } + + static void test_output (A a) + { + } + + static void test2 () + { + A a; + + // CS0165 + test_output (a); + } + + static void test3 () + { + A a; + + a.a = 5; + // CS0165 + test_output (a); + } + + static void test4 () + { + A a; + + // CS0170 + Console.WriteLine (a.a); + } + + public static int Main () + { + // Compilation-only test. + return 0; + } +} diff --git a/mcs/errors/error-4.cs b/mcs/errors/error-4.cs new file mode 100644 index 00000000000..05edea56cdd --- /dev/null +++ b/mcs/errors/error-4.cs @@ -0,0 +1,22 @@ +// This should not compile as void can't be converted to bool + +using System; + +public class MainClass +{ + public static void Main() + { + test MyBug = new test(); + Console.WriteLine (MyBug.mytest()); + } +} + +public class test +{ + public void mytest() + { + Console.WriteLine("test"); + } +} + + diff --git a/mcs/errors/error-5.cs b/mcs/errors/error-5.cs new file mode 100644 index 00000000000..1cb3b060e74 --- /dev/null +++ b/mcs/errors/error-5.cs @@ -0,0 +1,17 @@ +// The event access is illegal and it should bail out + +using System; + +delegate void MyEventHandler(); + +class MyEvent { + public event MyEventHandler SomeEvent; +} + +class EventDemo { + + public static void Main(){ + MyEvent evt = new MyEvent(); + evt.SomeEvent(); + } +} diff --git a/mcs/errors/errors.txt b/mcs/errors/errors.txt index d769c5c1bd2..027d2a5c931 100755 --- a/mcs/errors/errors.txt +++ b/mcs/errors/errors.txt @@ -1,5 +1,8 @@ We use negative numbers for the compiler, and leave the possitive -numbers to match the Microsoft numbers: +numbers to match the Microsoft numbers. + +NOTE: I am now moving to use numbers above 6000 instead of negative +numbers, as they look nicer on the debugging output. -1 An Primary Expression was parsed, when a Type was expected. This happens because my parser knowledge is limited, and I @@ -8,4 +11,76 @@ numbers to match the Microsoft numbers: of handling it. -2 Internal error, an interface is being defined inside an - interface (This should never happen).
\ No newline at end of file + interface (This should never happen). + +-3 Constant type is not one of sbyte, byte, short, ushort, int, + uint, long, ulong, char, float, double, decimal, bool, string, enum + or null type. + +-5 A search for a name on a Type returned matches that contain + methods and non-methods. They have the same name, and I do + not know how this is possible to begin with. + +-6 Generic internal compiler error. + +-7 Internal compiler error/library error: no default constructor + for a built-in type. Ie, decimal (int 32) + +-8 User-defined conversion cannot convert from or to object type. + +-9 User-defined conversion cannot convert from or to an interface type. + +-10 User-defined conversion cannot convert between types that derive + from each other. + +-11 Delegate creation expression takes only one argument + +-12 More than one integral conversion exists for the type on a + switch statement. + +-13 No return with a value found. Warning, since we currently + do not perform flow analysis, and can not tell whether a + ret is required or not. + +-14 Invalid number passed to probe + +-15 Can not locate default assembly path + +-16 Can not use System.Enum.ToObject (type, ConstantValue) with + user defined types. + +-17 A type has already been defined (try --nostdlib) + +-18 Do not know how to generate debugging information for this platform. + +-19 Can not find required utility function in the core libraries. + +-20 Cannot find attribute type Blah (maybe you forgot to set the + usage using the AttributeUsage attribute ?). + +-21 Bug in Microsoft compiler while applying named attribute for + StructLayout.CharSet value. + +-22 Location of previous error + +-23 .NET runtime error when encoding attributes whose constructor + takes an object, but an enumeration value that is boxed is + passed. + + Sample: + using System.ComponentModel; + [DefaultValue (CollectionChangeAction.Add)] + class X { static void Main () { } } + + +-24 .NET runtime bug when trying to set custom attributes on the + return type of a method + + +6024 Unused `using' statement + + Sample: + using System; + class X {} + +-25 Generic parse error
\ No newline at end of file diff --git a/mcs/errors/fail b/mcs/errors/fail new file mode 100755 index 00000000000..7ff0429db42 --- /dev/null +++ b/mcs/errors/fail @@ -0,0 +1,30 @@ +The following tests failed: + +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 +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.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 + diff --git a/mcs/errors/makefile b/mcs/errors/makefile new file mode 100755 index 00000000000..8edc6cc8730 --- /dev/null +++ b/mcs/errors/makefile @@ -0,0 +1,48 @@ +# +# Compile at the maximum warning level to probe for warnings +# +MCS=mono ../mcs/mcs.exe --wlevel 4 # for linux +#MCS=../mcs/mcs.exe --wlevel 4 # for windows + + +all: + @ failed=false; \ + for i in cs*.cs; do \ + case $$i in \ + cs[0-9]*-[0-9]*cs) \ + error=`echo $$i | sed -e 's/cs*//' -e 's/.cs//' -e 's/-.*//'`; \ + ;;\ + cs[0-9-]*cs) \ + error=`echo $$i | sed -e 's/cs*//' -e 's/.cs//'`; \ + ;;\ + esac; \ + 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 \ + echo "The following tests failed: $$flist"; \ + else \ + echo All tests passed; \ + fi + +test-error-mono: + @ failed=false; \ + for i in error-*.cs; do \ + echo -n "Running test $$i ... "; \ + if MCS='$(MCS)' perl ./runtest.pl $$i > /dev/null; \ + then echo OK; \ + else echo FAILED; \ + flist="$$flist $$i"; \ + failed=true; \ + fi; \ + done; \ + if $$failed; then \ + echo "The following tests failed: $$flist"; \ + else \ + echo All tests passed; \ + fi diff --git a/mcs/errors/runtest.pl b/mcs/errors/runtest.pl new file mode 100755 index 00000000000..09ace98e74d --- /dev/null +++ b/mcs/errors/runtest.pl @@ -0,0 +1,105 @@ +#!/usr/bin/perl -w + +use strict; +use IPC::Open3; + +# Setting $strict to 1 enables line number checks, setting it to 2 makes +# line number mismatches fatal. +my $strict = 2; +my $failures = 0; +my $mcs = (defined $ENV{MCS}) ? $ENV{MCS} : 'mcs'; + +unless ($#ARGV == 0) { + print STDERR "Usage: $0 testcase.cs\n"; + exit 1; +} + +my %errors = (); +my %warnings = (); +my %lines = (); + +my $filename = $ARGV [0]; +my $input; + +my $line = 0; + +open (INPUT, "<$filename") or die + "Can't open testcase: $!"; +while (defined ($input = <INPUT>)) { + ++$line; + chop $input; + next unless $input =~ m,^\s*//\s*(error|warning)?\s*(CS\d+),; + + if ((defined $1) and ($1 eq 'warning')) { + ++$warnings{$2}; + } else { + ++$errors{$2}; + } + + $lines{$line+1} = $2; +} +close INPUT; + +open (MCS, "$mcs $filename|") or die + "Can't open mcs pipe: $!"; + +while (defined ($input = <MCS>)) { + chop $input; + next unless $input =~ m,\((\d+)\)\s+(warning|error)\s+(CS\d+):,; + + if ($2 eq 'warning') { + --$warnings{$3}; + } else { + --$errors{$3}; + } + + next unless $strict; + + if (!defined $lines{$1}) { + print "Didn't expect any warnings or errors in line $1, but got $2 $3.\n"; + $failures++ if $strict == 2; + } elsif ($lines{$1} ne $3) { + print "Expected to find ".$lines{$1}." on line $1, but got $3.\n"; + $failures++ if $strict == 2; + } +} + +close MCS; + +foreach my $error (keys %errors) { + my $times = $errors{$error}; + + if ($times == -1) { + print "Unexpected error $error.\n"; + } elsif ($times < 0) { + print "Unexpected error $error (reported ".(-$times)." times).\n"; + } elsif ($times == 1) { + print "Failed to report error $error.\n"; + } elsif ($times > 0) { + print "Failed to report error $error $times times.\n"; + } + + $failures++ unless $times == 0; +} + +foreach my $warning (keys %warnings) { + my $times = $warnings{$warning}; + + if ($times == -1) { + print "Unexpected warning $warning.\n"; + } elsif ($times < 0) { + print "Unexpected warning $warning (reported ".(-$times)." times).\n"; + } elsif ($times == 1) { + print "Failed to report warning $warning.\n"; + } elsif ($times > 0) { + print "Failed to report warning $warning $times times.\n"; + } + + $failures++ unless $times == 0; +} + +if ($failures == 0) { + exit 0; +} else { + exit 1; +} |