+
+ struct S {
+ int i, j, k, l, m, n;
+ }
+
+ static IntPtr[] addr;
+
+ static unsafe void throw_func (int i, S s) {
+ addr [i] = new IntPtr (&i);
+ throw new Exception ();
+ }
+
+ /* Test that arguments are correctly popped off the stack during unwinding */
+ public static int test_0_stack_unwind () {
+ addr = new IntPtr [1000];
+ S s = new S ();
+ for (int j = 0; j < 1000; j++) {
+ try {
+ throw_func (j, s);
+ }
+ catch (Exception) {
+ }
+ }
+ return (addr [0].ToInt64 () - addr [100].ToInt64 () < 100) ? 0 : 1;
+ }
+
+ public static int test_0_regress_73242 () {
+ int [] arr = new int [10];
+ for (int i = 0; i < 10; ++i)
+ arr [i] = 0;
+ try {
+ throw new Exception ();
+ }
+ catch {
+ }
+ return 0;
+ }
+
+ public static int test_0_nullref () {
+ try {
+ Array foo = null;
+ foo.Clone();
+ } catch (NullReferenceException e) {
+ return 0;
+ }
+ return 1;
+ }
+
+ public int amethod () {
+ return 1;
+ }
+
+ public static int test_0_nonvirt_nullref_at_clause_start () {
+ Tests t = null;
+ try {
+ t.amethod ();
+ } catch (NullReferenceException) {
+ return 0;
+ }
+
+ return 1;
+ }
+
+ public static int throw_only () {
+ throw new Exception ();
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static int throw_only2 () {
+ return throw_only ();
+ }
+
+ public static int test_0_inline_throw_only () {
+ try {
+ return throw_only2 ();
+ }
+ catch (Exception ex) {
+ return 0;
+ }
+ }
+
+ // bug #78633
+ public static int test_0_throw_to_branch_opt_outer_clause () {
+ int i = 0;
+
+ try {
+ try {
+ string [] files = new string[1];
+
+ string s = files[2];
+ } finally {
+ i ++;
+ }
+ } catch {
+ }
+
+ return (i == 1) ? 0 : 1;
+ }