diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp --- a/clang/lib/Sema/JumpDiagnostics.cpp +++ b/clang/lib/Sema/JumpDiagnostics.cpp @@ -331,11 +331,8 @@ // operand (to avoid recording the address-of-label use), which // works only because of the restricted set of expressions which // we detect as constant targets. - if (cast(S)->getConstantTarget()) { - LabelAndGotoScopes[S] = ParentScope; - Jumps.push_back(S); - return; - } + if (cast(S)->getConstantTarget()) + goto RecordJumpScope; LabelAndGotoScopes[S] = ParentScope; IndirectJumps.push_back(S); @@ -352,15 +349,17 @@ BuildScopeInformation(Var, ParentScope); ++StmtsToSkip; } - [[fallthrough]]; + goto RecordJumpScope; - case Stmt::GotoStmtClass: case Stmt::GCCAsmStmtClass: - if (auto *GS = dyn_cast(S)) - if (!GS->isAsmGoto()) - break; + if (!cast(S)->isAsmGoto()) + break; + goto RecordJumpScope; + + case Stmt::GotoStmtClass: // Remember both what scope a goto is in as well as the fact that we have // it. This makes the second scan not have to walk the AST again. +RecordJumpScope: LabelAndGotoScopes[S] = ParentScope; Jumps.push_back(S); break;