aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-02-26 21:45:12 -0500
committerJason Merrill <jason@gcc.gnu.org>2018-02-26 21:45:12 -0500
commita2444ce97021c7a1e9afe05d014435c4c6933659 (patch)
treee2fbfb8b75f6eb16b0beabd4d2cbf3b92fcdae25 /gcc/cp/call.c
parentab5f26bba1270e16317188fe1070df05ab89bb00 (diff)
downloadgcc-a2444ce97021c7a1e9afe05d014435c4c6933659.zip
gcc-a2444ce97021c7a1e9afe05d014435c4c6933659.tar.gz
gcc-a2444ce97021c7a1e9afe05d014435c4c6933659.tar.bz2
PR c++/84441 - ICE with base initialized from ?:
* call.c (unsafe_copy_elision_p): Handle COND_EXPR. From-SVN: r258022
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index c47befd..11fe282 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -7580,6 +7580,15 @@ unsafe_copy_elision_p (tree target, tree exp)
/* build_compound_expr pushes COMPOUND_EXPR inside TARGET_EXPR. */
while (TREE_CODE (init) == COMPOUND_EXPR)
init = TREE_OPERAND (init, 1);
+ if (TREE_CODE (init) == COND_EXPR)
+ {
+ /* We'll end up copying from each of the arms of the COND_EXPR directly
+ into the target, so look at them. */
+ if (tree op = TREE_OPERAND (init, 1))
+ if (unsafe_copy_elision_p (target, op))
+ return true;
+ return unsafe_copy_elision_p (target, TREE_OPERAND (init, 2));
+ }
return (TREE_CODE (init) == AGGR_INIT_EXPR
&& !AGGR_INIT_VIA_CTOR_P (init));
}