In ilasm/parser:
authorAnkit Jain <radical@corewars.org>
Thu, 2 Feb 2006 14:59:04 +0000 (14:59 -0000)
committerAnkit Jain <radical@corewars.org>
Thu, 2 Feb 2006 14:59:04 +0000 (14:59 -0000)
* ILParser.jay (bound | int32 ELLIPSIS int32): Throw exception if
lower_bound > upper_bound.

In ilasm/errors:

* err-invalid-array-bounds.il: New. Test for 'lower bound <= upper bound'

svn path=/trunk/mcs/; revision=56470

mcs/ilasm/errors/ChangeLog
mcs/ilasm/errors/err-invalid-array-bounds.il [new file with mode: 0644]
mcs/ilasm/parser/ChangeLog
mcs/ilasm/parser/ILParser.jay

index 1f98ed5ab7ff1608c10d6eb008bdc0bc3bb190e9..68eebcad1d42a27309538d72bf3be30a78f39e1a 100644 (file)
@@ -1,3 +1,7 @@
+2006-02-02  Ankit Jain  <jankit@novell.com>
+
+       * err-invalid-array-bounds.il: New. Test for 'lower bound <= upper bound'
+
 2006-01-23  Ankit Jain  <jankit@novell.com>
 
        * err-*.il, test-perm_fail*.il: Move negative tests from tests/ to here.
diff --git a/mcs/ilasm/errors/err-invalid-array-bounds.il b/mcs/ilasm/errors/err-invalid-array-bounds.il
new file mode 100644 (file)
index 0000000..c2ce0bb
--- /dev/null
@@ -0,0 +1,40 @@
+// Test for invalid array bounds, [5...1]
+// lower bound <= upper bound
+
+.assembly extern mscorlib
+{
+  .ver 1:0:5000:0
+  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'err-invalid-array-bounds'
+{
+  .hash algorithm 0x00008004
+  .ver  0:0:0:0
+}
+.module 'err-invalid-array-bounds.exe'
+
+
+  .class private auto ansi beforefieldinit test
+       extends [mscorlib]System.Object
+  {
+
+    .method public hidebysig  specialname  rtspecialname 
+           instance default void .ctor ()  cil managed 
+    {
+       .maxstack 8
+       IL_0000:  ldarg.0 
+       IL_0001:  call instance void object::.ctor()
+       IL_0006:  ret 
+    }
+
+    .method public static  hidebysig 
+           default void Main ()  cil managed 
+    {
+       .entrypoint
+       .maxstack 0
+       .locals init (
+               int32[5...1]    V_0)
+       IL_0000:  ret 
+    }
+
+  }
index 489d20768ce9ecc5732286f6f0236f37b061bd39..c5fe34f09dd9a3b5964a8858395fc064f6b0d3fc 100644 (file)
@@ -1,3 +1,8 @@
+2006-02-02  Ankit Jain  <jankit@novell.com>
+
+       * ILParser.jay (bound | int32 ELLIPSIS int32): Throw exception if
+       lower_bound > upper_bound.     
+
 2006-01-28  Ankit Jain  <jankit@novell.com>
 
        * ILParser.jay (pinv_attr | ..): Fix typo.
index 39537e7aaa1389e098ec878f146a56327a2dfede..420d24ec36c97ff99060afb3346e1ce017c0f087 100644 (file)
@@ -1113,7 +1113,12 @@ bound                    : /* EMPTY */
                           }\r
                        | int32 ELLIPSIS int32\r
                           {\r
-                                // lower bound and size\r
+                                // lower and upper bound\r
+                                int lower = (int) $1;\r
+                                int upper = (int) $3;\r
+                                if (lower > upper) \r
+                                        throw new Exception (String.Format ("Lower bound {0} must be <= upper bound {1}", lower, upper));\r
+\r
                                 $$ = new DictionaryEntry ($1, $3);\r
                           }\r
                        | int32 ELLIPSIS\r