------------------------------------------------------------------------
r276350 | epilk | 2016-07-21 15:31:40 -0700 (Thu, 21 Jul 2016) | 3 lines
[CodeGen] Fix a crash when constant folding switch statement
Differential revision: https://reviews.llvm.org/D22542
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_39@276985
91177308-0d34-0410-b5e6-
96231b3b80d8
}
void CodeGenFunction::EmitDefaultStmt(const DefaultStmt &S) {
+ // If there is no enclosing switch instance that we're aware of, then this
+ // default statement can be elided. This situation only happens when we've
+ // constant-folded the switch.
+ if (!SwitchInsn) {
+ EmitStmt(S.getSubStmt());
+ return;
+ }
+
llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
assert(DefaultBlock->empty() &&
"EmitDefaultStmt: Default block already defined?");
return test(5);
}
+void other_test() {
+ switch(0) {
+ case 0:
+ do {
+ default:;
+ } while(0);
+ }
+}
+
// CHECK: call i32 (i8*, ...) @_Z6printfPKcz