diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-27 19:19:36 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-27 19:19:36 +0000 |
commit | d0389adcec8df4c33a662efaee000e1183dd996a (patch) | |
tree | 5c9e3a4746746875cf007866de55c9eb44b2aec0 /gcc/c-family | |
parent | ae43b05e18d3e6498309b0a1cce4fbef7ff73098 (diff) | |
download | gcc-d0389adcec8df4c33a662efaee000e1183dd996a.tar.gz |
PR c++/49165
* c-common.c (c_common_truthvalue_conversion) <case COND_EXPR>: For
C++ don't call c_common_truthvalue_conversion on void type arms.
* g++.dg/eh/cond6.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174350 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 15 |
2 files changed, 14 insertions, 7 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 557f89634e9..3bdfbab007c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2011-05-27 Jakub Jelinek <jakub@redhat.com> + + PR c++/49165 + * c-common.c (c_common_truthvalue_conversion) <case COND_EXPR>: For + C++ don't call c_common_truthvalue_conversion on void type arms. + 2011-05-27 Nathan Froyd <froydnj@codesourcery.com> * c-common.h (struct stmt_tree_s) [x_cur_stmt_list]: Change to a VEC. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index fa7ebc5d30d..dbef4b314ea 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -3945,14 +3945,15 @@ c_common_truthvalue_conversion (location_t location, tree expr) /* Distribute the conversion into the arms of a COND_EXPR. */ if (c_dialect_cxx ()) { + tree op1 = TREE_OPERAND (expr, 1); + tree op2 = TREE_OPERAND (expr, 2); + /* In C++ one of the arms might have void type if it is throw. */ + if (!VOID_TYPE_P (TREE_TYPE (op1))) + op1 = c_common_truthvalue_conversion (location, op1); + if (!VOID_TYPE_P (TREE_TYPE (op2))) + op2 = c_common_truthvalue_conversion (location, op2); expr = fold_build3_loc (location, COND_EXPR, truthvalue_type_node, - TREE_OPERAND (expr, 0), - c_common_truthvalue_conversion (location, - TREE_OPERAND (expr, - 1)), - c_common_truthvalue_conversion (location, - TREE_OPERAND (expr, - 2))); + TREE_OPERAND (expr, 0), op1, op2); goto ret; } else |