Allow Conditional attribute to be used with a keyword value
authorMarek Safar <marek.safar@gmail.com>
Mon, 31 Oct 2011 17:52:18 +0000 (17:52 +0000)
committerMarek Safar <marek.safar@gmail.com>
Wed, 2 Nov 2011 11:09:48 +0000 (11:09 +0000)
mcs/mcs/attribute.cs
mcs/tests/test-831.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_5.xml

index 4a8adff9b6cfa3c3d6465ff2aa227db770702aca..867f726fd0db2bd3540f9402e5f636aacbd88304 100644 (file)
@@ -958,7 +958,7 @@ namespace Mono.CSharp {
                                                if (j == 0) {
                                                        if ((Type == predefined.IndexerName || Type == predefined.Conditional) && arg_expr is Constant) {
                                                                string v = ((Constant) arg_expr).GetValue () as string;
-                                                               if (!Tokenizer.IsValidIdentifier (v) || Tokenizer.IsKeyword (v)) {
+                                                               if (!Tokenizer.IsValidIdentifier (v) || (Type == predefined.IndexerName && Tokenizer.IsKeyword (v))) {
                                                                        context.Module.Compiler.Report.Error (633, arg_expr.Location,
                                                                                "The argument to the `{0}' attribute must be a valid identifier", GetSignatureForError ());
                                                                        return;
diff --git a/mcs/tests/test-831.cs b/mcs/tests/test-831.cs
new file mode 100644 (file)
index 0000000..ffcb3d4
--- /dev/null
@@ -0,0 +1,13 @@
+using System.Diagnostics;
+
+class C
+{
+       [Conditional ("true")]
+       static void Test ()
+       {
+       }
+
+       static void Main ()
+       {
+       }
+}
\ No newline at end of file
index 9332ab87319a8e30cae9c141529ef39c3d541d80..a64cd8b28aefc836e55f3751601becc4acdedf8e 100644 (file)
       </method>
     </type>
   </test>
+  <test name="test-831.cs">
+    <type name="C">
+      <method name="Void Test()">
+        <size>1</size>
+      </method>
+      <method name="Void Main()">
+        <size>1</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="test-84.cs">
     <type name="Ghost">
       <method name="Void .ctor()">