forked from OSchip/llvm-project
Correctly handle conditional operators involving throw.
llvm-svn: 90800
This commit is contained in:
parent
5445f6e5b6
commit
f6c175b745
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue