OSDN Git Service

/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Jan 2010 23:12:25 +0000 (23:12 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Jan 2010 23:12:25 +0000 (23:12 +0000)
2010-01-20  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/42038
* except.c (expand_start_catch_block): Deal correctly with
do_begin_catch returning error_mark_node.

/testsuite
2010-01-20  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/42038
* g++.dg/parse/crash55.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156094 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/except.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/crash55.C [new file with mode: 0644]

index 4cc1119..5f7190e 100644 (file)
@@ -1,3 +1,9 @@
+2010-01-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/42038
+       * except.c (expand_start_catch_block): Deal correctly with
+       do_begin_catch returning error_mark_node.
+
 2010-01-20  Jason Merrill  <jason@redhat.com>
 
        PR c++/41788
index 83164c8..4f4f85b 100644 (file)
@@ -1,6 +1,6 @@
 /* Handle exceptional things in C++.
    Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Michael Tiemann <tiemann@cygnus.com>
    Rewritten by Mike Stump <mrs@cygnus.com>, based upon an
@@ -417,7 +417,7 @@ tree
 expand_start_catch_block (tree decl)
 {
   tree exp;
-  tree type;
+  tree type, init;
 
   if (! doing_eh (1))
     return NULL_TREE;
@@ -450,10 +450,12 @@ expand_start_catch_block (tree decl)
   /* Call __cxa_end_catch at the end of processing the exception.  */
   push_eh_cleanup (type);
 
+  init = do_begin_catch ();
+
   /* If there's no decl at all, then all we need to do is make sure
      to tell the runtime that we've begun handling the exception.  */
-  if (decl == NULL || decl == error_mark_node)
-    finish_expr_stmt (do_begin_catch ());
+  if (decl == NULL || decl == error_mark_node || init == error_mark_node)
+    finish_expr_stmt (init);
 
   /* If the C++ object needs constructing, we need to do that before
      calling __cxa_begin_catch, so that std::uncaught_exception gets
@@ -463,7 +465,7 @@ expand_start_catch_block (tree decl)
     {
       exp = do_get_exception_ptr ();
       initialize_handler_parm (decl, exp);
-      finish_expr_stmt (do_begin_catch ());
+      finish_expr_stmt (init);
     }
 
   /* Otherwise the type uses a bitwise copy, and we don't have to worry
@@ -471,7 +473,6 @@ expand_start_catch_block (tree decl)
      copy with the return value of __cxa_end_catch instead.  */
   else
     {
-      tree init = do_begin_catch ();
       tree init_type = type;
 
       /* Pointers are passed by values, everything else by reference.  */
index faf0f05..76d2bc5 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/42038
+       * g++.dg/parse/crash55.C: New.
+
 2010-01-20  Alexandre Oliva  <aoliva@redhat.com>
 
        PR debug/42782
diff --git a/gcc/testsuite/g++.dg/parse/crash55.C b/gcc/testsuite/g++.dg/parse/crash55.C
new file mode 100644 (file)
index 0000000..7676d49
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/42038
+
+extern int __cxa_begin_catch;
+
+void f(void)
+{
+  try { } catch (int) { } // { dg-error "cannot be used" }
+}