forked from OSchip/llvm-project
Fix an edge case in IRGen for conditionals. PR11509.
llvm-svn: 146189
This commit is contained in:
parent
6e09995159
commit
516c2ad731
|
@ -2566,6 +2566,11 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
|
|||
llvm::Value *CondV = CGF.EvaluateExprAsBool(condExpr);
|
||||
llvm::Value *LHS = Visit(lhsExpr);
|
||||
llvm::Value *RHS = Visit(rhsExpr);
|
||||
if (!LHS) {
|
||||
// If the conditional has void type, make sure we return a null Value*.
|
||||
assert(!RHS && "LHS and RHS types must match");
|
||||
return 0;
|
||||
}
|
||||
return Builder.CreateSelect(CondV, LHS, RHS, "cond");
|
||||
}
|
||||
|
||||
|
|
|
@ -66,3 +66,9 @@ int test11(int c) {
|
|||
double test12(int c) {
|
||||
return c ? 4.0 : 2.0;
|
||||
}
|
||||
// CHECK: @test13
|
||||
// CHECK: call {{.*}} @f2(
|
||||
int f2(void);
|
||||
void test13() {
|
||||
f2() ? (void)0 : (void)0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue