@@ -493,9 +493,10 @@ CIRGenFunction::emitCaseDefaultCascade(const T *stmt, mlir::Type condType,
493
493
// simple form later since the conversion itself should be harmless.
494
494
if (subStmtKind == SubStmtKind::Case)
495
495
result = emitCaseStmt (*cast<CaseStmt>(sub), condType, buildingTopLevelCase);
496
- else if (subStmtKind == SubStmtKind::Default)
496
+ else if (subStmtKind == SubStmtKind::Default) {
497
497
getCIRGenModule ().errorNYI (sub->getSourceRange (), " Default case" );
498
- else if (buildingTopLevelCase)
498
+ return mlir::failure ();
499
+ } else if (buildingTopLevelCase)
499
500
// If we're building a top level case, try to restore the insert point to
500
501
// the case we're building, then we can attach more random stmts to the
501
502
// case to make generating `cir.switch` operation to be a simple form.
@@ -513,6 +514,7 @@ mlir::LogicalResult CIRGenFunction::emitCaseStmt(const CaseStmt &s,
513
514
mlir::ArrayAttr value = builder.getArrayAttr (caseEltValueListAttr);
514
515
if (s.getRHS ()) {
515
516
getCIRGenModule ().errorNYI (s.getSourceRange (), " SwitchOp range kind" );
517
+ return mlir::failure ();
516
518
}
517
519
assert (!cir::MissingFeatures::foldCaseStmt ());
518
520
return emitCaseDefaultCascade (&s, condType, value, cir::CaseOpKind::Equal,
@@ -528,8 +530,10 @@ mlir::LogicalResult CIRGenFunction::emitSwitchCase(const SwitchCase &s,
528
530
return emitCaseStmt (cast<CaseStmt>(s), condTypeStack.back (),
529
531
buildingTopLevelCase);
530
532
531
- if (s.getStmtClass () == Stmt::DefaultStmtClass)
533
+ if (s.getStmtClass () == Stmt::DefaultStmtClass) {
532
534
getCIRGenModule ().errorNYI (s.getSourceRange (), " Default case" );
535
+ return mlir::failure ();
536
+ }
533
537
534
538
llvm_unreachable (" expect case or default stmt" );
535
539
}
@@ -724,7 +728,7 @@ mlir::LogicalResult CIRGenFunction::emitSwitchBody(const Stmt *s) {
724
728
// ...
725
729
// }
726
730
if (!isa<CompoundStmt>(s))
727
- return emitStmt (s, /* useCurrentScope=*/ ! false );
731
+ return emitStmt (s, /* useCurrentScope=*/ true );
728
732
729
733
auto *compoundStmt = cast<CompoundStmt>(s);
730
734
0 commit comments