Skip to content

Commit

Permalink
PR c++/84441 - ICE with base initialized from ?:
Browse files Browse the repository at this point in the history
	* call.c (unsafe_copy_elision_p): Handle COND_EXPR.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258022 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
jason committed Feb 27, 2018
1 parent 9960ad2 commit f52b11f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2018-02-26 Jason Merrill <jason@redhat.com>

PR c++/84441 - ICE with base initialized from ?:
* call.c (unsafe_copy_elision_p): Handle COND_EXPR.

PR c++/84520 - ICE with generic lambda in NSDMI.
* lambda.c (lambda_expr_this_capture): Don't look for fake NSDMI
'this' in a generic lambda instantiation.
Expand Down
9 changes: 9 additions & 0 deletions gcc/cp/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
21 changes: 21 additions & 0 deletions gcc/testsuite/g++.dg/cpp0x/elision3.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// PR c++/84441
// { dg-do compile { target c++11 } }

struct B {
int *b;
};
struct A {
B b;
A (A &&);
};
struct C {
A c;
int d;
};
C bar ();
struct D : C {
D ()
: C (0 ? bar () : bar ())
{}
};
D d;

0 comments on commit f52b11f

Please sign in to comment.