Update few async error codes
authorMarek Safar <marek.safar@gmail.com>
Thu, 15 Sep 2011 15:08:47 +0000 (16:08 +0100)
committerMarek Safar <marek.safar@gmail.com>
Thu, 15 Sep 2011 15:08:47 +0000 (16:08 +0100)
mcs/errors/cs4004-2.cs [new file with mode: 0644]
mcs/errors/cs4004.cs [new file with mode: 0644]
mcs/errors/cs4005.cs [new file with mode: 0644]
mcs/errors/cs4006.cs [new file with mode: 0644]
mcs/errors/cs4009.cs [new file with mode: 0644]
mcs/mcs/async.cs
mcs/mcs/method.cs

diff --git a/mcs/errors/cs4004-2.cs b/mcs/errors/cs4004-2.cs
new file mode 100644 (file)
index 0000000..43777a9
--- /dev/null
@@ -0,0 +1,19 @@
+// 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;
+       }
+}
diff --git a/mcs/errors/cs4004.cs b/mcs/errors/cs4004.cs
new file mode 100644 (file)
index 0000000..4f393c0
--- /dev/null
@@ -0,0 +1,21 @@
+// 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;
+       }
+}
diff --git a/mcs/errors/cs4005.cs b/mcs/errors/cs4005.cs
new file mode 100644 (file)
index 0000000..5b544ac
--- /dev/null
@@ -0,0 +1,10 @@
+// CS4005: Async methods cannot have unsafe parameters
+// Line: 7
+// Compiler options: -langversion:future -unsafe
+
+class C
+{
+       public unsafe async void Test (int* arg)
+       {
+       }
+}
diff --git a/mcs/errors/cs4006.cs b/mcs/errors/cs4006.cs
new file mode 100644 (file)
index 0000000..f8a6bde
--- /dev/null
@@ -0,0 +1,18 @@
+// 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;
+       }
+}
diff --git a/mcs/errors/cs4009.cs b/mcs/errors/cs4009.cs
new file mode 100644 (file)
index 0000000..038b2bd
--- /dev/null
@@ -0,0 +1,15 @@
+// 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 ()
+       {
+       }
+}
index 24c138ece12ce5e28a674cb63ab2a21717dce086..cc458659ceb51e5567d989b60224d323d3aada25 100644 (file)
@@ -64,8 +64,7 @@ namespace Mono.CSharp
                        }
 
                        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");
                        }
 
@@ -443,17 +442,15 @@ namespace Mono.CSharp
                                        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;
                                }
                        }
index 79d6715200ecc1b913d2f794e57f7e73344cf42a..a0c9edf8f590a09d296d25e7860cb8371a5750fb 100644 (file)
@@ -1222,6 +1222,9 @@ namespace Mono.CSharp {
                                                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;