* 62 new error tests.
svn path=/trunk/mcs/; revision=31867
+2004-08-04 Marek Safar <marek.safar@seznam.cz>
+
+ * 62 new error tests.
+
2004-07-23 Martin Baulig <martin@ximian.com>
* cs0260.cs, cs0260-2.cs, cs0261.cs, cs0262.cs, cs0263.cs: New
--- /dev/null
+// cs0066.cs : 'System.TypedReference' : event must be of a delegate type
+// Line: 5
+public class Sample { event System.TypedReference reference;}
\ No newline at end of file
-// CS0102: The container `Test' already contains a definition for `x'
-// Line: 10
-partial class Test
-{
- int x;
-}
-
-partial class Test
-{
- int x;
-}
+// cs102.cs: The class 'X' already contains a definition for 'A'
+// Line: 6
-class X
-{
- static void Main ()
- { }
+class X {
+ const int A = 10;
+ int A () {}
}
--- /dev/null
+// cs0111.cs: Class 'C' already defines a member called 'this' with the same parameter types
+// Line: 6
+
+class C
+{
+ bool this [int i] { get { return false; } }
+ bool this [int i] { get { return true; } }
+}
--- /dev/null
+// cs0119.cs: 'Test.E()' is a 'method', which is not valid in the given context
+// Line: 14
+
+using System;
+
+public class Test
+{
+ public static void E ()
+ {
+ }
+
+ public static void Main ()
+ {
+ Console.WriteLine(E.x);
+ }
+}
--- /dev/null
+// cs0146.cs: Circular base class dependency involving 'B' and 'A'
+// Line: 7
+
+struct A : B {
+}
+
+struct B : A {
+}
\ No newline at end of file
-// cs0146.cs: circular class definition
-// Line: 6
+// cs0146.cs: Circular base class dependency involving 'B' and 'A'
+// Line: 7
+
class A : B {
}
--- /dev/null
+// cs0160.cs: A previous catch clause already catches all exceptions of this or a super type 'System.Exception'
+// Line: 8
+
+class ClassMain {
+ public static void Main() {
+ try { }
+ catch (System.Exception) { }
+ catch (System.Exception) { }
+ }
+}
--- /dev/null
+// cs0162.cs: Unreachable code detected
+// Line: 11
+
+using System;
+
+class E
+{
+ public void Method (int i)
+ {
+ throw new ArgumentNullException ();
+ Console.WriteLine ("Once upon a time..");
+ }
+}
--- /dev/null
+// cs0168.cs: The variable 'p' is declared but never used
+// Line: 9
+// Compiler options: -warn:3 -warnaserror
+
+class Main
+{
+ public void Method (int i)
+ {
+ long p;
+ }
+}
--- /dev/null
+// cs0182.cs : An attribute argument must be a constant expression, typeof expression or array creation expression
+// Line : 13
+
+using System;
+
+class TestAttribute: Attribute
+{
+ public TestAttribute (int[,] i) {}
+}
+
+public class E
+{
+ [Test (null)]
+ public void Method () {}
+}
\ No newline at end of file
--- /dev/null
+// cs0192.cs: A readonly field cannot be passed ref or out (except in a constructor)
+// Line: 15
+
+class A
+{
+ public readonly int a;
+
+ public void Inc (out int a)
+ {
+ a = 3;
+ }
+
+ public void IncCall ()
+ {
+ Inc (out a);
+ }
+}
-// cs0158.cs: A static readonly field cannot be passed ref or out (except in a static constructor)\r
-// Line: 16\r
-\r
-class ClassMain {\r
- static readonly int index;\r
- \r
- static ClassMain () {\r
- GetMaxIndex (ref index);\r
- }\r
- \r
- static void GetMaxIndex (ref int value) {\r
- value = 5;\r
- }\r
- \r
- public static void Main () {\r
- GetMaxIndex (ref index);\r
- }\r
-}\r
-\r
+// cs0199.cs: A static readonly field cannot be passed ref or out (except in a static constructor)\r// Line: 19\r
+class ClassMain {\r static readonly int index;\r
+ static ClassMain ()
+ {\r GetMaxIndex (ref index);\r }\r
+ static void GetMaxIndex (ref int value)
+ {\r value = 5;\r }\r
+ public static void Main ()
+ {\r GetMaxIndex (ref index);\r }\r}\r
--- /dev/null
+// cs0219.cs: The variable 'p' is declared but its value is never used
+// Line: 9
+// Compiler options: -warn:3 -warnaserror
+
+class Main
+{
+ public void Method (int i)
+ {
+ long p = -9;
+ }
+}
-//
-// CS0230.cs: foreach statement must contain the type and the variable identifier
-//
+// CS0230.cs: Type and identifier are both required in a foreach statement
+// Lise: 12
using System;
-// cs0231.cs: A params or __arglist parameter must be the last in a formal parameter list\r
-// Line: 5\r
-\r
-class Test {\r
- void Foo (params object[] o, bool b) {}\r
-}\r
-\r
+// cs0231.cs: A params parameter must be the last in a formal parameter list// Line: 5
+class Test {
+ void Foo (params object[] o, bool b) {}}
-// cs0241.cs: Default parameter specifiers are not permitted\r
-// Line: 5\r
-\r
-class TestClass {\r
- public TestClass(int value = 0) {\r
- }\r
-}\r
-\r
+// cs0241.cs: Default parameter specifiers are not permitted
+// Line: 5
+
+class TestClass {
+ public TestClass(int value = 0) {
+ }
+}
-// cs0245.cs: Destructors and object.Finalize cannot be called directly. Consider calling IDisposable.Dispose if available\r
-// Line: 6\r
-\r
-class Sample {\r
- void Close () {\r
- this.Finalize();\r
- }\r
-}\r
-\r
+// cs0245.cs: Destructors and object.Finalize cannot be called directly. Consider calling IDisposable.Dispose if available
+// Line: 7
+
+class Sample {
+ void Close ()
+ {
+ this.Finalize();
+ }
+}
--- /dev/null
+// cs0251.cs: Indexing an array with a negative index (array indices always start at zero)
+// Line: 10
+// Compiler options: -warn:2 -warnaserror
+
+class Main
+{
+ public int Method (int[] array)
+ {
+ const int index = 5;
+ return array [index - 10];
+ }
+}
--- /dev/null
+// cs0254.cs: The right hand side of a fixed statement assignment may not be a cast expression
+// Line: 16
+// Compiler options: -unsafe
+
+class Box {
+ public int value;
+}
+
+unsafe struct Obsolete {
+}
+
+class MainClass {
+ unsafe public static void Main ()
+ {
+ Box b = new Box ();
+ fixed (long* p = (long*)&b.value)
+ {
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+// cs0257.cs: An __arglist parameter must be the last parameter in a formal parameter list// Line: 5
+class Test { void Foo (__arglist, bool b) {}}
+
--- /dev/null
+// cs0448.cs: The return type for ++ or -- operator must be the containing type or derived from the containing type// Line: 5
+class SampleClass { public static int operator ++ (SampleClass value) { return new SampleClass(); }}
\ No newline at end of file
--- /dev/null
+// cs0518.cs: The predefined type 'System.Object' is not defined or imported
+// Line: 0
+// Compiler options: -nostdlib
+
+class MainClass
+{
+ public static void Main ()
+ {
+ }
+}
--- /dev/null
+// cs0524.cs: 'I' : interfaces cannot declare types// Line: 5
+interface Interface {
+ interface I {}
+}
\ No newline at end of file
--- /dev/null
+// cs0524.cs: 'E' : interfaces cannot declare types// Line: 5
+interface Interface {
+ enum E {
+ White,
+ Black
+ }
+}
\ No newline at end of file
--- /dev/null
+// cs0524.cs: 'C' : interfaces cannot declare types
+// Line: 5
+
+interface Interface {
+ public class C {
+ }
+}
--- /dev/null
+// cs0524.cs: 'D' : interfaces cannot declare types
+// Line: 5
+
+interface Interface {
+ delegate void D ();
+}
-// cs0524.cs: 'Struct' : interfaces cannot declare types\r
-// Line: 5\r
-\r
-interface Interface {\r
- public struct Struct {\r
- }\r
-}\r
-\r
-\r
-\r
+// cs0524.cs: 'Struct' : interfaces cannot declare types
+// Line: 5
+
+interface Interface {
+ public struct Struct {
+ }
+}
--- /dev/null
+// cs0525.cs: Interfaces cannot contain fields// Line: 5
+interface Interface { const bool value = false;}
\ No newline at end of file
-// cs0525.cs: Interfaces cannot contain fields\r
-// Line: 5\r
-\r
-interface Interface {\r
- bool value = false;\r
-}\r
-\r
-\r
-\r
+// cs0525.cs: Interfaces cannot contain fields// Line: 5
+interface Interface { bool value = false;}
\ No newline at end of file
-// cs0526.cs: Interfaces cannot contain constructors\r
-// Line: 5\r
-\r
-public interface Interface {\r
- public Interface () {\r
- }\r
-}\r
-\r
-\r
-\r
+// cs0526.cs: Interfaces cannot contain constructors
+// Line: 5
+
+public interface Interface {
+ public Interface ()
+ {
+ }
+}
-// cs0529: Recursive interface definition
-// Line: 3
+// cs0529: Inherited interface 'C' causes a cycle in the interface hierarchy of 'A'
+// Line: 10
+
interface A : B {
}
-interface B : A {
+interface B : C {
}
+
+interface C : A {
+}
\ No newline at end of file
--- /dev/null
+// cs0531.cs: 'Interface.P.get' : interface members cannot have a definition// Line: 5
+public interface Interface { int P { get {} }}
\ No newline at end of file
-// cs0547.cs: 'Property' : property or indexer cannot have void type// Line: 5
-interface Interface {
- void Property { get; }
-}
-
+// cs0547.cs: 'Value' : property cannot have void type
+// Line: 5
+interface PropertyInterface {
+ void Value { get; }
+}
-// cs0547.cs: 'PropertyClass.Value' : property or indexer cannot have void type\r
-// Line: 5\r
-\r
-class PropertyClass {\r
- public void Value { get {}\r
- }\r
-}\r
-\r
-\r
+// cs0547.cs: 'Value' : property or indexer cannot have void type
+// Line: 5
+
+class PropertyClass {
+ public void Value { get {} }
+}
--- /dev/null
+// cs0548.cs: 'PropertyClass.Value' : property or indexer must have at least one accessor// Line: 5
+interface PropertyInterface { int Value {}}
+
+
--- /dev/null
+// cs0548.cs: 'PropertyClass.Value' : property or indexer must have at least one accessor// Line: 5
+interface PropertyInterface { int this [long l] {}}
+
+
--- /dev/null
+// cs0548.cs: 'this[bool]' : property or indexer must have at least one accessor
+// Line: 5
+
+class IndexerClass {
+ public int this [bool b] { }
+}
-// cs0548.cs: 'PropertyClass.Value' : property or indexer must have at least one accessor\r
-// Line: 5\r
-\r
-class PropertyClass {\r
- public int Value {\r
- }\r
-}\r
-\r
-\r
+// cs0548.cs: 'PropertyClass.Value' : property or indexer must have at least one accessor
+// Line: 5
+
+class PropertyClass {
+ public int Value {
+ }
+}
-// cs0559.cs: The parameter and return type for ++ or \97 operator must be the containing type\r
-// Line: 5\r
-\r
-class SampleClass {\r
- public static SampleClass operator ++ (int value) {\r
- return new SampleClass();\r
- }\r
-}\r
+// cs0559.cs: The parameter type for ++ or -- operator must be the containing type
+// Line: 5
+
+class SampleClass {
+ public static SampleClass operator ++ (int value) {
+ return new SampleClass();
+ }
+}
--- /dev/null
+// cs0564.cs: Overloaded shift operator must have the type of the first operand be the containing type, and the type of the second operand must be int
+// Line: 5
+
+class SampleClass {
+ public static int operator << (object value, int count) {
+ return 0;
+ }
+}
-// cs0564.cs: Overloaded shift operator must have the type of the first operand be the containing type, and the type of the second operand must be int\r
-// Line: 5\r
-\r
-class SampleClass {\r
- public static int operator << (SampleClass value, SampleClass count) {\r
- return 0;\r
- }\r
-}\r
+// cs0564.cs: Overloaded shift operator must have the type of the first operand be the containing type, and the type of the second operand must be int
+// Line: 5
+
+class SampleClass {
+ public static int operator << (SampleClass value, SampleClass count) {
+ return 0;
+ }
+}
--- /dev/null
+// cs0590.cs: User-defined operators cannot return void
+// Line: 5
+
+class SampleClass {
+ public static void operator << (SampleClass value, int value) {
+ return null;
+ }
+}
--- /dev/null
+// cs0610.cs: Field or property cannot be of type 'System.TypedReference'
+// Line: 5
+
+public class Sample {
+ const System.TypedReference arg = null;
+}
--- /dev/null
+// cs0620.cs: Indexers cannot have void type
+// Line: 5
+
+interface Indexer {
+ void this [int i] { set; }
+}
--- /dev/null
+// cs0620.cs: Indexers cannot have void type
+// Line: 5
+
+class PropertyClass {
+ public void this [int i] { set {}
+ }
+}
--- /dev/null
+// cs0622.cs: Can only use array initializer expressions to assign to array types. Try using a new expression instead
+// Line: 7
+
+class X {
+ public static void Main ()
+ {
+ int i = { 3, 4, 5};
+ }
+}
--- /dev/null
+// cs0622.cs: ref and out are not valid in this context
+// Line: 5
+
+class X {
+ public int this [ref int arg] { set {} }
+}
--- /dev/null
+// CS0636: The FieldOffset attribute can only be placed on members of types marked with the StructLayout(LayoutKind.Explicit)
+// Line: 10
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace cs0636 {
+ class GValue {
+ [FieldOffset (4)]
+ public const int value = 2;
+ }
+}
--- /dev/null
+// CS0636: The 'FieldOffset' attribute is not allowed on static or const fields
+// Line: 10
+
+using System;
+using System.Runtime.InteropServices;
+
+[StructLayout(LayoutKind.Explicit)]
+struct GValue {
+ [FieldOffset (4)]
+ public const int value = 3;
+}
\ No newline at end of file
--- /dev/null
+// CS0636: The 'FieldOffset' attribute is not allowed on static or const fields
+// Line: 10
+
+using System;
+using System.Runtime.InteropServices;
+
+[StructLayout(LayoutKind.Explicit)]
+struct GValue {
+ [FieldOffset (4)]
+ public static int value = 3;
+}
\ No newline at end of file
--- /dev/null
+// cs0641.cs: Attribute 'AttributeUsage' is only valid on classes derived from System.Attribute
+// Line: 6
+
+using System;
+
+[AttributeUsage (AttributeTargets.All)]
+public class A
+{
+}
+
--- /dev/null
+// cs0650.cs: Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed buffer field, use the fixed keyword before the field type
+// Line: 7
+
+class X {
+ public static void Main ()
+ {
+ int myarray[2];
+ }
+}
--- /dev/null
+// cs0652.cs: Comparison to integral constant is useless; the constant is outside the range of type 'type'
+// Line: 9
+
+class X
+{
+ void b ()
+ {
+ byte b = 0;
+ if (b == 500)
+ return;
+ }
+}
--- /dev/null
+// cs0641.cs: Cannot apply attribute class 'Abstract' because it is abstract
+// Line: 10
+
+using System;
+
+abstract class AbstractAttribute: Attribute
+{
+}
+
+[Abstract]
+class TestClass
+{
+}
\ No newline at end of file
--- /dev/null
+// cs0674.cs: Do not use 'System.ParamArrayAttribute'. Use the 'params' keyword instead
+// Line: 8
+
+using System;
+
+public class X
+{
+ public void Error ([ParamArray] int args)
+ {
+ }
+
+}
--- /dev/null
+// cs0685.cs: Conditional method 'MainClass.Method(out int)' cannot have an out parameter
+// Line: 6
+
+class MainClass {
+ [System.Diagnostics.Conditional("DEBUG")]
+ public void Method (out int o)
+ {
+ o = 3;
+ }
+}
-//
-// cs1001: identifier expected
-// Line: 8
+// cs1001: Identifier expected
+// Line: 6
class T {
-
// Change (args) to (string args) to fix it
public static int Main (args)
{
--- /dev/null
+// cs1009.cs: Unrecognized escape sequence
+// Line : 6
+
+class X
+{
+ static string s = "\i";
+}
\ No newline at end of file
--- /dev/null
+// cs1013.cs: Invalid number
+// Line : 6
+
+class X
+{
+ static int i = 0x;
+}
\ No newline at end of file
--- /dev/null
+// cs1016.cs: Named attribute argument expected
+// Line: 19
+
+using System;
+using System.Runtime.CompilerServices;
+
+class Attr: Attribute
+{
+ public Attr (int i) {}
+
+ public string Arg {
+ set {}
+ get { return "a"; }
+ }
+}
+
+public class E
+{
+ [Attr (Arg = "xxx", 3)]
+ public void Method () {}
+}
\ No newline at end of file
--- /dev/null
+// cs1024.cs: Preprocessor directive expected
+// Line: 4
+
+#wrong_directive
--- /dev/null
+// cs1027.cs: #endif directive expected
+// Line: 6
+
+#if false
+
--- /dev/null
+// cs1029.cs: #error: 'Expected error'
+// Line: 4
+
+#error Expected error
+
--- /dev/null
+// cs1030.cs: #warning 'Expected error'
+// Line: 4
+// Compiler options: -warnaserror
+
+#warning Expected warning
+
--- /dev/null
+// cs1031.cs: Type expected
+// Line: 8
+
+class M
+{
+ public static void Main ()
+ {
+ p = new this;
+ }
+}
+
--- /dev/null
+// cs1035.cs: End-of-file found, '*/' expected
+// Line: 4
+
+/*
+
--- /dev/null
+// cs1035.cs: #endregion directive expected
+// Line: 5
+
+#region
--- /dev/null
+// cs1040.cs: Preprocessor directives must appear as the first non-whitespace character on a line
+// Line: 4
+
+/* */ #define AA
+
--- /dev/null
+// cs1055.cs: An add or remove accessor expected
+// Line: 9
+
+class E
+{
+ delegate void test();
+ event test Event
+ {
+ bool add;
+ }
+}
+
--- /dev/null
+// cs1512.cs: Keyword 'base' is not available in the current context
+// Line: 11
+
+class Base
+{
+ private string B () { return "a"; }
+}
+
+class E
+{
+ private string B = base.B ();
+}
--- /dev/null
+// cs1517.cs: Invalid preprocessor expression
+// Line: 4
+
+#if 8
+#endif
--- /dev/null
+// cs1522.cs: Empty switch block
+// Line: 9
+// Compiler options: -warnaserror
+
+class E
+{
+ public static void Method (int i)
+ {
+ switch (i) {}
+ }
+}
-// cs1525: Invalid expression term.
+// cs1525: Invalid expression term '}'
// Line: 7
+
class X {
X ()
{
-// cs1528.cs: cant specify constructor arguments in declaration
-// Line:
+// cs1528.cs: Expected ; or = (cannot specify constructor arguments in declaration)
+// Line: 13
+
class X {
X (int a)
{
--- /dev/null
+// cs1551.cs: Indexers must have at least one parameter
+// Line: 8
+
+class Test
+{
+ public int this []
+ {
+ set {}
+ }
+}
\ No newline at end of file
-//
-// cs1552.cs: Array type specified, [] must appear before parameter name
-// Line: 8
+// cs1552.cs: Array type specifier, [], must appear before parameter name
+// Line: 6
class T {
// To fix: change (string args[]) to (string [] args)
-
public static int Main (string args[])
{
+ return 0;
}
}
--- /dev/null
+// cs1575.cs: A stackalloc expression requires [] after type
+// Line: 9
+// Compiler options: -unsafe
+
+class E
+{
+ public unsafe void Method (int i)
+ {
+ long* p = stackalloc long;
+ }
+}
--- /dev/null
+// cs1605.cs: Cannot pass 'i' as a ref or out argument because it is read-only
+// Line: 9
+
+class E
+{
+ public E (int[] args)
+ {
+ foreach (int i in args)
+ Init (ref i);
+ }
+
+ void Init (ref int val) {}
+
+}
--- /dev/null
+// cs1611.cs: The params parameter cannot be declared as ref or out
+// Line: 6
+
+class Test
+{
+ public static void Error (params ref int args) {}
+}
\ No newline at end of file
--- /dev/null
+// cs1616.cs: Option 'keycontainer' overrides 'System.Reflection.AssemblyKeyNameAttribute' given in source
+// Line: 0
+// Compiler options: -keycontainer:CS1616.snk -warnaserror
+
+using System.Reflection;
+
+[assembly: AssemblyKeyNameAttribute("mono.snk")]
--- /dev/null
+// cs1616.cs: Option 'keyfile' overrides 'System.Reflection.AssemblyKeyFileAttribute' given in source
+// Line: 0
+// Compiler options: -keyfile:CS1616.snk -warnaserror
+
+using System.Reflection;
+
+[assembly: AssemblyKeyFile("mono.snk")]
+
+class C
+{
+ public static void Main () {}
+}
\ No newline at end of file
--- /dev/null
+// cs2002.cs: Source file 'cs2002.cs' specified multiple times
+// Line: 0
+// Compiler options: cs2002.cs /warnaserror