Fix an edge case in IRGen for conditionals. PR11509.

llvm-svn: 146189
This commit is contained in:
Eli Friedman 2011-12-08 22:01:56 +00:00
parent 6e09995159
commit 516c2ad731
2 changed files with 11 additions and 0 deletions

View File

@ -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");
}

View File

@ -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;
}