diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1272,10 +1272,12 @@ if (PrevColNum != 0 && CurColNum != 0 && StmtColNum != 0 && ((PrevColNum > StmtColNum && PrevColNum == CurColNum) || - !Tok.isAtStartOfLine()) && SM.getPresumedLineNumber(StmtLoc) != - SM.getPresumedLineNumber(Tok.getLocation())) { - P.Diag(Tok.getLocation(), diag::warn_misleading_indentation) - << Kind; + !Tok.isAtStartOfLine()) && + SM.getPresumedLineNumber(StmtLoc) != + SM.getPresumedLineNumber(Tok.getLocation()) && + (Tok.isNot(tok::identifier) || + P.getPreprocessor().LookAhead(0).isNot(tok::colon))) { + P.Diag(Tok.getLocation(), diag::warn_misleading_indentation) << Kind; P.Diag(StmtLoc, diag::note_previous_statement); } } diff --git a/clang/test/Parser/warn-misleading-indentation.cpp b/clang/test/Parser/warn-misleading-indentation.cpp --- a/clang/test/Parser/warn-misleading-indentation.cpp +++ b/clang/test/Parser/warn-misleading-indentation.cpp @@ -305,3 +305,10 @@ fail:; } +void f_label(int b) { + if (b) + return; + a: + return; + goto a; +}