forked from OSchip/llvm-project
Fix a bug where we would not mark temporaries as conditional when emitting a conditional operator as an lvalue.
llvm-svn: 95311
This commit is contained in:
parent
e5dfc26850
commit
9b942c65a5
|
@ -1538,9 +1538,12 @@ CodeGenFunction::EmitConditionalOperatorLValue(const ConditionalOperator* E) {
|
|||
|
||||
EmitBranchOnBoolExpr(E->getCond(), LHSBlock, RHSBlock);
|
||||
|
||||
// Any temporaries created here are conditional.
|
||||
BeginConditionalBranch();
|
||||
EmitBlock(LHSBlock);
|
||||
|
||||
LValue LHS = EmitLValue(E->getLHS());
|
||||
EndConditionalBranch();
|
||||
|
||||
if (!LHS.isSimple())
|
||||
return EmitUnsupportedLValue(E, "conditional operator");
|
||||
|
||||
|
@ -1548,8 +1551,11 @@ CodeGenFunction::EmitConditionalOperatorLValue(const ConditionalOperator* E) {
|
|||
Builder.CreateStore(LHS.getAddress(), Temp);
|
||||
EmitBranch(ContBlock);
|
||||
|
||||
// Any temporaries created here are conditional.
|
||||
BeginConditionalBranch();
|
||||
EmitBlock(RHSBlock);
|
||||
LValue RHS = EmitLValue(E->getRHS());
|
||||
EndConditionalBranch();
|
||||
if (!RHS.isSimple())
|
||||
return EmitUnsupportedLValue(E, "conditional operator");
|
||||
|
||||
|
|
|
@ -9,14 +9,20 @@ struct A {
|
|||
A() : i(0) { ctorcalls++; }
|
||||
~A() { dtorcalls++; }
|
||||
int i;
|
||||
|
||||
friend const A& operator<<(const A& a, int n) {
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
void g(int) { }
|
||||
void g(const A&) { }
|
||||
|
||||
void f1(bool b) {
|
||||
g(b ? A().i : 0);
|
||||
g(b || A().i);
|
||||
g(b && A().i);
|
||||
g(b ? A() << 1 : A() << 2);
|
||||
}
|
||||
|
||||
struct Checker {
|
||||
|
|
Loading…
Reference in New Issue