re PR c++/15745 (exception specification incorrectly changes the type of the exceptio...
authorJason Merrill <jason@redhat.com>
Thu, 6 Sep 2007 03:33:46 +0000 (23:33 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 6 Sep 2007 03:33:46 +0000 (23:33 -0400)
        PR c++/15745
        * except.c (prepare_eh_type): Use type_decays_to.

From-SVN: r128174

gcc/cp/ChangeLog
gcc/cp/except.c
gcc/testsuite/g++.dg/eh/spec9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/vla4.C

index a32ecdb..6bcc3ef 100644 (file)
@@ -1,5 +1,8 @@
 2007-09-05  Jason Merrill  <jason@redhat.com>
 
+       PR c++/15745
+       * except.c (prepare_eh_type): Use type_decays_to.
+
        PR c++/15097
        * init.c (build_delete): Use build_headof to get the address of the
        complete object if we aren't using the deleting destructor.
index 199d185..38111b1 100644 (file)
@@ -115,6 +115,9 @@ prepare_eh_type (tree type)
   /* Peel off cv qualifiers.  */
   type = TYPE_MAIN_VARIANT (type);
 
+  /* Functions and arrays decay to pointers.  */
+  type = type_decays_to (type);
+
   return type;
 }
 
diff --git a/gcc/testsuite/g++.dg/eh/spec9.C b/gcc/testsuite/g++.dg/eh/spec9.C
new file mode 100644 (file)
index 0000000..9e00d1c
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/15745
+// { dg-do run }
+
+typedef int IntArray[10];
+IntArray i;
+
+void test_array() throw (IntArray)
+{
+  throw i;
+}
+
+int main ()
+{
+  try
+    {
+      test_array();
+    }
+  catch (IntArray) {}
+}
index 8b7f38f..ecec908 100644 (file)
@@ -7,7 +7,7 @@ void f(int i) {
   try {
     int a[i];
     throw &a; // { dg-error "variable size" }
-  } catch (int (&)[i]) { // { dg-error "variable size" }
+  } catch (int (*)[i]) { // { dg-error "variable size" }
   }
 }