diff options
Diffstat (limited to 'mcs/errors')
71 files changed, 1117 insertions, 69 deletions
diff --git a/mcs/errors/CS0246-29-lib.il b/mcs/errors/CS0246-29-lib.il new file mode 100644 index 0000000000..27709d43e5 --- /dev/null +++ b/mcs/errors/CS0246-29-lib.il @@ -0,0 +1,25 @@ +.assembly extern mscorlib +{ +} + +.assembly extern 'missing' +{ + .ver 0:0:0:0 +} + +.assembly 'CS0246-29-lib' +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} + +.module 'CS0246-29-lib.dll' + +.class extern forwarder A +{ + .assembly extern 'missing' +} +.class extern B +{ + .class extern A +}
\ No newline at end of file diff --git a/mcs/errors/CS0731-1-lib.il b/mcs/errors/CS0731-1-lib.il new file mode 100644 index 0000000000..d130a15a82 --- /dev/null +++ b/mcs/errors/CS0731-1-lib.il @@ -0,0 +1,21 @@ +.assembly extern mscorlib +{ +} + +.assembly extern 'CS0731-2-lib' +{ + .ver 0:0:0:0 +} + +.assembly 'CS0731-1-lib' +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} + +.module 'CS0731-1-lib.dll' + +.class extern forwarder A +{ + .assembly extern 'CS0731-2-lib' +} diff --git a/mcs/errors/CS0731-2-lib.il b/mcs/errors/CS0731-2-lib.il new file mode 100644 index 0000000000..ded95c70ef --- /dev/null +++ b/mcs/errors/CS0731-2-lib.il @@ -0,0 +1,21 @@ +.assembly extern mscorlib +{ +} + +.assembly extern 'CS0731-1-lib' +{ + .ver 0:0:0:0 +} + +.assembly 'CS0731-2-lib' +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} + +.module 'CS0731-2-lib.dll' + +.class extern forwarder A +{ + .assembly extern 'CS0731-1-lib' +}
\ No newline at end of file diff --git a/mcs/errors/CS1070-lib.il b/mcs/errors/CS1070-lib.il index d4487ff844..6200771307 100644 --- a/mcs/errors/CS1070-lib.il +++ b/mcs/errors/CS1070-lib.il @@ -14,7 +14,7 @@ .module 'CS1070-lib.dll' -.class extern forwarder E +.class extern forwarder N.E { .assembly extern 'CS1070-lib-missing' } diff --git a/mcs/errors/Makefile b/mcs/errors/Makefile index 756d130359..036f7aee51 100644 --- a/mcs/errors/Makefile +++ b/mcs/errors/Makefile @@ -23,13 +23,13 @@ DISTFILES = \ TEST_SUPPORT_FILES = \ CS0012-lib.dll CS0012-2-lib.dll CS0012-3-lib.dll CS0012-4-lib.dll CS0012-5-lib.dll CS0012-6-lib.dll CS0012-9-lib.dll CS0012-10-lib.dll CS0012-11-lib.dll CS0012-12-lib.dll CS0012-13-lib.dll CS0012-14-lib.dll CS0012-15-lib.dll CS0012-16-lib.dll CS0012-17-lib.dll CS0012-18-lib.dll CS0012-21-lib.dll CS0029-26-lib.dll \ CS0103-2-lib.dll CS0118-2-lib.dll CS0122-8-lib.dll CS0122-10-lib.dll CS0122-14-lib.dll CS0122-15-lib.dll CS0122-19-lib.dll CS0122-35-lib.dll CS0122-36-lib.dll CS0143-lib.dll CS0144-3-lib.dll CS0165-19-lib.dll \ - CS0205-3-lib.dll CS0229-3-lib.dll CS0229-4-lib.dll CS0266-25-lib.dll \ + CS0205-3-lib.dll CS0246-29-lib.dll CS0229-3-lib.dll CS0229-4-lib.dll CS0266-25-lib.dll \ CS0315-2-lib.dll \ CS0425-7-lib.dll CS0433-lib.dll CS0433-2-lib.dll \ CS0506-3-lib.dll CS0507-7-lib.dll CS0507-8-lib.dll CS0534-3-lib.dll CS0534-4-lib.dll CS0534-6-lib.dll CS0571-3-lib.dll CS0571-5-lib.dll CS0571-6-lib.dll \ CS0612-2-lib.dll CS0618-2-lib.dll CS0619-8-lib.dll CS0619-17-lib.dll CS0619-32-lib.dll CS0619-33-lib.dll CS0619-36-lib.dll CS0619-42-lib.dll \ CS0619-43-lib.dll CS1546-lib.dll CS0619-51-lib.dll CS1509-module.dll CS1681-2-lib.dll \ - CS0730-lib.dll \ + CS0730-lib.dll CS0731-1-lib.dll CS0731-2-lib.dll \ CS1070-lib.dll \ CS1540-15-lib.dll CS1540-17-lib.dll CS1542-lib.dll CS1577-lib.dll \ CS1607-3-lib.dll CS1683-lib.dll CS1684-lib.dll CS1685-2-lib.dll \ diff --git a/mcs/errors/cs0029-35.cs b/mcs/errors/cs0029-35.cs new file mode 100644 index 0000000000..c2330990f1 --- /dev/null +++ b/mcs/errors/cs0029-35.cs @@ -0,0 +1,12 @@ +// CS0029: Cannot implicitly convert type `string' to `int' +// Line: 10 +// Compiler options: -unsafe + +class TestClass +{ + public unsafe static void Main () + { + int* arr = null; + var i = arr["c"]; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0035-2.cs b/mcs/errors/cs0035-2.cs new file mode 100644 index 0000000000..12d91ef9f6 --- /dev/null +++ b/mcs/errors/cs0035-2.cs @@ -0,0 +1,33 @@ +// CS0035: Operator `++' is ambiguous on an operand of type `MyType' +// Line: 31 + +public class MyType +{ + public static implicit operator float (MyType v) + { + return 0; + } + + public static implicit operator decimal (MyType v) + { + return 0; + } + + public static implicit operator MyType (float v) + { + return null; + } + + public static implicit operator MyType (decimal v) + { + return null; + } +} + +class Test +{ + static void test (MyType x) + { + x++; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0037-8.cs b/mcs/errors/cs0037-8.cs deleted file mode 100644 index 5f54e10eda..0000000000 --- a/mcs/errors/cs0037-8.cs +++ /dev/null @@ -1,11 +0,0 @@ -// CS0037: Cannot convert null to `int' because it is a value type -// Line: 9 - -class C -{ - public static void Main () - { - int i = 44; - i <<= null; - } -} diff --git a/mcs/errors/cs0103-12.cs b/mcs/errors/cs0103-12.cs new file mode 100644 index 0000000000..9e2274cfe3 --- /dev/null +++ b/mcs/errors/cs0103-12.cs @@ -0,0 +1,11 @@ +// CS0103: The name `bar' does not exist in the current context +// Line: 8 + +public class Test +{ + static void Main () + { + if (false && bar ()) { + } + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0104-3.cs b/mcs/errors/cs0104-3.cs new file mode 100644 index 0000000000..95e116ead4 --- /dev/null +++ b/mcs/errors/cs0104-3.cs @@ -0,0 +1,33 @@ +// CS0104: `X' is an ambiguous reference between `A.X' and `B.X' +// Line: 25 + +namespace A +{ + class X { } +} + +namespace B +{ + class X { } +} + +namespace C +{ + using System; + using A; + using B; + + class Test + { + static void Main () + { + Foo (delegate { + X x; + }); + } + + static void Foo (Action a) + { + } + } +} diff --git a/mcs/errors/cs0104-4.cs b/mcs/errors/cs0104-4.cs new file mode 100644 index 0000000000..9072d99bb1 --- /dev/null +++ b/mcs/errors/cs0104-4.cs @@ -0,0 +1,25 @@ +// CS0104: `XAttribute' is an ambiguous reference between `A.XAttribute' and `B.XAttribute' +// Line: 21 + +using System; + +namespace A +{ + class XAttribute : Attribute { } +} + +namespace B +{ + class XAttribute : Attribute { } +} + +namespace C +{ + using A; + using B; + + [X] + class Test + { + } +} diff --git a/mcs/errors/cs0126-2.cs b/mcs/errors/cs0126-2.cs new file mode 100644 index 0000000000..c472df74e8 --- /dev/null +++ b/mcs/errors/cs0126-2.cs @@ -0,0 +1,18 @@ +// CS0126: An object of a type convertible to `string' is required for the return statement +// Line: 7 + +using System.Threading.Tasks; + +class A +{ + static async Task<string> Test () + { + await CallAsync (); + return; + } + + static Task<string> CallAsync () + { + return null; + } +} diff --git a/mcs/errors/cs0161-4.cs b/mcs/errors/cs0161-4.cs deleted file mode 100644 index faeaf5734a..0000000000 --- a/mcs/errors/cs0161-4.cs +++ /dev/null @@ -1,15 +0,0 @@ -// CS0161: `T.Main()': not all code paths return a value -// Line: 6 -// CSC bug: The error is not reported even if it should as in other unreachable cases - -class T { - public static int Main () - { - switch (1) { - case 1: - return 0; - default: - break; - } - } -} diff --git a/mcs/errors/cs0162-17.cs b/mcs/errors/cs0162-18.cs index 821c7418a4..6b393ae94f 100644 --- a/mcs/errors/cs0162-17.cs +++ b/mcs/errors/cs0162-18.cs @@ -7,6 +7,15 @@ public class X public static void Main () { return; - 1+1; + + switch (8) { + case 1: + case 2: + break; + default: + return; + } + + return; } }
\ No newline at end of file diff --git a/mcs/errors/cs0162-20.cs b/mcs/errors/cs0162-20.cs new file mode 100644 index 0000000000..e2bb4dcda6 --- /dev/null +++ b/mcs/errors/cs0162-20.cs @@ -0,0 +1,21 @@ +// CS0162: Unreachable code detected +// Line: 14 +// Compiler options: -warnaserror + +using System; + +class X +{ + + public static void Main () + { + goto X; + A: + bool b = false; + if (b) { + goto A; + } + X: + return; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0162-7.cs b/mcs/errors/cs0162-7.cs index d8ae75fb0c..3eb8bcfdb3 100644 --- a/mcs/errors/cs0162-7.cs +++ b/mcs/errors/cs0162-7.cs @@ -2,9 +2,6 @@ // Line: 9 // Compiler options: -warnaserror -warn:2 -// this requires a multi-pass algorithm for unreachable code detection -// punting for now - class Foo { static void Main () { diff --git a/mcs/errors/cs0163-2.cs b/mcs/errors/cs0163-2.cs new file mode 100644 index 0000000000..dfdd9c1225 --- /dev/null +++ b/mcs/errors/cs0163-2.cs @@ -0,0 +1,20 @@ +// CS0163: Control cannot fall through from one case label `case 1:' to another +// Line: 14 + +using System; +using System.Collections.Generic; + +static class C +{ + public static IEnumerable<int> Test (int key) + { + switch (key) { + case 1: + yield return 0; + case 2: + yield return 2; + default: + throw new ArgumentOutOfRangeException ("symbol:" + key); + } + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0163.cs b/mcs/errors/cs0163.cs index 7596a4fcea..1f65f60490 100644 --- a/mcs/errors/cs0163.cs +++ b/mcs/errors/cs0163.cs @@ -1,6 +1,5 @@ -// CS0163: Control cannot fall through from one case label to another -// Line: 17 - +// CS0163: Control cannot fall through from one case label `case 3:' to another +// Line: 21 public class Foo { diff --git a/mcs/errors/cs0165-21.cs b/mcs/errors/cs0165-21.cs new file mode 100644 index 0000000000..2f6bbc1a4e --- /dev/null +++ b/mcs/errors/cs0165-21.cs @@ -0,0 +1,19 @@ +// CS0165: Use of unassigned local variable `v' +// Line: 17 + +using System; + +class C +{ + void Test (int arg) + { + int v; + switch (arg) { + case 1: + v = 0; + break; + } + + Console.WriteLine (v); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0165-22.cs b/mcs/errors/cs0165-22.cs new file mode 100644 index 0000000000..6b76beba2f --- /dev/null +++ b/mcs/errors/cs0165-22.cs @@ -0,0 +1,34 @@ +// CS0165: Use of unassigned local variable `x' +// Line: 17 + +using System; + +class Program +{ + static int Main () + { + int foo = 9; + int x; + + switch (foo) { + case 1: + x = 1; + gotoTarget: + { + Console.WriteLine (x); + } + break; + default: + { + if (foo != 0) { + goto gotoTarget; + } + + break; + } + } + + return 1; + } +} + diff --git a/mcs/errors/cs0165-23.cs b/mcs/errors/cs0165-23.cs new file mode 100644 index 0000000000..8c947a2af5 --- /dev/null +++ b/mcs/errors/cs0165-23.cs @@ -0,0 +1,23 @@ +// CS0165: Use of unassigned local variable `retval' +// Line: 9 + +class Test +{ + static string DoStuff (string msg) + { + string retval; + + switch (msg) { + case "hello": + retval = "goodbye"; + return retval; + case "goodbye": + return retval; + case "other": + retval = "other"; + case "": + return msg; + } + return ""; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0165-24.cs b/mcs/errors/cs0165-24.cs new file mode 100644 index 0000000000..cbc9c97ce5 --- /dev/null +++ b/mcs/errors/cs0165-24.cs @@ -0,0 +1,18 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 14 + +class X +{ + public static void Main () + { + int i = 3; + switch (i) { + case 1: + float a = 7.0f; + break; + default: + float b = a + 99.0f; + break; + } + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0165-25.cs b/mcs/errors/cs0165-25.cs new file mode 100644 index 0000000000..8ffe58681b --- /dev/null +++ b/mcs/errors/cs0165-25.cs @@ -0,0 +1,24 @@ +// CS0165: Use of unassigned local variable `trial' +// Line: 18 + +using System; + +class Test +{ + public static void Main (string[] args) + { + bool trial; + string action = "add_trial"; + + switch (action) { + case "add_trial": + trial = true; + goto case "add_to_project"; + case "add_to_project": + Console.WriteLine (trial); + break; + case "test": + break; + } + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0165-26.cs b/mcs/errors/cs0165-26.cs new file mode 100644 index 0000000000..b1442187b9 --- /dev/null +++ b/mcs/errors/cs0165-26.cs @@ -0,0 +1,15 @@ +// CS0165: Use of unassigned local variable `eh' +// Line: 12 + +using System; + +public class E +{ + public static void Main () + { + EventHandler eh; + eh = delegate { + Console.WriteLine (eh); + }; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0165-27.cs b/mcs/errors/cs0165-27.cs new file mode 100644 index 0000000000..db34dd83f6 --- /dev/null +++ b/mcs/errors/cs0165-27.cs @@ -0,0 +1,15 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 13 + +using System; + +class Program +{ + public static void Main (string[] args) + { + int a, b; + string s = ""; + var res = s != null ? a = 1 : b = 2; + Console.WriteLine (a); + } +} diff --git a/mcs/errors/cs0165-28.cs b/mcs/errors/cs0165-28.cs new file mode 100644 index 0000000000..4b22f7d0b4 --- /dev/null +++ b/mcs/errors/cs0165-28.cs @@ -0,0 +1,15 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 13 + +using System; + +class Program +{ + public static void Main () + { + int a; + string s = ""; + var res = s == null || ((a = 1) > 0); + Console.WriteLine (a); + } +} diff --git a/mcs/errors/cs0165-29.cs b/mcs/errors/cs0165-29.cs new file mode 100644 index 0000000000..238093d457 --- /dev/null +++ b/mcs/errors/cs0165-29.cs @@ -0,0 +1,12 @@ +// CS0165: Use of unassigned local variable `j' +// Line: 10 + +class Test +{ + static void Main () + { + int? i; + int? j; + int? x = (i = 7) ?? j; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0165-30.cs b/mcs/errors/cs0165-30.cs new file mode 100644 index 0000000000..c800affb13 --- /dev/null +++ b/mcs/errors/cs0165-30.cs @@ -0,0 +1,11 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 9 + +using System; + +class Test { + + static void Main () { + Action a = () => a(); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0165-31.cs b/mcs/errors/cs0165-31.cs new file mode 100644 index 0000000000..07759cbe0f --- /dev/null +++ b/mcs/errors/cs0165-31.cs @@ -0,0 +1,11 @@ +// CS0165: Use of unassigned local variable `i' +// Line: 9 + +public class MainClass +{ + public void Foo () + { + int i; + i++; + } +} diff --git a/mcs/errors/cs0165-32.cs b/mcs/errors/cs0165-32.cs new file mode 100644 index 0000000000..fb9652267c --- /dev/null +++ b/mcs/errors/cs0165-32.cs @@ -0,0 +1,16 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 9 + +class C +{ + static void Main () + { + int a; + Foo (out a, a); + } + + static void Foo (out int a, int b) + { + a = b; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0165-33.cs b/mcs/errors/cs0165-33.cs new file mode 100644 index 0000000000..16afc7db6f --- /dev/null +++ b/mcs/errors/cs0165-33.cs @@ -0,0 +1,20 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 13 + +using System; +using System.Diagnostics; + +class C +{ + static int Main () + { + int a; + Foo (a = 9); + return a; + } + + [Conditional ("MISSING")] + static void Foo (int value) + { + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0165-34.cs b/mcs/errors/cs0165-34.cs new file mode 100644 index 0000000000..229f472f6d --- /dev/null +++ b/mcs/errors/cs0165-34.cs @@ -0,0 +1,17 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 14 + +using System; + +class Program +{ + public static void Main () + { + int a; + string s = ""; + + if (s != "s" || (a = 4) > 3) { + Console.WriteLine (a); + } + } +} diff --git a/mcs/errors/cs0165-35.cs b/mcs/errors/cs0165-35.cs new file mode 100644 index 0000000000..ad3604f55b --- /dev/null +++ b/mcs/errors/cs0165-35.cs @@ -0,0 +1,19 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 14 + +using System; + +class Program +{ + public static void Main () + { + int a; + string s = ""; + + if (s != "s" && (a = 4) > 3) { + return; + } + + Console.WriteLine (a); + } +} diff --git a/mcs/errors/cs0165-36.cs b/mcs/errors/cs0165-36.cs new file mode 100644 index 0000000000..594eafc6f6 --- /dev/null +++ b/mcs/errors/cs0165-36.cs @@ -0,0 +1,17 @@ +// CS0165: Use of unassigned local variable `s' +// Line: 14 + +using System; + +class Program +{ + public static void Main () + { + string s; + object o = null; + while (o != null && string.IsNullOrEmpty (s = (string) o.ToString ())) { + } + + Console.WriteLine (s); + } +} diff --git a/mcs/errors/cs0165-37.cs b/mcs/errors/cs0165-37.cs new file mode 100644 index 0000000000..cb56118fcd --- /dev/null +++ b/mcs/errors/cs0165-37.cs @@ -0,0 +1,16 @@ +// CS0165: Use of unassigned local variable `s' +// Line: 14 + +using System; + +class Program +{ + public static void Main () + { + string s; + object o = null; + while (o != null || string.IsNullOrEmpty (s = (string) o.ToString ())) { + Console.WriteLine (s); + } + } +} diff --git a/mcs/errors/cs0165-38.cs b/mcs/errors/cs0165-38.cs new file mode 100644 index 0000000000..20fc40949f --- /dev/null +++ b/mcs/errors/cs0165-38.cs @@ -0,0 +1,18 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 16 + +using System; + +class Program +{ + public static void Main () + { + int a; + string s = ""; + + do { + } while (s != "s" && (a = 4) > 3); + + Console.WriteLine (a); + } +} diff --git a/mcs/errors/cs0165-39.cs b/mcs/errors/cs0165-39.cs new file mode 100644 index 0000000000..c5da9d659e --- /dev/null +++ b/mcs/errors/cs0165-39.cs @@ -0,0 +1,18 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 16 + +using System; + +class Program +{ + public static void Main () + { + int a; + string s = ""; + + for (int i = 0; s != "s" && (a = 4) > 3; ++i) { + } + + Console.WriteLine (a); + } +} diff --git a/mcs/errors/cs0165-40.cs b/mcs/errors/cs0165-40.cs new file mode 100644 index 0000000000..690cdaecc1 --- /dev/null +++ b/mcs/errors/cs0165-40.cs @@ -0,0 +1,17 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 14 + +using System; + +class Program +{ + public static void Main () + { + int a; + string s = ""; + + if (!(s != "s" && (a = 4) > 3)) { + Console.WriteLine (a); + } + } +} diff --git a/mcs/errors/cs0165-41.cs b/mcs/errors/cs0165-41.cs new file mode 100644 index 0000000000..b1242a054c --- /dev/null +++ b/mcs/errors/cs0165-41.cs @@ -0,0 +1,15 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 14 + +using System; + +class Program +{ + public static void Main () + { + int a; + string s = ""; + + var res = (s == "" && (a = 4) > 3) ? 1 : a; + } +} diff --git a/mcs/errors/cs0165-42.cs b/mcs/errors/cs0165-42.cs new file mode 100644 index 0000000000..81de0cf868 --- /dev/null +++ b/mcs/errors/cs0165-42.cs @@ -0,0 +1,16 @@ +// CS0165: Use of unassigned local variable `a' +// Line: 14 + +using System; + +class Program +{ + public static void Main () + { + object a; + string s = null; + + var res = s ?? (a = null); + Console.WriteLine (a); + } +} diff --git a/mcs/errors/cs0165-43.cs b/mcs/errors/cs0165-43.cs new file mode 100644 index 0000000000..b4762ab06b --- /dev/null +++ b/mcs/errors/cs0165-43.cs @@ -0,0 +1,18 @@ +// CS0165: Use of unassigned local variable `g' +// Line: 10 + +public class A +{ + static bool Test7 () + { + int f = 1; + int g; + return f > 1 && OutCall (out g) || g > 1; + } + + static bool OutCall (out int arg) + { + arg = 1; + return false; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0171-6.cs b/mcs/errors/cs0171-6.cs new file mode 100644 index 0000000000..e968f1ae32 --- /dev/null +++ b/mcs/errors/cs0171-6.cs @@ -0,0 +1,18 @@ +// CS0171: Field `S.value' must be fully assigned before control leaves the constructor +// Line: 10 + +using System; + +struct S +{ + string value; + + public S (int arg) + { + if (arg > 0) { + return; + } + + throw new ApplicationException (); + } +} diff --git a/mcs/errors/cs0177-14.cs b/mcs/errors/cs0177-14.cs new file mode 100644 index 0000000000..103bf7a60f --- /dev/null +++ b/mcs/errors/cs0177-14.cs @@ -0,0 +1,22 @@ +// CS0177: The out parameter `val' must be assigned to before control leaves the current method +// Line: 12 + +public class A +{ + public bool GetValue (out int val) + { + val = 0; + return true; + } + + public void ReallyGetValue (out int val) + { + if (AlwaysReturnTrue () || GetValue (out val)) { + } + } + + public bool AlwaysReturnTrue () + { + return true; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0193.cs b/mcs/errors/cs0193.cs index 96da3d7d0e..3eae90ffd6 100644 --- a/mcs/errors/cs0193.cs +++ b/mcs/errors/cs0193.cs @@ -7,8 +7,6 @@ unsafe class X { { int a = 0; if (*a == 0) - return 1; - - return 0; + return; } } diff --git a/mcs/errors/cs0201-10.cs b/mcs/errors/cs0201-10.cs new file mode 100644 index 0000000000..a76e80adca --- /dev/null +++ b/mcs/errors/cs0201-10.cs @@ -0,0 +1,11 @@ +// CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement +// Line: 9 + +public class X +{ + public static void Main () + { + return; + 1+1; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0201-11.cs b/mcs/errors/cs0201-11.cs new file mode 100644 index 0000000000..536ee2424f --- /dev/null +++ b/mcs/errors/cs0201-11.cs @@ -0,0 +1,12 @@ +// CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement +// Line: 10 + +using System; + +class X +{ + public static void Main () + { + new Func<int> (() => 0); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0220-4.cs b/mcs/errors/cs0220-4.cs new file mode 100644 index 0000000000..c52aa54522 --- /dev/null +++ b/mcs/errors/cs0220-4.cs @@ -0,0 +1,12 @@ +// CS0220: The operation overflows at compile time in checked mode +// Line: 10 +// Compiler options: -unsafe + +class TestClass +{ + public unsafe static void Main () + { + int* arr = null; + var i = arr[long.MaxValue]; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0246-29.cs b/mcs/errors/cs0246-29.cs new file mode 100644 index 0000000000..051b956e54 --- /dev/null +++ b/mcs/errors/cs0246-29.cs @@ -0,0 +1,10 @@ +// CS0246: The type or namespace name `B' could not be found. Are you missing an assembly reference? +// Line: 8 + +class X +{ + public static void Main () + { + B b; + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0246-30.cs b/mcs/errors/cs0246-30.cs new file mode 100644 index 0000000000..06b41b07da --- /dev/null +++ b/mcs/errors/cs0246-30.cs @@ -0,0 +1,22 @@ +// CS0246: The type or namespace name `T' could not be found. Are you missing an assembly reference? +// Line: 13 + +using System; +using System.Collections.Generic; + +class X +{ + public static void Main () + { + Foo (() => { + IEnumerable<object> f = null; + foreach (KeyValuePair<int, T> e in f) { + } + }); + + } + + static void Foo (Action a) + { + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0411-6.cs b/mcs/errors/cs0411-6.cs deleted file mode 100644 index c6e7ffd6e1..0000000000 --- a/mcs/errors/cs0411-6.cs +++ /dev/null @@ -1,25 +0,0 @@ -// CS0411: The type arguments for method `Hello.World<U>(U, IFoo<U>)' cannot be inferred from the usage. Try specifying the type arguments explicitly -// Line: 16 -public interface IFoo<T> -{ } - -public class Foo : IFoo<int>, IFoo<string> -{ } - -public class Hello -{ - public void World<U> (U u, IFoo<U> foo) - { } - - public void Test (Foo foo) - { - World ("Canada", foo); - } -} - -class X -{ - static void Main () - { - } -} diff --git a/mcs/errors/cs0429-3.cs b/mcs/errors/cs0429-3.cs new file mode 100644 index 0000000000..b8572b5ba8 --- /dev/null +++ b/mcs/errors/cs0429-3.cs @@ -0,0 +1,11 @@ +// CS0429: Unreachable expression code detected +// Line: 9 +// Compiler options: -warn:4 -warnaserror + +class Main +{ + public void Method (int i) + { + var x = true ? 1 : i; + } +} diff --git a/mcs/errors/cs0429-4.cs b/mcs/errors/cs0429-4.cs new file mode 100644 index 0000000000..d808039967 --- /dev/null +++ b/mcs/errors/cs0429-4.cs @@ -0,0 +1,14 @@ +// CS0429: Unreachable expression code detected +// Line: 12 +// Compiler options: -warnaserror + +public class X +{ + static void test (int stop) + { + int pos = 0; + do { + break; + } while (pos < stop); + } +} diff --git a/mcs/errors/cs0458-17.cs b/mcs/errors/cs0458-17.cs new file mode 100644 index 0000000000..748f7730f3 --- /dev/null +++ b/mcs/errors/cs0458-17.cs @@ -0,0 +1,12 @@ +// CS0458: The result of the expression is always `null' of type `int?' +// Line: 10 +// Compiler options: -warnaserror -warn:2 + +class C +{ + public static void Main () + { + int i = 44; + i <<= null; + } +} diff --git a/mcs/errors/cs0534-11.cs b/mcs/errors/cs0534-11.cs new file mode 100644 index 0000000000..7d67ac6515 --- /dev/null +++ b/mcs/errors/cs0534-11.cs @@ -0,0 +1,17 @@ +// CS0534: `Foo' does not implement inherited abstract member `SomeAbstract.SomeProperty.get' +// Line: 13 + +public class SomeProperty +{ +} + +public abstract class SomeAbstract +{ + public abstract SomeProperty SomeProperty { get; } +} + +public class Foo : SomeAbstract +{ + public static SomeProperty SomeProperty { get { return null; } } +} + diff --git a/mcs/errors/cs0540-3.cs b/mcs/errors/cs0540-3.cs new file mode 100644 index 0000000000..99f5f5efa8 --- /dev/null +++ b/mcs/errors/cs0540-3.cs @@ -0,0 +1,27 @@ +// CS0540: `Foo.ISomeProp.SomeProperty': containing type does not implement interface `ISomeProp' +// Line: 18 + +public class SomeProperty +{ +} + +public abstract class SomeAbstract : ISomeProp +{ + public abstract SomeProperty SomeProperty { get; } +} + +interface ISomeProp +{ + SomeProperty SomeProperty { get; } +} + +public class Foo : SomeAbstract +{ + SomeProperty ISomeProp.SomeProperty { get { return null; } } + + public override SomeProperty SomeProperty { get { return null; } } + + public static void Main () + { + } +} diff --git a/mcs/errors/cs0731.cs b/mcs/errors/cs0731.cs new file mode 100644 index 0000000000..4eb355360c --- /dev/null +++ b/mcs/errors/cs0731.cs @@ -0,0 +1,11 @@ +// CS0731: The type forwarder for type `A' in assembly `CS0731-2-lib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' has circular dependency +// Line: 9 +// Compiler options: -r:CS0731-1-lib.dll -r:CS0731-2-lib.dll + +class Test +{ + static void Main () + { + new A (); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs1061-14.cs b/mcs/errors/cs1061-14.cs new file mode 100644 index 0000000000..e5c3db5d96 --- /dev/null +++ b/mcs/errors/cs1061-14.cs @@ -0,0 +1,25 @@ +// CS1061: Type `string' does not contain a definition for `Name' and no extension method `Name' of type `string' could be found. Are you missing an assembly reference? +// Line: 18 + +using System; + +static class X +{ + public static void Main () + { + } + + static void Foo () + { + var fileName = ""; + string[] all = null; + + all.Each (x => { + var name = fileName.Name; + }); + } + + static void Each<T> (this T[] s, Action<T> a) + { + } +} diff --git a/mcs/errors/cs1070-2.cs b/mcs/errors/cs1070-2.cs new file mode 100644 index 0000000000..7fe8760619 --- /dev/null +++ b/mcs/errors/cs1070-2.cs @@ -0,0 +1,12 @@ +// CS1070: The type `N.E' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `CS1070-lib-missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' +// Line: 9 +// Compiler options: -r:CS1070-lib.dll + +using N; + +public class D +{ + public void Foo (E e) + { + } +}
\ No newline at end of file diff --git a/mcs/errors/cs1503-14.cs b/mcs/errors/cs1503-14.cs new file mode 100644 index 0000000000..26422fa367 --- /dev/null +++ b/mcs/errors/cs1503-14.cs @@ -0,0 +1,25 @@ +// CS1503: Argument `#2' cannot convert `IContravariant<object>' expression to type `ICovariant<string>' +// Line: 23 + +interface IContravariant<in T> +{ +} + +interface ICovariant<out T> +{ +} + +class C +{ + public static void Test<T> (ICovariant<T> e1, ICovariant<T> e2) + { + } + + public static void Main () + { + ICovariant<string> a_2 = null; + IContravariant<object> b_2 = null; + + Test (a_2, b_2); + } +}
\ No newline at end of file diff --git a/mcs/errors/cs0411-15.cs b/mcs/errors/cs1503-15.cs index ed39e457d9..4313fcf2c8 100644 --- a/mcs/errors/cs0411-15.cs +++ b/mcs/errors/cs1503-15.cs @@ -1,5 +1,5 @@ -// CS0411: The type arguments for method `C.Foo<T>(IFoo<T>, IFoo<T>)' cannot be inferred from the usage. Try specifying the type arguments explicitly -// Line: 17 +// CS1503: Argument `#2' cannot convert `IFoo<object>' expression to type `IFoo<int>' +// Line: 18 interface IFoo<in T> { diff --git a/mcs/errors/cs0411-7.cs b/mcs/errors/cs1503-16.cs index c22648e5d8..24fa1e6662 100644 --- a/mcs/errors/cs0411-7.cs +++ b/mcs/errors/cs1503-16.cs @@ -1,4 +1,4 @@ -// CS0411: The type arguments for method `C.Foo<T>(T, System.Collections.Generic.Comparer<T>)' cannot be inferred from the usage. Try specifying the type arguments explicitly +// CS1503: Argument `#2' cannot convert `method group' expression to type `System.Collections.Generic.Comparer<int>' // Line: 20 using System; diff --git a/mcs/errors/cs1632-2.cs b/mcs/errors/cs1632-2.cs new file mode 100644 index 0000000000..fe6c1c2dc6 --- /dev/null +++ b/mcs/errors/cs1632-2.cs @@ -0,0 +1,16 @@ +// CS1632: Control cannot leave the body of an anonymous method +// Line: 12 + +using System; + +class X +{ + public static void Main () + { + while (true) { + Action a = () => { + break; + }; + } + } +} diff --git a/mcs/errors/cs1632-3.cs b/mcs/errors/cs1632-3.cs new file mode 100644 index 0000000000..b7e457b57c --- /dev/null +++ b/mcs/errors/cs1632-3.cs @@ -0,0 +1,20 @@ +// CS1632: Control cannot leave the body of an anonymous method +// Line: 14 + +using System; + +class X +{ + public static void Main () + { + int b = 0; + switch (b) { + case 1: + Action a = () => { + break; + }; + + break; + } + } +} diff --git a/mcs/errors/cs1632-4.cs b/mcs/errors/cs1632-4.cs new file mode 100644 index 0000000000..a9127d5339 --- /dev/null +++ b/mcs/errors/cs1632-4.cs @@ -0,0 +1,22 @@ +// CS1632: Control cannot leave the body of an anonymous method +// Line: 14 + +using System; + +class X +{ + public static void Main () + { + int b = 0; + switch (b) { + case 1: + Action a = () => { + goto case 2; + }; + + break; + case 2: + break; + } + } +} diff --git a/mcs/errors/cs1648-2.cs b/mcs/errors/cs1648-2.cs new file mode 100644 index 0000000000..b470e10ace --- /dev/null +++ b/mcs/errors/cs1648-2.cs @@ -0,0 +1,23 @@ +// CS1648: Members of readonly field `Test.p' cannot be modified (except in a constructor or a variable initializer) +// Line: 17 + +using System; + +public class Test +{ + struct Container + { + public int foo { get; set; } + } + + readonly Container p; + + void Foo () + { + p.foo = 0; + } + + public static void Main () + { + } +}
\ No newline at end of file diff --git a/mcs/errors/cs1648-3.cs b/mcs/errors/cs1648-3.cs new file mode 100644 index 0000000000..7afc29f193 --- /dev/null +++ b/mcs/errors/cs1648-3.cs @@ -0,0 +1,26 @@ +// CS1648: Members of readonly field `Test.p' cannot be modified (except in a constructor or a variable initializer) +// Line: 17 + +using System; + +public class Test +{ + struct Container + { + public int this[int arg] { + set { + } + } + } + + readonly Container p; + + void Foo () + { + p[0] = 0; + } + + public static void Main () + { + } +}
\ No newline at end of file diff --git a/mcs/errors/cs1650-2.cs b/mcs/errors/cs1650-2.cs new file mode 100644 index 0000000000..9aa902d435 --- /dev/null +++ b/mcs/errors/cs1650-2.cs @@ -0,0 +1,18 @@ +// CS1650: Fields of static readonly field `C.s' cannot be assigned to (except in a static constructor or a variable initializer) +// Line: 15 + +struct S +{ + public int x { get; set; } +} + +class C +{ + static readonly S s; + + public static void Main (string[] args) + { + s.x = 42; + } +} + diff --git a/mcs/errors/cs1654-3.cs b/mcs/errors/cs1654-3.cs new file mode 100644 index 0000000000..c49e6875dd --- /dev/null +++ b/mcs/errors/cs1654-3.cs @@ -0,0 +1,25 @@ +// CS1654: Cannot assign to members of `f' because it is a `using variable' +// Line: 22 + +using System; + +struct Foo : IDisposable +{ + public int Property { + set { } + } + + public void Dispose () + { + } +} + +class Bar +{ + static void Main () + { + using (var f = new Foo ()) { + f.Property = 0; + } + } +}
\ No newline at end of file diff --git a/mcs/errors/cs1654-4.cs b/mcs/errors/cs1654-4.cs new file mode 100644 index 0000000000..c568ddeb68 --- /dev/null +++ b/mcs/errors/cs1654-4.cs @@ -0,0 +1,25 @@ +// CS1654: Cannot assign to members of `f' because it is a `using variable' +// Line: 22 + +using System; + +struct Foo : IDisposable +{ + public int this[int arg] { + set { } + } + + public void Dispose () + { + } +} + +class Bar +{ + static void Main () + { + using (var f = new Foo ()) { + f[0] = 1; + } + } +}
\ No newline at end of file diff --git a/mcs/errors/cs1739-4.cs b/mcs/errors/cs1739-4.cs new file mode 100644 index 0000000000..ab18a009be --- /dev/null +++ b/mcs/errors/cs1739-4.cs @@ -0,0 +1,14 @@ +// CS1739: The best overloaded method match for `Program.M(int, int, int)' does not contain a parameter named `whatever' +// Line: 8 + +public class Program +{ + public static void Main () + { + M (z: 1, whatever: 0); + } + + void M (int x = 0, int y = 0, int z = 0) + { + } +} diff --git a/mcs/errors/known-issues-net_4_5 b/mcs/errors/known-issues-net_4_5 index 5d05d2ad67..a2f951235f 100644 --- a/mcs/errors/known-issues-net_4_5 +++ b/mcs/errors/known-issues-net_4_5 @@ -14,8 +14,10 @@ # Parser problems cs0080.cs -cs0162-7.cs NO ERROR - # Operators cs0457-2.cs cs0457.cs + +cs1060.cs NO ERROR +cs1060-2.cs NO ERROR +cs1060-3.cs NO ERROR |