--- /dev/null
+// CS4004: The `await' operator cannot be used in an unsafe context
+// Line: 12
+// Compiler options: -langversion:future -unsafe
+
+using System;
+using System.Threading.Tasks;
+
+unsafe class C
+{
+ public async Task Test ()
+ {
+ await Call ();
+ }
+
+ static Task Call ()
+ {
+ return null;
+ }
+}
--- /dev/null
+// CS4004: The `await' operator cannot be used in an unsafe context
+// Line: 12
+// Compiler options: -langversion:future -unsafe
+
+using System;
+using System.Threading.Tasks;
+
+class C
+{
+ public async Task Test ()
+ {
+ unsafe {
+ await Call ();
+ }
+ }
+
+ static Task Call ()
+ {
+ return null;
+ }
+}
--- /dev/null
+// CS4005: Async methods cannot have unsafe parameters
+// Line: 7
+// Compiler options: -langversion:future -unsafe
+
+class C
+{
+ public unsafe async void Test (int* arg)
+ {
+ }
+}
--- /dev/null
+// CS4006: __arglist is not allowed in parameter list of async methods
+// Line: 9
+// Compiler options: -langversion:future
+
+using System.Threading.Tasks;
+
+class C
+{
+ public async Task Test (__arglist)
+ {
+ await Call ();
+ }
+
+ static Task Call ()
+ {
+ return null;
+ }
+}
--- /dev/null
+// CS4009: `C.Main()': an entry point cannot be async method
+// Line: 7
+// Compiler options: -langversion:future
+
+class C
+{
+ public static async void Main ()
+ {
+ await Call ();
+ }
+
+ static async void Call ()
+ {
+ }
+}
}
if (rc.IsUnsafe) {
- // TODO: New error code
- rc.Report.Error (-1900, loc,
+ rc.Report.Error (4004, loc,
"The `await' operator cannot be used in an unsafe context");
}
return;
}
- // TODO:
if (p is ArglistParameter) {
- host.Compiler.Report.Error (1636, p.Location,
- "__arglist is not allowed in parameter list of iterators");
+ host.Compiler.Report.Error (4006, p.Location,
+ "__arglist is not allowed in parameter list of async methods");
return;
}
- // TODO:
if (parameters.Types[i].IsPointer) {
- host.Compiler.Report.Error (1637, p.Location,
- "Iterators cannot have unsafe parameters or yield types");
+ host.Compiler.Report.Error (4005, p.Location,
+ "Async methods cannot have unsafe parameters");
return;
}
}
if (Parent.IsGeneric || MemberName.IsGeneric) {
Report.Warning (402, 4, Location, "`{0}': an entry point cannot be generic or in a generic type",
GetSignatureForError ());
+ } else if ((ModFlags & Modifiers.ASYNC) != 0) {
+ Report.Error (4009, Location, "`{0}': an entry point cannot be async method",
+ GetSignatureForError ());
} else {
SetIsUsed ();
Parent.DeclaringAssembly.EntryPoint = this;