* mcs/statement.cs (Foreach.ArrayForeach.Resolve): Set barrier after
[mono.git] / mcs / mcs / anonymous.cs
index 29bf017133aad4f5a104dfae5dcc5591c908043b..e4822e289163de6f252dae4892961d1a77e8f670 100644 (file)
@@ -81,7 +81,6 @@ namespace Mono.CSharp {
                        // The order is important: this setups the CaptureContext tree hierarchy.
                        //
                        if (container == null) {
-                               Report.Error (1706, l, "Anonymous methods are not allowed in attribute declaration");
                                return;
                        }
                        container.SetHaveAnonymousMethods (l, this);
@@ -384,6 +383,11 @@ namespace Mono.CSharp {
 
                public override Expression DoResolve (EmitContext ec)
                {
+                       if (!ec.IsAnonymousMethodAllowed) {
+                               Report.Error (1706, loc, "Anonymous methods are not allowed in the attribute declaration");
+                               return null;
+                       }
+
                        if (Parameters != null && !Parameters.Resolve (ec)) {
                                return null;
                        }