New test.
authorMarek Safar <marek.safar@gmail.com>
Fri, 2 May 2008 18:24:59 +0000 (18:24 -0000)
committerMarek Safar <marek.safar@gmail.com>
Fri, 2 May 2008 18:24:59 +0000 (18:24 -0000)
svn path=/trunk/mcs/; revision=102362

mcs/tests/test-643.cs [new file with mode: 0644]
mcs/tests/ver-il-gmcs.xml

diff --git a/mcs/tests/test-643.cs b/mcs/tests/test-643.cs
new file mode 100644 (file)
index 0000000..b8f6f16
--- /dev/null
@@ -0,0 +1,55 @@
+// Compiler options: -unsafe
+
+using System;
+
+class PointerArithmeticTest
+{
+       unsafe static int Main()
+       {
+               try {
+                       return CheckAdd((byte*)(-1), -1);
+               } catch (System.OverflowException) {}
+               
+               try {
+                       return CheckSub((short*)(-1), int.MaxValue);
+               } catch (System.OverflowException) {}
+               
+               CheckSub2((short*)(-1), int.MaxValue);
+                       
+               if ((long)Conversions (long.MaxValue) != uint.MaxValue)
+                       return 5;
+               
+               Console.WriteLine ("OK");
+               return 0;
+       }
+       
+       unsafe static int* Conversions (long b)
+       {
+               return (int*)b;
+       }
+       
+       unsafe static int CheckAdd(byte* ptr, int offset)
+       {
+               if (checked(ptr + offset < ptr))
+                       return 1;
+               
+               return 101;
+       }
+       
+       unsafe static int CheckSub(short* ptr, int offset)
+       {
+               if (checked(ptr - offset < ptr))
+                       return 2;
+
+               return 102;
+       }
+
+       unsafe static int CheckSub2(short* ptr, int offset)
+       {
+               short* b = ptr + offset;
+               if (checked(ptr - b < 0))
+                       return 3;
+
+               return 0;
+       }
+}
index 7db77635db381d0754466153c11d6e8ea0729b2f..1324c1ea57d4c5af823b388d2cafa9e1de8ab9f0 100644 (file)
   <test name="gtest-226.cs">
     <type name="A">
       <method name="Void .ctor()">
-        <size>27</size>
+        <size>24</size>
       </method>
     </type>
     <type name="M">
         <size>7</size>
       </method>
       <method name="Int32 Main()">
-        <size>90</size>
+        <size>84</size>
       </method>
     </type>
   </test>
       </method>
     </type>
   </test>
+  <test name="test-642.cs">
+    <type name="C">
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+      <method name="Int32 Main()">
+        <size>40</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-643.cs">
+    <type name="PointerArithmeticTest">
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+      <method name="Int32 Main()">
+        <size>105</size>
+      </method>
+      <method name="System.Int32* Conversions(Int64)">
+        <size>3</size>
+      </method>
+      <method name="Int32 CheckAdd(System.Byte*, Int32)">
+        <size>15</size>
+      </method>
+      <method name="Int32 CheckSub(System.Int16*, Int32)">
+        <size>17</size>
+      </method>
+      <method name="Int32 CheckSub2(System.Int16*, Int32)">
+        <size>24</size>
+      </method>
+    </type>
+  </test>
   <test name="test-65.cs">
     <type name="X">
       <method name="Void .ctor()">