From: Andrew Lewycky Date: Wed, 12 Mar 2003 22:59:37 +0000 (+0000) Subject: re PR c++/7050 (g++ segfaults on: (i ? get_string() : throw)) X-Git-Tag: releases/gcc-3.2.3~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=731361b379e4397f3baabcc9d87562f357451415;p=thirdparty%2Fgcc.git re PR c++/7050 (g++ segfaults on: (i ? get_string() : throw)) PR c++/7050 * expr.c (store_expr): Don't attempt to store void-typed trees, just evaluate them for side effects. * cp/expr.c (cxx_expand_expr): Return const0_rtx for throw expressions. From-SVN: r64270 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e663fe339871..89c682171ec6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2003-03-12 Andrew Lewycky + + PR c++/7050 + * expr.c (store_expr): Don't attempt to store void-typed trees, + just evaluate them for side effects. + 2003-03-12 Bob Wilson Backport from mainline: diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ea552bbe7cbd..27697e271561 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-03-12 Andrew Lewycky + + PR c++/7050 + * expr.c (cxx_expand_expr): Return const0_rtx for throw + expressions. + 2003-03-10 Jason Merrill PR c++/9798 diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c index 34f779ebb97f..bc38fd22a823 100644 --- a/gcc/cp/expr.c +++ b/gcc/cp/expr.c @@ -111,7 +111,7 @@ cplus_expand_expr (exp, target, tmode, modifier) case THROW_EXPR: expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0); - return NULL; + return const0_rtx; case MUST_NOT_THROW_EXPR: expand_eh_region_start (); diff --git a/gcc/expr.c b/gcc/expr.c index 2a13cd4825f6..ba261d56912a 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -3917,6 +3917,16 @@ store_expr (exp, target, want_value) int dont_return_target = 0; int dont_store_target = 0; + if (VOID_TYPE_P (TREE_TYPE (exp))) + { + /* C++ can generate ?: expressions with a throw expression in one + branch and an rvalue in the other. Here, we resolve attempts to + store the throw expression's nonexistant result. */ + if (want_value) + abort (); + expand_expr (exp, const0_rtx, VOIDmode, 0); + return NULL_RTX; + } if (TREE_CODE (exp) == COMPOUND_EXPR) { /* Perform first part of compound expression, then assign from second