2004-08-04 Marek Safar <[email protected]>

* 62 new error tests.

svn path=/trunk/mcs/; revision=31867
This commit is contained in:
Marek Safar committed 2004-08-04 14:04:42 +00:00
1 parent babecb6d8b
commit 6094dea7af
83 files changed
+644 -145

No files matched your search

+4
View File
@@ -1,3 +1,7 @@
2004-08-04 Marek Safar <[email protected]>
* 62 new error tests.
2004-07-23 Martin Baulig <[email protected]>
* cs0260.cs, cs0260-2.cs, cs0261.cs, cs0262.cs, cs0263.cs: New
+3
View File
@@ -0,0 +1,3 @@
// cs0066.cs : 'System.TypedReference' : event must be of a delegate type
// Line: 5
public class Sample { event System.TypedReference reference;}
+5 -15
View File
@@ -1,17 +1,7 @@
// CS0102: The container `Test' already contains a definition for `x'
// Line: 10
partial class Test
{
int x;
}
// cs102.cs: The class 'X' already contains a definition for 'A'
// Line: 6
partial class Test
{
int x;
}
class X
{
static void Main ()
{ }
class X {
const int A = 10;
int A () {}
}
+8
View File
@@ -0,0 +1,8 @@
// 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; } }
}
+16
View File
@@ -0,0 +1,16 @@
// 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);
}
}
+8
View File
@@ -0,0 +1,8 @@
// cs0146.cs: Circular base class dependency involving 'B' and 'A'
// Line: 7
struct A : B {
}
struct B : A {
}
+3 -2
View File
@@ -1,5 +1,6 @@
// cs0146.cs: circular class definition
// Line: 6
// cs0146.cs: Circular base class dependency involving 'B' and 'A'
// Line: 7
class A : B {
}
+10
View File
@@ -0,0 +1,10 @@
// 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) { }
}
}
+13
View File
@@ -0,0 +1,13 @@
// 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..");
}
}
+11
View File
@@ -0,0 +1,11 @@
// 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;
}
}
+15
View File
@@ -0,0 +1,15 @@
// 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 () {}
}
+17
View File
@@ -0,0 +1,17 @@
// 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);
}
}
+8 -19
View File
@@ -1,19 +1,8 @@
// cs0158.cs: A static readonly field cannot be passed ref or out (except in a static constructor)
// Line: 16
class ClassMain {
static readonly int index;
static ClassMain () {
GetMaxIndex (ref index);
}
static void GetMaxIndex (ref int value) {
value = 5;
}
public static void Main () {
GetMaxIndex (ref index);
}
}
// cs0199.cs: A static readonly field cannot be passed ref or out (except in a static constructor)␍// Line: 19
class ClassMain {␍ static readonly int index;
static ClassMain ()
{␍ GetMaxIndex (ref index);␍ }
static void GetMaxIndex (ref int value)
{␍ value = 5;␍ }
public static void Main ()
{␍ GetMaxIndex (ref index);␍ }␍}
+11
View File
@@ -0,0 +1,11 @@
// 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;
}
}
+2 -3
View File
@@ -1,6 +1,5 @@
//
// 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;
+3 -7
View File
@@ -1,7 +1,3 @@
// cs0231.cs: A params or __arglist parameter must be the last in a formal parameter list
// Line: 5
class Test {
void Foo (params object[] o, bool b) {}
}
// 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) {}}
+7 -8
View File
@@ -1,8 +1,7 @@
// cs0241.cs: Default parameter specifiers are not permitted
// Line: 5
class TestClass {
public TestClass(int value = 0) {
}
}
// cs0241.cs: Default parameter specifiers are not permitted
// Line: 5
class TestClass {
public TestClass(int value = 0) {
}
}
+9 -9
View File
@@ -1,9 +1,9 @@
// cs0245.cs: Destructors and object.Finalize cannot be called directly. Consider calling IDisposable.Dispose if available
// Line: 6
class Sample {
void Close () {
this.Finalize();
}
}
// cs0245.cs: Destructors and object.Finalize cannot be called directly. Consider calling IDisposable.Dispose if available
// Line: 7
class Sample {
void Close ()
{
this.Finalize();
}
}
+12
View File
@@ -0,0 +1,12 @@
// 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];
}
}
+20
View File
@@ -0,0 +1,20 @@
// 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)
{
}
}
}
+3
View File
@@ -0,0 +1,3 @@
// cs0257.cs: An __arglist parameter must be the last parameter in a formal parameter list// Line: 5
class Test { void Foo (__arglist, bool b) {}}
+2
View File
@@ -0,0 +1,2 @@
// 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(); }}
+10
View File
@@ -0,0 +1,10 @@
// cs0518.cs: The predefined type 'System.Object' is not defined or imported
// Line: 0
// Compiler options: -nostdlib
class MainClass
{
public static void Main ()
{
}
}
+4
View File
@@ -0,0 +1,4 @@
// cs0524.cs: 'I' : interfaces cannot declare types// Line: 5
interface Interface {
interface I {}
}
+7
View File
@@ -0,0 +1,7 @@
// cs0524.cs: 'E' : interfaces cannot declare types// Line: 5
interface Interface {
enum E {
White,
Black
}
}
+7
View File
@@ -0,0 +1,7 @@
// cs0524.cs: 'C' : interfaces cannot declare types
// Line: 5
interface Interface {
public class C {
}
}
+6
View File
@@ -0,0 +1,6 @@
// cs0524.cs: 'D' : interfaces cannot declare types
// Line: 5
interface Interface {
delegate void D ();
}
+7 -10
View File
@@ -1,10 +1,7 @@
// cs0524.cs: 'Struct' : interfaces cannot declare types
// Line: 5
interface Interface {
public struct Struct {
}
}
// cs0524.cs: 'Struct' : interfaces cannot declare types
// Line: 5
interface Interface {
public struct Struct {
}
}
+2
View File
@@ -0,0 +1,2 @@
// cs0525.cs: Interfaces cannot contain fields// Line: 5
interface Interface { const bool value = false;}
+2 -9
View File
@@ -1,9 +1,2 @@
// cs0525.cs: Interfaces cannot contain fields
// Line: 5
interface Interface {
bool value = false;
}
// cs0525.cs: Interfaces cannot contain fields// Line: 5
interface Interface { bool value = false;}
+8 -10
View File
@@ -1,10 +1,8 @@
// cs0526.cs: Interfaces cannot contain constructors
// Line: 5
public interface Interface {
public Interface () {
}
}
// cs0526.cs: Interfaces cannot contain constructors
// Line: 5
public interface Interface {
public Interface ()
{
}
}
+7 -3
View File
@@ -1,7 +1,11 @@
// 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 {
}
+2
View File
@@ -0,0 +1,2 @@
// cs0531.cs: 'Interface.P.get' : interface members cannot have a definition// Line: 5
public interface Interface { int P { get {} }}
+5 -5
View File
@@ -1,7 +1,7 @@
// 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; }
}
+6 -9
View File
@@ -1,9 +1,6 @@
// cs0547.cs: 'PropertyClass.Value' : property or indexer cannot have void type
// Line: 5
class PropertyClass {
public void Value { get {}
}
}
// cs0547.cs: 'Value' : property or indexer cannot have void type
// Line: 5
class PropertyClass {
public void Value { get {} }
}
+4
View File
@@ -0,0 +1,4 @@
// cs0548.cs: 'PropertyClass.Value' : property or indexer must have at least one accessor// Line: 5
interface PropertyInterface { int Value {}}
+4
View File
@@ -0,0 +1,4 @@
// cs0548.cs: 'PropertyClass.Value' : property or indexer must have at least one accessor// Line: 5
interface PropertyInterface { int this [long l] {}}
+6
View File
@@ -0,0 +1,6 @@
// cs0548.cs: 'this[bool]' : property or indexer must have at least one accessor
// Line: 5
class IndexerClass {
public int this [bool b] { }
}
+7 -9
View File
@@ -1,9 +1,7 @@
// cs0548.cs: 'PropertyClass.Value' : property or indexer must have at least one accessor
// Line: 5
class PropertyClass {
public int Value {
}
}
// cs0548.cs: 'PropertyClass.Value' : property or indexer must have at least one accessor
// Line: 5
class PropertyClass {
public int Value {
}
}
+8 -8
View File
@@ -1,8 +1,8 @@
// cs0559.cs: The parameter and return type for ++ or — operator must be the containing type
// Line: 5
class SampleClass {
public static SampleClass operator ++ (int value) {
return new SampleClass();
}
}
// 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();
}
}
+8
View File
@@ -0,0 +1,8 @@
// 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;
}
}
+8 -8
View File
@@ -1,8 +1,8 @@
// 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;
}
}
// 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;
}
}
+8
View File
@@ -0,0 +1,8 @@
// cs0590.cs: User-defined operators cannot return void
// Line: 5
class SampleClass {
public static void operator << (SampleClass value, int value) {
return null;
}
}
+6
View File
@@ -0,0 +1,6 @@
// cs0610.cs: Field or property cannot be of type 'System.TypedReference'
// Line: 5
public class Sample {
const System.TypedReference arg = null;
}
+6
View File
@@ -0,0 +1,6 @@
// cs0620.cs: Indexers cannot have void type
// Line: 5
interface Indexer {
void this [int i] { set; }
}
+7
View File
@@ -0,0 +1,7 @@
// cs0620.cs: Indexers cannot have void type
// Line: 5
class PropertyClass {
public void this [int i] { set {}
}
}
+9
View File
@@ -0,0 +1,9 @@
// 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};
}
}
+6
View File
@@ -0,0 +1,6 @@
// cs0622.cs: ref and out are not valid in this context
// Line: 5
class X {
public int this [ref int arg] { set {} }
}
+12
View File
@@ -0,0 +1,12 @@
// 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;
}
}
+11
View File
@@ -0,0 +1,11 @@
// 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;
}
+11
View File
@@ -0,0 +1,11 @@
// 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;
}
+10
View File
@@ -0,0 +1,10 @@
// cs0641.cs: Attribute 'AttributeUsage' is only valid on classes derived from System.Attribute
// Line: 6
using System;
[AttributeUsage (AttributeTargets.All)]
public class A
{
}
+9
View File
@@ -0,0 +1,9 @@
// 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];
}
}
+12
View File
@@ -0,0 +1,12 @@
// 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;
}
}
+13
View File
@@ -0,0 +1,13 @@
// cs0641.cs: Cannot apply attribute class 'Abstract' because it is abstract
// Line: 10
using System;
abstract class AbstractAttribute: Attribute
{
}
[Abstract]
class TestClass
{
}
+12
View File
@@ -0,0 +1,12 @@
// 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)
{
}
}
+10
View File
@@ -0,0 +1,10 @@
// 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;
}
}
+2 -4
View File
@@ -1,9 +1,7 @@
//
// 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)
{
+7
View File
@@ -0,0 +1,7 @@
// cs1009.cs: Unrecognized escape sequence
// Line : 6
class X
{
static string s = "\i";
}
+7
View File
@@ -0,0 +1,7 @@
// cs1013.cs: Invalid number
// Line : 6
class X
{
static int i = 0x;
}
+21
View File
@@ -0,0 +1,21 @@
// 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 () {}
}
+4
View File
@@ -0,0 +1,4 @@
// cs1024.cs: Preprocessor directive expected
// Line: 4
#wrong_directive
+5
View File
@@ -0,0 +1,5 @@
// cs1027.cs: #endif directive expected
// Line: 6
#if false
+5
View File
@@ -0,0 +1,5 @@
// cs1029.cs: #error: 'Expected error'
// Line: 4
#error Expected error
+6
View File
@@ -0,0 +1,6 @@
// cs1030.cs: #warning 'Expected error'
// Line: 4
// Compiler options: -warnaserror
#warning Expected warning
+11
View File
@@ -0,0 +1,11 @@
// cs1031.cs: Type expected
// Line: 8
class M
{
public static void Main ()
{
p = new this;
}
}
+5
View File
@@ -0,0 +1,5 @@
// cs1035.cs: End-of-file found, '*/' expected
// Line: 4
/*
+4
View File
@@ -0,0 +1,4 @@
// cs1035.cs: #endregion directive expected
// Line: 5
#region
+5
View File
@@ -0,0 +1,5 @@
// cs1040.cs: Preprocessor directives must appear as the first non-whitespace character on a line
// Line: 4
/* */ #define AA
+12
View File
@@ -0,0 +1,12 @@
// cs1055.cs: An add or remove accessor expected
// Line: 9
class E
{
delegate void test();
event test Event
{
bool add;
}
}
+12
View File
@@ -0,0 +1,12 @@
// 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 ();
}
+5
View File
@@ -0,0 +1,5 @@
// cs1517.cs: Invalid preprocessor expression
// Line: 4
#if 8
#endif
+11
View File
@@ -0,0 +1,11 @@
// cs1522.cs: Empty switch block
// Line: 9
// Compiler options: -warnaserror
class E
{
public static void Method (int i)
{
switch (i) {}
}
}
+2 -1
View File
@@ -1,5 +1,6 @@
// cs1525: Invalid expression term.
// cs1525: Invalid expression term '}'
// Line: 7
class X {
X ()
{
+3 -2
View File
@@ -1,5 +1,6 @@
// 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)
{
+10
View File
@@ -0,0 +1,10 @@
// cs1551.cs: Indexers must have at least one parameter
// Line: 8
class Test
{
public int this []
{
set {}
}
}
+3 -4
View File
@@ -1,11 +1,10 @@
//
// 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;
}
}
+11
View File
@@ -0,0 +1,11 @@
// 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;
}
}
+14
View File
@@ -0,0 +1,14 @@
// 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) {}
}
+7
View File
@@ -0,0 +1,7 @@
// cs1611.cs: The params parameter cannot be declared as ref or out
// Line: 6
class Test
{
public static void Error (params ref int args) {}
}
+7
View File
@@ -0,0 +1,7 @@
// 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")]
+12
View File
@@ -0,0 +1,12 @@
// 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 () {}
}
+3
View File
@@ -0,0 +1,3 @@
// cs2002.cs: Source file 'cs2002.cs' specified multiple times
// Line: 0
// Compiler options: cs2002.cs /warnaserror