VisitForTemporaryDtors(E->getCond(), false, Context);
CFGBlock *ConditionBlock = Block;
CFGBlock *ConditionSucc = Succ;
+ TryResult ConditionVal = tryEvaluateBool(E->getCond());
TempDtorContext TrueContext(/*IsConditional=*/true);
- VisitForTemporaryDtors(E->getTrueExpr(), BindToTemporary, TrueContext);
+ if (!ConditionVal.isFalse()) {
+ VisitForTemporaryDtors(E->getTrueExpr(), BindToTemporary, TrueContext);
+ if (ConditionVal.isTrue())
+ return Block;
+ }
CFGBlock *TrueBlock = Block;
Block = ConditionBlock;
Succ = ConditionSucc;
TempDtorContext FalseContext(/*IsConditional=*/true);
- VisitForTemporaryDtors(E->getFalseExpr(), BindToTemporary, FalseContext);
+ if (!ConditionVal.isTrue()) {
+ VisitForTemporaryDtors(E->getFalseExpr(), BindToTemporary, FalseContext);
+ if (ConditionVal.isFalse())
+ return Block;
+ }
if (TrueContext.TerminatorExpr && FalseContext.TerminatorExpr) {
InsertTempDtorDecisionBlock(FalseContext, TrueBlock);
true ? NoReturn() : NoReturn();
}
+int testTernaryStaticallyConditionalNoretrunOnTrue() {
+ true ? NoReturn() : Return();
+}
+
+int testTernaryStaticallyConditionalRetrunOnTrue() {
+ true ? Return() : NoReturn();
+} // expected-warning {{control reaches end of non-void function}}
+
+int testTernaryStaticallyConditionalNoretrunOnFalse() {
+ false ? Return() : NoReturn();
+}
+
+int testTernaryStaticallyConditionalRetrunOnFalse() {
+ false ? NoReturn() : Return();
+} // expected-warning {{control reaches end of non-void function}}
+
int testTernaryConditionalNoreturnTrueBranch(bool value) {
value ? (NoReturn() || NoReturn()) : Return();
} // expected-warning {{control may reach end of non-void function}}