diff options
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index a6aa1df818c..16e7eb30b30 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3025,9 +3025,18 @@ invert_truthvalue (tree arg) return TREE_OPERAND (arg, 0); case COND_EXPR: - return build3 (COND_EXPR, type, TREE_OPERAND (arg, 0), - invert_truthvalue (TREE_OPERAND (arg, 1)), - invert_truthvalue (TREE_OPERAND (arg, 2))); + { + tree arg1 = TREE_OPERAND (arg, 1); + tree arg2 = TREE_OPERAND (arg, 2); + /* A COND_EXPR may have a throw as one operand, which + then has void type. Just leave void operands + as they are. */ + return build3 (COND_EXPR, type, TREE_OPERAND (arg, 0), + VOID_TYPE_P (TREE_TYPE (arg1)) + ? arg1 : invert_truthvalue (arg1), + VOID_TYPE_P (TREE_TYPE (arg2)) + ? arg2 : invert_truthvalue (arg2)); + } case COMPOUND_EXPR: return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg, 0), |