diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index b796540156539..0339328ca5137 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1272,10 +1272,12 @@ struct MisleadingIndentationChecker { 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 index 4b9d45b19ca6e..8339f21099c31 100644 --- a/clang/test/Parser/warn-misleading-indentation.cpp +++ b/clang/test/Parser/warn-misleading-indentation.cpp @@ -305,3 +305,10 @@ int main(int argc, char* argv[]) { fail:; } +void f_label(int b) { + if (b) + return; + a: + return; + goto a; +}