@@ -6203,19 +6203,6 @@ 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-
62196206 emitDiagnostic (asNote ? diag::note_result_builder_control_flow
62206207 : diag::result_builder_control_flow,
62216208 builder->getName ());
@@ -6287,6 +6274,27 @@ void SkipUnhandledConstructInResultBuilderFailure::diagnosePrimary(
62876274}
62886275
62896276bool SkipUnhandledConstructInResultBuilderFailure::diagnoseAsError () {
6277+ // Following errors are already diagnosed:
6278+ // - brace statement - error related to absence of appropriate buildBlock
6279+ // - switch/case statements - empty body
6280+ if (auto *stmt = unhandled.dyn_cast <Stmt *>()) {
6281+ if (isa<BraceStmt>(stmt))
6282+ return true ;
6283+
6284+ if (auto *switchStmt = getAsStmt<SwitchStmt>(stmt)) {
6285+ auto caseStmts = switchStmt->getCases ();
6286+ if (caseStmts.empty ())
6287+ return true ;
6288+ }
6289+
6290+ // Empty case statements are diagnosed by parser.
6291+ if (auto *caseStmt = getAsStmt<CaseStmt>(stmt)) {
6292+ auto *body = caseStmt->getBody ();
6293+ if (body->getNumElements () == 0 )
6294+ return true ;
6295+ }
6296+ }
6297+
62906298 diagnosePrimary (/* asNote=*/ false );
62916299 emitDiagnosticAt (builder, diag::kind_declname_declared_here,
62926300 builder->getDescriptiveKind (), builder->getName ());
0 commit comments