Skip to content

Commit 568174c

Browse files
committed
[CSDiagnostics] Don't try to diagnose empty case/switch statements as unsupported
Such statements are already incorrect and going to be diagnosed by the parser.
1 parent bf0e0f1 commit 568174c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: lib/Sema/CSDiagnostics.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -6203,6 +6203,19 @@ void SkipUnhandledConstructInResultBuilderFailure::diagnosePrimary(
62036203
}
62046204

62056205
if (auto stmt = unhandled.dyn_cast<Stmt *>()) {
6206+
if (auto *switchStmt = getAsStmt<SwitchStmt>(stmt)) {
6207+
auto caseStmts = switchStmt->getCases();
6208+
if (caseStmts.empty())
6209+
return;
6210+
}
6211+
6212+
// Empty case statements are diagnosed by parser.
6213+
if (auto *caseStmt = getAsStmt<CaseStmt>(stmt)) {
6214+
auto *body = caseStmt->getBody();
6215+
if (body->getNumElements() == 0)
6216+
return;
6217+
}
6218+
62066219
emitDiagnostic(asNote ? diag::note_result_builder_control_flow
62076220
: diag::result_builder_control_flow,
62086221
builder->getName());

0 commit comments

Comments
 (0)