summaryrefslogtreecommitdiff
path: root/gcc/convert.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-30 22:04:36 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-30 22:04:36 +0000
commit57d0100fbd6823e5c9715d3f46030484a7667371 (patch)
tree22d4472aed1465f326e3cc594adf1560e23c69d9 /gcc/convert.c
parentc899341f16da17859b9a36a8839ce1c49d7420df (diff)
downloadgcc-57d0100fbd6823e5c9715d3f46030484a7667371.tar.gz
PR c++/40566
* convert.c (convert_to_integer) <case COND_EXPR>: Don't convert to type arguments that have void type. * g++.dg/parse/cond5.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149121 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/convert.c')
-rw-r--r--gcc/convert.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/convert.c b/gcc/convert.c
index 8245e1647fb..706dc41985c 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -772,10 +772,16 @@ convert_to_integer (tree type, tree expr)
case COND_EXPR:
/* It is sometimes worthwhile to push the narrowing down through
- the conditional and never loses. */
+ the conditional and never loses. A COND_EXPR may have a throw
+ as one operand, which then has void type. Just leave void
+ operands as they are. */
return fold_build3 (COND_EXPR, type, TREE_OPERAND (expr, 0),
- convert (type, TREE_OPERAND (expr, 1)),
- convert (type, TREE_OPERAND (expr, 2)));
+ VOID_TYPE_P (TREE_TYPE (TREE_OPERAND (expr, 1)))
+ ? TREE_OPERAND (expr, 1)
+ : convert (type, TREE_OPERAND (expr, 1)),
+ VOID_TYPE_P (TREE_TYPE (TREE_OPERAND (expr, 2)))
+ ? TREE_OPERAND (expr, 2)
+ : convert (type, TREE_OPERAND (expr, 2)));
default:
break;