From 89711f4d03c39db8beadf9bfbadd9aa0056b3815 Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 20 Jan 2010 23:12:25 +0000 Subject: [PATCH] /cp 2010-01-20 Paolo Carlini 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 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 | 6 ++++++ gcc/cp/except.c | 13 +++++++------ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/crash55.C | 8 ++++++++ 4 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/crash55.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4cc1119a211..5f7190ed3c2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-01-20 Paolo Carlini + + PR c++/42038 + * except.c (expand_start_catch_block): Deal correctly with + do_begin_catch returning error_mark_node. + 2010-01-20 Jason Merrill PR c++/41788 diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 83164c86a7e..4f4f85b490d 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -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 Rewritten by Mike Stump , 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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index faf0f055187..76d2bc5c163 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-01-20 Paolo Carlini + + PR c++/42038 + * g++.dg/parse/crash55.C: New. + 2010-01-20 Alexandre Oliva 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 index 00000000000..7676d49bcd9 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash55.C @@ -0,0 +1,8 @@ +// PR c++/42038 + +extern int __cxa_begin_catch; + +void f(void) +{ + try { } catch (int) { } // { dg-error "cannot be used" } +} -- 2.11.0