@@ -6203,19 +6203,6 @@ void SkipUnhandledConstructInResultBuilderFailure::diagnosePrimary(
6203
6203
}
6204
6204
6205
6205
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
-
6219
6206
emitDiagnostic (asNote ? diag::note_result_builder_control_flow
6220
6207
: diag::result_builder_control_flow,
6221
6208
builder->getName ());
@@ -6287,6 +6274,27 @@ void SkipUnhandledConstructInResultBuilderFailure::diagnosePrimary(
6287
6274
}
6288
6275
6289
6276
bool 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
+
6290
6298
diagnosePrimary (/* asNote=*/ false );
6291
6299
emitDiagnosticAt (builder, diag::kind_declname_declared_here,
6292
6300
builder->getDescriptiveKind (), builder->getName ());
0 commit comments