Correctly handle conditional operators involving throw.

llvm-svn: 90800
This commit is contained in:
Eli Friedman 2009-12-07 20:25:53 +00:00
parent 5445f6e5b6
commit f6c175b745
2 changed files with 15 additions and 4 deletions

View File

@ -1868,10 +1868,11 @@ VisitConditionalOperator(const ConditionalOperator *E) {
CGF.EmitBlock(ContBlock);
if (!LHS || !RHS) {
assert(E->getType()->isVoidType() && "Non-void value should have a value");
return 0;
}
// If the LHS or RHS is a throw expression, it will be legitimately null.
if (!LHS)
return RHS;
if (!RHS)
return LHS;
// Create a PHI node for the real part.
llvm::PHINode *PN = Builder.CreatePHI(LHS->getType(), "cond");

View File

@ -0,0 +1,10 @@
// RUN: clang-cc -emit-llvm-only -verify %s
int val = 42;
int& test1() {
return throw val, val;
}
int test2() {
return val ? throw val : val;
}