2008-06-23 Mark Probst <mark.probst@gmail.com>
authorMark Probst <mark.probst@gmail.com>
Mon, 23 Jun 2008 18:11:52 +0000 (18:11 -0000)
committerMark Probst <mark.probst@gmail.com>
Mon, 23 Jun 2008 18:11:52 +0000 (18:11 -0000)
* mini.c: Fail sharing of a generic method if it contains an open
catch clause (because we don't pass MRGCTXs yet).

2008-06-23  Mark Probst  <mark.probst@gmail.com>

* generic-exceptions.2.cs: Test case for exception handlers in
generic methods with catch clauses depending on the method type
arguments.

* Makefile.am: Test added.

svn path=/trunk/mono/; revision=106446

mono/mini/ChangeLog
mono/mini/mini.c
mono/tests/ChangeLog
mono/tests/Makefile.am
mono/tests/generic-exceptions.2.cs [new file with mode: 0644]

index d897e72f9ec2d4e7d3f14fd9a3325466337c5ec0..05adf0de2d7da14b2bdc62a2b1dc7d170a5244f4 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-23  Mark Probst  <mark.probst@gmail.com>
+
+       * mini.c: Fail sharing of a generic method if it contains an open
+       catch clause (because we don't pass MRGCTXs yet).
+
 2008-06-23  Mark Probst  <mark.probst@gmail.com>
 
        * mini.c: When compiling a method with generic sharing, insert the
index 488ac456f9d77d5ae3be1e943d0028c97cde7ff3..f0b012ed09096f474bec5eddfd109a4c948ec4b3 100644 (file)
@@ -5025,6 +5025,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        clause->data.catch_class &&
                                        cfg->generic_sharing_context &&
                                        mono_class_check_context_used (clause->data.catch_class)) {
+                               if (mono_method_get_context (method)->method_inst)
+                                       GENERIC_SHARING_FAILURE (CEE_NOP);
+
                                /*
                                 * In shared generic code with catch
                                 * clauses containing type variables
index eb56112bee32278c8f48436e3853fec9729156bd..284944621ae442a85903daa008f2f9fcf31c5584 100644 (file)
@@ -1,3 +1,11 @@
+2008-06-23  Mark Probst  <mark.probst@gmail.com>
+
+       * generic-exceptions.2.cs: Test case for exception handlers in
+       generic methods with catch clauses depending on the method type
+       arguments.
+
+       * Makefile.am: Test added.
+
 2008-06-20  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * bug-349190.2.cs: Regression test for bug #349190.
index adedad90f6a992fbecf6f143e38115f6fb651a2a..5e65d6c339273cb9db9cd5a1c947900866c3209e 100644 (file)
@@ -274,6 +274,7 @@ BASE_TEST_CS_SRC=           \
        generic-static-methods.2.cs     \
        generic-null-call.2.cs  \
        generic-special.2.cs    \
+       generic-exceptions.2.cs \
        recursive-generics.2.cs \
        bug-80392.2.cs          \
        dynamic-method-access.2.cs      \
@@ -707,7 +708,8 @@ test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe  \
                generic-interface-methods.2.exe generic-array-type.2.exe        \
                generic-method-patching.2.exe generic-static-methods.2.exe      \
                generic-null-call.2.exe generic-tailcall2.2.exe                 \
-               generic-array-exc.2.exe generic-special.2.exe
+               generic-array-exc.2.exe generic-special.2.exe                   \
+               generic-exceptions.2.exe
        for fn in $+ ; do       \
                echo "Testing $$fn ...";        \
                MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared                $$fn || exit 1;   \
diff --git a/mono/tests/generic-exceptions.2.cs b/mono/tests/generic-exceptions.2.cs
new file mode 100644 (file)
index 0000000..ef0777a
--- /dev/null
@@ -0,0 +1,76 @@
+using System;
+
+public class GenExc<S,T> : Exception {
+}
+
+public delegate void ThrowDelegate ();
+
+public class Gen<T> {
+       public void catcher<S> (ThrowDelegate thrower) {
+               try {
+                       thrower ();
+               }
+               catch (GenExc<S,T>) {
+               }
+       }
+
+       public static void staticCatcher<S> (ThrowDelegate thrower) {
+               try {
+                       thrower ();
+               }
+               catch (GenExc<S,T>) {
+               }
+       }
+}
+
+public class main {
+       static void throwObjectObject () {
+               throw new GenExc<object, object> ();
+       }
+
+       static void throwStringObject () {
+               throw new GenExc<string, object> ();
+       }
+
+       static int Main () {
+               Gen<object> go = new Gen<object> ();
+
+               try {
+                       go.catcher<object> (new ThrowDelegate (main.throwObjectObject));
+                       Gen<object>.staticCatcher<object> (new ThrowDelegate (main.throwObjectObject));
+                       go.catcher<string> (new ThrowDelegate (main.throwStringObject));
+                       Gen<object>.staticCatcher<string> (new ThrowDelegate (main.throwStringObject));
+               }
+               catch {
+                       return 1;
+               }
+
+               try {
+                       go.catcher<object> (new ThrowDelegate (main.throwStringObject));
+                       return 1;
+               }
+               catch {
+               }
+               try {
+                       Gen<object>.staticCatcher<object> (new ThrowDelegate (main.throwStringObject));
+                       return 1;
+               }
+               catch {
+               }
+
+               try {
+                       go.catcher<string> (new ThrowDelegate (main.throwObjectObject));
+                       return 1;
+               }
+               catch {
+               }
+               try {
+                       Gen<object>.staticCatcher<string> (new ThrowDelegate (main.throwObjectObject));
+                       return 1;
+               }
+               catch {
+               }
+
+               return 0;
+       }
+}