2 using System
.Reflection
;
3 using System
.Runtime
.CompilerServices
;
6 * Regression tests for the mono JIT.
8 * Each test needs to be of the form:
10 * public static int test_<result>_<name> ();
12 * where <result> is an integer (the value that needs to be returned by
13 * the method to make it pass.
14 * <name> is a user-displayed name used to identify the test.
16 * The tests can be driven in two ways:
17 * *) running the program directly: Main() uses reflection to find and invoke
18 * the test methods (this is useful mostly to check that the tests are correct)
19 * *) with the --regression switch of the jit (this is the preferred way since
20 * all the tests will be run with optimizations on and off)
22 * The reflection logic could be moved to a .dll since we need at least another
23 * regression test file written in IL code to have better control on how
35 public static int Main (string[] args
) {
36 return TestDriver
.RunTests (typeof (Tests
), args
);
40 public static int test_0_catch () {
41 Exception x
= new Exception ();
45 } catch (Exception e
) {
52 public static int test_0_finally_without_exc () {
57 } catch (Exception e
) {
66 public static int test_0_finally () {
70 throw new Exception ();
71 } catch (Exception e
) {
79 public static int test_0_nested_finally () {
94 public static int test_0_byte_cast () {
107 } catch (OverflowException
) {
121 } catch (OverflowException
) {
136 } catch (OverflowException
) {
150 } catch (OverflowException
) {
164 } catch (OverflowException
) {
178 } catch (OverflowException
) {
192 } catch (OverflowException
) {
206 } catch (OverflowException
) {
220 } catch (OverflowException
) {
234 } catch (OverflowException
) {
248 } catch (OverflowException
) {
262 } catch (OverflowException
) {
277 catch (OverflowException
) {
288 public static int test_0_sbyte_cast () {
300 } catch (OverflowException
) {
314 } catch (OverflowException
) {
328 } catch (OverflowException
) {
342 } catch (OverflowException
) {
356 } catch (OverflowException
) {
370 } catch (OverflowException
) {
384 } catch (OverflowException
) {
398 } catch (OverflowException
) {
412 } catch (OverflowException
) {
426 } catch (OverflowException
) {
440 } catch (OverflowException
) {
454 } catch (OverflowException
) {
468 } catch (OverflowException
) {
482 } catch (OverflowException
) {
496 } catch (OverflowException
) {
510 } catch (OverflowException
) {
524 } catch (OverflowException
) {
538 } catch (OverflowException
) {
552 } catch (OverflowException
) {
566 } catch (OverflowException
) {
581 catch (OverflowException
) {
592 public static int test_0_ushort_cast () {
600 a
= System
.UInt16
.MaxValue
;
605 } catch (OverflowException
) {
617 } catch (OverflowException
) {
624 a
= System
.UInt16
.MaxValue
+ 1;
629 } catch (OverflowException
) {
641 } catch (OverflowException
) {
653 } catch (OverflowException
) {
660 double d
= System
.UInt16
.MaxValue
;
665 } catch (OverflowException
) {
677 } catch (OverflowException
) {
684 double d
= System
.UInt16
.MaxValue
+ 1.0;
689 } catch (OverflowException
) {
696 l
= System
.UInt16
.MaxValue
;
701 } catch (OverflowException
) {
713 } catch (OverflowException
) {
720 l
= System
.UInt16
.MaxValue
+ 1;
725 } catch (OverflowException
) {
737 } catch (OverflowException
) {
749 } catch (OverflowException
) {
758 public static int test_0_short_cast () {
765 a
= System
.UInt16
.MaxValue
;
770 } catch (OverflowException
) {
782 } catch (OverflowException
) {
789 a
= System
.Int16
.MaxValue
+ 1;
794 } catch (OverflowException
) {
801 a
= System
.Int16
.MinValue
- 1;
806 } catch (OverflowException
) {
818 } catch (OverflowException
) {
825 a
= System
.Int16
.MinValue
;
830 } catch (OverflowException
) {
837 a
= System
.Int16
.MaxValue
;
842 } catch (OverflowException
) {
849 a
= System
.Int16
.MaxValue
+ 1;
854 } catch (OverflowException
) {
861 double d
= System
.Int16
.MaxValue
;
866 } catch (OverflowException
) {
873 double d
= System
.Int16
.MinValue
;
878 } catch (OverflowException
) {
885 double d
= System
.Int16
.MaxValue
+ 1.0;
890 } catch (OverflowException
) {
897 double d
= System
.Int16
.MinValue
- 1.0;
902 } catch (OverflowException
) {
909 l
= System
.Int16
.MaxValue
+ 1;
914 } catch (OverflowException
) {
921 l
= System
.Int16
.MaxValue
;
926 } catch (OverflowException
) {
933 l
= System
.Int16
.MinValue
- 1;
938 } catch (OverflowException
) {
946 l
= System
.Int16
.MinValue
;
951 } catch (OverflowException
) {
958 l
= 0x00000000ffffffff;
963 } catch (OverflowException
) {
975 } catch (OverflowException
) {
984 public static int test_0_int_cast () {
990 double d
= System
.Int32
.MaxValue
+ 1.0;
995 } catch (OverflowException
) {
1002 double d
= System
.Int32
.MaxValue
;
1007 } catch (OverflowException
) {
1015 double d
= System
.Int32
.MinValue
;
1020 } catch (OverflowException
) {
1028 double d
= System
.Int32
.MinValue
- 1.0;
1033 } catch (OverflowException
) {
1040 l
= System
.Int32
.MaxValue
+ (long)1;
1045 } catch (OverflowException
) {
1052 l
= System
.Int32
.MaxValue
;
1057 } catch (OverflowException
) {
1065 l
= System
.Int32
.MinValue
;
1070 } catch (OverflowException
) {
1078 l
= System
.Int32
.MinValue
- (long)1;
1083 } catch (OverflowException
) {
1090 uint ui
= System
.UInt32
.MaxValue
;
1096 catch (OverflowException
) {
1103 ulong ul
= (long)(System
.Int32
.MaxValue
) + 1;
1109 catch (OverflowException
) {
1116 ulong ul
= UInt64
.MaxValue
;
1122 catch (OverflowException
) {
1139 public static int test_0_uint_cast () {
1145 double d
= System
.UInt32
.MaxValue
;
1150 } catch (OverflowException
) {
1157 double d
= System
.UInt32
.MaxValue
+ 1.0;
1162 } catch (OverflowException
) {
1169 double d
= System
.UInt32
.MinValue
;
1174 } catch (OverflowException
) {
1181 double d
= System
.UInt32
.MinValue
- 1.0;
1186 } catch (OverflowException
) {
1193 l
= System
.UInt32
.MaxValue
;
1198 } catch (OverflowException
) {
1205 l
= System
.UInt32
.MaxValue
+ (long)1;
1210 } catch (OverflowException
) {
1217 l
= System
.UInt32
.MinValue
;
1222 } catch (OverflowException
) {
1229 l
= System
.UInt32
.MinValue
- (long)1;
1234 } catch (OverflowException
) {
1247 catch (OverflowException
) {
1264 public static int test_0_long_cast () {
1267 * These tests depend on properties of x86 fp arithmetic so they won't work
1268 * on other platforms.
1275 double d = System.Int64.MaxValue - 512.0;
1280 } catch (OverflowException) {
1287 double d = System.Int64.MaxValue - 513.0;
1292 } catch (OverflowException) {
1299 double d = System.Int64.MinValue - 1024.0;
1304 } catch (OverflowException) {
1311 double d = System.Int64.MinValue - 1025.0;
1316 } catch (OverflowException) {
1334 /* Github issue 13284 */
1335 public static int test_0_ulong_ovf_spilling () {
1346 // Console.WriteLine ($"u64 ({x} - {y} >= {z}) => {a} [{(a == false ? "OK" : "NG")}]");
1347 } catch (OverflowException
) {
1349 // Console.WriteLine ($"u64 ({x} - {y} >= {z}) => overflow [NG]");
1356 // Console.WriteLine ($"u64 ({t} >= {z}) => {a} [{(a == false ? "OK" : "NG")}]");
1357 } catch (OverflowException
) {
1359 // Console.WriteLine ($"u64 ({t} >= {z}) => overflow [NG]");
1363 var a
= x
- y
- z
>= 0;
1368 // Console.WriteLine ($"u64 ({x} - {y} - {z} >= 0) => {a} [NG]");
1369 } catch (OverflowException
) {
1371 // Console.WriteLine ($"u64 ({x} - {y} - {z} >= 0) => overflow [OK]");
1376 public static int test_0_ulong_cast () {
1381 * These tests depend on properties of x86 fp arithmetic so they won't work
1382 * on other platforms.
1387 double d = System.UInt64.MaxValue - 1024.0;
1392 } catch (OverflowException) {
1399 double d = System.UInt64.MaxValue - 1025.0;
1404 } catch (OverflowException) {
1417 } catch (OverflowException
) {
1429 } catch (OverflowException
) {
1450 catch (OverflowException
) {
1457 int i
= Int32
.MinValue
;
1463 catch (OverflowException
) {
1472 [Category ("!WASM")] // reported as https://github.com/kripken/emscripten/issues/5603
1473 public static int test_0_simple_double_casts () {
1475 double d
= 0xffffffff;
1477 if ((uint)d
!= 4294967295)
1481 * These tests depend on properties of x86 fp arithmetic so they won't work
1482 * on other platforms.
1485 d = 0xffffffffffffffff;
1499 if ((ushort)d
!= 0xffff)
1502 if ((byte)d
!= 0xff)
1508 public static int test_0_div_zero () {
1517 } catch (DivideByZeroException
) {
1526 } catch (DivideByZeroException
) {
1537 } catch (DivideByZeroException
) {
1538 /* wrong exception */
1539 } catch (OverflowException
) {
1550 } catch (DivideByZeroException
) {
1551 /* wrong exception */
1552 } catch (OverflowException
) {
1561 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1562 static void dummy () {
1565 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1566 static int div_zero_llvm_inner (int i
) {
1568 // This call make use avoid the 'handler without invoke' restriction in the llvm backend
1571 } catch (Exception ex
) {
1576 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1577 static long div_zero_llvm_inner_long (long l
) {
1581 } catch (Exception ex
) {
1586 public static int test_0_div_zero_llvm () {
1587 long r
= div_zero_llvm_inner (0);
1590 r
= div_zero_llvm_inner_long (0);
1596 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1597 static int div_overflow_llvm_inner (int i
) {
1600 return Int32
.MinValue
/ i
;
1601 } catch (Exception ex
) {
1606 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
1607 static long div_overflow_llvm_inner_long (long l
) {
1610 return Int64
.MinValue
/ l
;
1611 } catch (Exception ex
) {
1616 public static int test_0_div_overflow_llvm () {
1617 long r
= div_overflow_llvm_inner (-1);
1620 r
= div_overflow_llvm_inner_long ((long)-1);
1626 public static int return_55 () {
1630 public static int test_0_cfold_div_zero () {
1631 // Test that constant folding doesn't cause division by zero exceptions
1632 if (return_55 () != return_55 ()) {
1651 public static int test_0_udiv_zero () {
1660 } catch (DivideByZeroException
) {
1669 } catch (DivideByZeroException
) {
1678 public static int test_0_long_div_zero () {
1687 } catch (DivideByZeroException
) {
1696 } catch (DivideByZeroException
) {
1707 } catch (DivideByZeroException
) {
1708 /* wrong exception */
1709 } catch (OverflowException
) {
1720 } catch (DivideByZeroException
) {
1721 /* wrong exception */
1722 } catch (OverflowException
) {
1731 public static int test_0_ulong_div_zero () {
1740 } catch (DivideByZeroException
) {
1749 } catch (DivideByZeroException
) {
1758 public static int test_0_float_div_zero () {
1767 } catch (DivideByZeroException
) {
1776 } catch (DivideByZeroException
) {
1785 public static int test_0_invalid_unbox () {
1788 object o
= "Some string";
1792 // Illegal conversion; o contains a string not an int
1794 } catch (Exception e
) {
1802 // Test that double[] can't be cast to double (bug #46027)
1803 public static int test_0_invalid_unbox_arrays () {
1804 double[] d1
= { 1.0 }
;
1805 double[][] d2
= { d1 }
;
1809 foreach (double d
in a
) {
1813 catch (InvalidCastException e
) {
1818 /* bug# 42190, at least mcs generates a leave for the return that
1819 * jumps out of multiple exception clauses: we used to execute just
1820 * one enclosing finally block.
1822 public static int finally_level
;
1823 static void do_something () {
1836 public static int test_2_multiple_finally_clauses () {
1839 if (finally_level
== 1)
1844 public static int test_3_checked_cast_un () {
1845 ulong i
= 0x8000000034000000;
1849 checked { j = (long)i; }
1850 } catch (OverflowException
) {
1859 public static int test_4_checked_cast () {
1863 unchecked { i = (long)0x8000000034000000;}
;
1865 checked { j = (ulong)i; }
1866 } catch (OverflowException
) {
1875 static readonly int[] mul_dim_results
= new int[] {
1876 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8,
1877 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8,
1881 5, 0, 5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 6, 5, 7, 5, 8,
1882 6, 0, 6, 1, 6, 2, 6, 3, 6, 4, 6, 5, 6, 6, 6, 7, 6, 8,
1883 7, 0, 7, 1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7, 7, 7, 8,
1886 public static int test_0_multi_dim_array_access () {
1887 int [,] a
= System
.Array
.CreateInstance (typeof (int),
1888 new int [] {3,6}
, new int [] {2,2 }
) as int[,];
1891 for (x
= 0; x
< 8; ++x
) {
1892 for (y
= 0; y
< 9; ++y
) {
1893 bool got_ex
= false;
1900 if (result_idx
>= mul_dim_results
.Length
)
1902 if (mul_dim_results
[result_idx
] != x
|| mul_dim_results
[result_idx
+ 1] != y
) {
1903 return result_idx
+ 1;
1909 if (result_idx
== mul_dim_results
.Length
)
1914 static void helper_out_obj (out object o
) {
1915 o
= (object)"buddy";
1918 static void helper_out_string (out string o
) {
1922 public static int test_2_array_mismatch () {
1923 string[] a
= { "hello", "world" }
;
1925 bool passed
= false;
1928 helper_out_obj (out b
[1]);
1929 } catch (ArrayTypeMismatchException
) {
1934 helper_out_string (out a
[1]);
1935 if (a
[1] != "buddy")
1940 public static int test_0_ovf1 () {
1945 ulong a
= UInt64
.MaxValue
- 1;
1954 public static int test_1_ovf2 () {
1959 ulong a
= UInt64
.MaxValue
;
1968 public static int test_0_ovf3 () {
1971 long a
= Int64
.MaxValue
- 1;
1982 public static int test_1_ovf4 () {
1985 long a
= Int64
.MaxValue
;
1996 public static int test_0_ovf5 () {
1999 ulong a
= UInt64
.MaxValue
- 1;
2010 public static int test_1_ovf6 () {
2013 ulong a
= UInt64
.MaxValue
;
2024 public static int test_0_ovf7 () {
2027 long a
= Int64
.MinValue
+ 1;
2038 public static int test_1_ovf8 () {
2041 long a
= Int64
.MinValue
;
2052 public static int test_0_ovf9 () {
2055 ulong a
= UInt64
.MinValue
+ 1;
2066 public static int test_1_ovf10 () {
2069 ulong a
= UInt64
.MinValue
;
2080 public static int test_0_ovf11 () {
2083 int a
= Int32
.MinValue
+ 1;
2094 public static int test_1_ovf12 () {
2097 int a
= Int32
.MinValue
;
2108 public static int test_0_ovf13 () {
2122 public static int test_1_ovf14 () {
2136 public static int test_0_ovf15 () {
2150 public static int test_1_ovf16 () {
2164 public static int test_0_ovf17 () {
2176 public static int test_0_ovf18 () {
2190 public static int test_1_ovf19 () {
2204 public static int test_0_ovf20 () {
2209 ulong a
= 0xffffffffff;
2210 ulong t
= a
*0x0ffffff;
2218 public static int test_1_ovf21 () {
2221 ulong a
= 0xffffffffff;
2224 ulong t
= a
*0x0fffffff;
2232 public static int test_1_ovf22 () {
2235 long a
= Int64
.MinValue
;
2247 public static int test_1_ovf23 () {
2251 long b
= Int64
.MinValue
;
2263 public static int i
;
2266 throw new Exception ("Ugh!");
2269 public static int DoSomething () {
2274 public static int test_0_exception_in_cctor () {
2276 Broken
.DoSomething ();
2278 catch (TypeInitializationException
) {
2279 // This will only happen once even if --regression is used
2284 public static int test_5_regalloc () {
2288 for (i
= 0; i
< 10; ++i
) {
2290 throw new Exception ();
2298 // Check that variables written in catch clauses are volatile
2301 throw new Exception ();
2312 throw new Exception ();
2326 public static void rethrow () {
2328 throw new ApplicationException();
2329 } catch (ApplicationException
) {
2331 throw new OverflowException();
2332 } catch (Exception
) {
2338 // Test that a rethrow rethrows the correct exception
2339 public static int test_0_rethrow_nested () {
2342 } catch (OverflowException
) {
2344 } catch (Exception
) {
2350 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
2351 public static void rethrow1 () {
2352 throw new Exception ();
2355 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
2356 public static void rethrow2 () {
2358 /* This disables tailcall opts */
2359 Console
.WriteLine ();
2362 [Category ("!BITCODE")]
2363 public static int test_0_rethrow_stacktrace () {
2364 // Check that rethrowing an exception preserves the original stack trace
2369 catch (Exception ex
) {
2370 // Check that each catch clause has its own exception variable
2371 // If not, the throw below will overwrite the exception used
2374 throw new DivideByZeroException ();
2376 catch (Exception foo
) {
2382 catch (Exception ex
) {
2383 if (ex
.StackTrace
.IndexOf ("rethrow2") != -1)
2391 class Face
: IFace
{}
2393 public static int test_1_array_mismatch_2 () {
2395 object [] o
= new Face
[1];
2398 } catch (ArrayTypeMismatchException
) {
2403 public static int test_1_array_mismatch_3 () {
2405 object [] o
= new IFace
[1];
2408 } catch (ArrayTypeMismatchException
) {
2413 public static int test_1_array_mismatch_4 () {
2415 object [][] o
= new Face
[5] [];
2416 o
[0] = new object [5];
2419 } catch (ArrayTypeMismatchException
) {
2424 public static int test_0_array_size () {
2429 int[,] mem2
= new int [Int32
.MaxValue
, Int32
.MaxValue
];
2431 catch (OutOfMemoryException e
) {
2441 int i
, j
, k
, l
, m
, n
;
2444 static IntPtr
[] addr
;
2446 static unsafe void throw_func (int i
, S s
) {
2447 addr
[i
] = new IntPtr (&i
);
2448 throw new Exception ();
2451 /* Test that arguments are correctly popped off the stack during unwinding */
2452 /* FIXME: Fails on x86 when llvm is enabled (#5432) */
2454 public static int test_0_stack_unwind () {
2455 addr = new IntPtr [1000];
2457 for (int j = 0; j < 1000; j++) {
2464 return (addr [0].ToInt64 () - addr [100].ToInt64 () < 100) ? 0 : 1;
2468 static unsafe void get_sp (int i
) {
2469 addr
[i
] = new IntPtr (&i
);
2472 /* Test that the arguments to the throw trampoline are correctly popped off the stack */
2473 public static int test_0_throw_unwind () {
2474 addr
= new IntPtr
[1000];
2476 for (int j
= 0; j
< 1000; j
++) {
2479 throw new Exception ();
2484 return (addr
[0].ToInt64 () - addr
[100].ToInt64 () < 100) ? 0 : 1;
2487 public static int test_0_regress_73242 () {
2488 int [] arr
= new int [10];
2489 for (int i
= 0; i
< 10; ++i
)
2492 throw new Exception ();
2499 public static int test_0_nullref () {
2503 } catch (NullReferenceException e
) {
2509 public int amethod () {
2513 public static int test_0_nonvirt_nullref_at_clause_start () {
2514 ExceptionTests t
= null;
2517 } catch (NullReferenceException
) {
2524 public static int throw_only () {
2525 throw new Exception ();
2528 [MethodImpl(MethodImplOptions
.NoInlining
)]
2529 public static int throw_only2 () {
2530 return throw_only ();
2533 public static int test_0_inline_throw_only () {
2535 return throw_only2 ();
2537 catch (Exception ex
) {
2542 public static string GetText (string s
) {
2546 public static int throw_only_gettext () {
2547 throw new Exception (GetText ("FOO"));
2550 public static int test_0_inline_throw_only_gettext () {
2553 o
= throw_only_gettext ();
2555 catch (Exception ex
) {
2559 return o
!= null ? 0 : 1;
2563 public static int test_0_throw_to_branch_opt_outer_clause () {
2568 string [] files
= new string[1];
2570 string s
= files
[2];
2577 return (i
== 1) ? 0 : 1;
2581 public static int test_0_try_inside_finally_cmov_opt () {
2582 bool Reconect
= false;
2584 object o
= new object ();
2588 catch (Exception ExCon
) {
2594 catch (Exception Last
) {
2598 if (Reconect
== true) {
2601 catch (Exception ex
) {
2609 public static int test_0_inline_throw () {
2618 // for llvm, the end bblock is unreachable
2619 public static int inline_throw1 (int i
) {
2621 throw new Exception ();
2623 return inline_throw2 (i
);
2626 public static int inline_throw2 (int i
) {
2627 throw new Exception ();
2631 public static int test_0_lmf_filter () {
2633 // The invoke calls a runtime-invoke wrapper which has a filter clause
2635 typeof (ExceptionTests
).GetMethod ("lmf_filter").Invoke (null, new object [] { }
);
2637 typeof (Tests
).GetMethod ("lmf_filter").Invoke (null, new object [] { }
);
2639 } catch (TargetInvocationException
) {
2644 public static void lmf_filter () {
2649 throw new NotImplementedException ();
2653 public static void Connect () {
2655 throw new Exception();
2658 public static void Stop () {
2666 private static void do_raise () {
2667 throw new System
.Exception ();
2670 private static int int_func (int i
) {
2675 public static int test_8_local_deadce_causes () {
2682 } catch (System
.Exception
) {
2688 public static int test_0_except_opt_two_clauses () {
2691 uint ui
= (uint)size
;
2694 uint v
= ui
* (uint)4;
2696 } catch (OverflowException e
) {
2698 } catch (Exception
) {
2707 public virtual long Method()
2709 throw new Exception();
2714 public static int test_100_long_vars_in_clauses_initlocals_opt () {
2715 Child c
= new Child();
2725 public object AnObj
;
2728 public static void DoSomething (ref object o
) {
2731 public static int test_0_ldflda_null () {
2735 DoSomething (ref a
.AnObj
);
2736 } catch (NullReferenceException
) {
2747 public static Foo
* pFoo
;
2750 /* MS.NET doesn't seem to throw in this case */
2751 public unsafe static int test_0_ldflda_null_pointer () {
2752 int* pi
= &Foo
.pFoo
->i
;
2757 static int test_0_try_clause_in_finally_clause_regalloc () {
2758 // Fill up registers with values
2759 object a
= new object ();
2760 object[] arr1
= new object [1];
2761 object[] arr2
= new object [1];
2762 object[] arr3
= new object [1];
2763 object[] arr4
= new object [1];
2764 object[] arr5
= new object [1];
2766 for (int i
= 0; i
< 10; ++i
)
2768 for (int i
= 0; i
< 10; ++i
)
2770 for (int i
= 0; i
< 10; ++i
)
2772 for (int i
= 0; i
< 10; ++i
)
2774 for (int i
= 0; i
< 10; ++i
)
2779 try_clause_in_finally_clause_regalloc_inner (out res
);
2780 } catch (Exception
) {
2785 public static object Throw () {
2786 for (int i
= 0; i
< 10; ++i
)
2788 throw new Exception ();
2791 static void try_clause_in_finally_clause_regalloc_inner (out int res
) {
2797 } catch (Exception
) {
2798 /* Make sure this doesn't branch to the finally */
2799 throw new DivideByZeroException ();
2802 /* Make sure o is register allocated */
2815 } catch (DivideByZeroException
) {
2820 public static bool t_1835_inner () {
2822 if (a
) throw new Exception();
2826 [MethodImpl(MethodImplOptions
.NoInlining
)]
2827 public static bool t_1835_inner_2 () {
2828 bool b
= t_1835_inner ();
2832 public static int test_0_inline_retval_throw_in_branch_1835 () {
2841 static bool finally_called
= false;
2843 static void regress_30472 (int a
, int b
) {
2848 finally_called
= true;
2853 public static int test_0_regress_30472 () {
2854 finally_called
= false;
2856 regress_30472 (Int32
.MaxValue
- 1, 2);
2857 } catch (Exception ex
) {
2859 return finally_called
? 0 : 1;
2862 static int array_len_1
= 1;
2864 public static int test_0_bounds_check_negative_constant () {
2866 byte[] arr
= new byte [array_len_1
];
2872 byte[] arr
= new byte [array_len_1
];
2880 public static int test_0_string_bounds_check_negative_constant () {
2890 public class MyException
: Exception
{
2891 public int marker
= 0;
2892 public string res
= "";
2894 public MyException (String res
) {
2898 public bool FilterWithoutState () {
2899 return this.marker
== 0x666;
2902 public bool FilterWithState () {
2903 bool ret
= this.marker
== 0x566;
2904 this.marker
+= 0x100;
2908 public bool FilterWithStringState () {
2909 bool ret
= this.marker
== 0x777;
2910 this.res
= "fromFilter_" + this.res
;
2915 [Category ("!BITCODE")]
2916 public static int test_1_basic_filter_catch () {
2918 MyException e
= new MyException ("");
2921 } catch (MyException ex
) when (ex
.marker
== 0x1337) {
2927 [Category ("!BITCODE")]
2928 public static int test_1234_complicated_filter_catch () {
2929 string res
= "init";
2931 MyException e
= new MyException (res
);
2936 } catch (MyException ex
) when (ex
.FilterWithoutState ()) {
2937 res
= "WRONG_" + res
;
2940 res
= "innerFinally_" + res
;
2942 } catch (MyException ex
) when (ex
.FilterWithState ()) {
2943 res
= "2ndcatch_" + res
;
2945 // "2ndcatch_innerFinally_init"
2946 // Console.WriteLine ("res1: " + res);
2949 } catch (MyException ex
) when (ex
.FilterWithStringState ()) {
2950 res
= "fwos_" + ex
.res
;
2952 res
= "outerFinally_" + res
;
2954 // Console.WriteLine ("res2: " + res);
2955 return "outerFinally_fwos_fromFilter_2ndcatch_innerFinally_init" == res
? 1234 : 0;
2958 public struct FooStruct
2960 public long Part1 { get; }
2961 public long Part2 { get; }
2963 public byte Part3 { get; }
2966 [MethodImpl( MethodImplOptions
.NoInlining
)]
2967 private static bool ExceptionFilter( byte x
, FooStruct item
) => true;
2969 [Category ("!BITCODE")]
2970 public static int test_0_filter_caller_area () {
2972 throw new Exception();
2974 catch (Exception
) when (ExceptionFilter (default(byte), default (FooStruct
))) {
2979 public static int test_0_signed_ct_div () {
2981 bool divide_by_zero
= false;
2982 bool overflow
= false;
2988 } catch (OverflowException
) {
2996 } catch (DivideByZeroException
) {
2997 divide_by_zero
= true;
2999 if (!divide_by_zero
)
3002 if ((n
/ 35) != -61356675)
3004 if ((n
/ -35) != 61356675)
3006 n
= -(n
+ 1); /* MaxValue */
3007 if ((n
/ 35) != 61356675)
3009 if ((n
/ -35) != -61356675)
3015 public static int test_0_unsigned_ct_div () {
3016 uint n
= 4294967295;
3017 bool divide_by_zero
= false;
3021 } catch (DivideByZeroException
) {
3022 divide_by_zero
= true;
3025 if (!divide_by_zero
)
3028 if ((n
/ 35) != 122713351)
3036 class ExceptionTests
: Tests