re PR c++/28250 (ICE with invalid catch)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Fri, 21 Jul 2006 09:59:57 +0000 (09:59 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Fri, 21 Jul 2006 09:59:57 +0000 (09:59 +0000)
PR c++/28250
* pt.c (tsubst_expr): Only apply DECL_TEMPLATE_INSTANTIATED to
valid decls.  Cleanup.

* g++.dg/eh/catch3.C: New test.

From-SVN: r115643

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/eh/catch3.C [new file with mode: 0644]

index 722334c17777c8dab284fc214d1cb9a5af5ae2a6..0017e1d8b405a8e9af7260f7ea4d1cb9e401cf64 100644 (file)
@@ -1,5 +1,9 @@
 2006-07-21  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c++/28250
+       * pt.c (tsubst_expr): Only apply DECL_TEMPLATE_INSTANTIATED to
+       valid decls.  Cleanup.
+
        PR c++/28363
        * semantics.c (check_template_template_default_arg): Simplify
        error handling.
index f65d0ce25a6755923f6fd188fc4ace8c87d97818..76deddd04aed97cdf041013757d4a1ac917dcc77 100644 (file)
@@ -8491,20 +8491,18 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 
     case HANDLER:
       {
-       tree decl;
+       tree decl = HANDLER_PARMS (t);
 
-       stmt = begin_handler ();
-       if (HANDLER_PARMS (t))
+       if (decl)
          {
-           decl = HANDLER_PARMS (t);
            decl = tsubst (decl, args, complain, in_decl);
            /* Prevent instantiate_decl from trying to instantiate
               this variable.  We've already done all that needs to be
               done.  */
-           DECL_TEMPLATE_INSTANTIATED (decl) = 1;
+           if (decl != error_mark_node)
+             DECL_TEMPLATE_INSTANTIATED (decl) = 1;
          }
-       else
-         decl = NULL_TREE;
+       stmt = begin_handler ();
        finish_handler_parms (decl, stmt);
        tsubst_expr (HANDLER_BODY (t), args, complain, in_decl);
        finish_handler (stmt);
index d56ce67b23346605949a150011b2ad3179498360..ad43ecab79fc32dd2784584e7bdef1d8365295e8 100644 (file)
@@ -1,5 +1,8 @@
 2006-07-21  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c++/28250
+       * g++.dg/eh/catch3.C: New test.
+
        PR c++/28363
        * g++.dg/template/defarg10.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/eh/catch3.C b/gcc/testsuite/g++.dg/eh/catch3.C
new file mode 100644 (file)
index 0000000..8848292
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/28250
+// { dg-do compile }
+
+template<int> void foo()
+{
+  try {}
+  catch () {}  // { dg-error "type-specifier" }
+}
+
+template void foo<0>();