Index: clang/lib/Sema/AnalysisBasedWarnings.cpp =================================================================== --- clang/lib/Sema/AnalysisBasedWarnings.cpp +++ clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -1216,9 +1216,10 @@ bool isFollowedByFallThroughComment(const Stmt *Statement) { // Try to detect whether the fallthough is marked by a comment like // /*FALLTHOUGH*/. + auto Loc = S.getSourceManager().getExpansionLoc(Statement->getEndLoc()); bool Invalid; - const char *SourceData = S.getSourceManager().getCharacterData( - Statement->getEndLoc(), &Invalid); + const char *SourceData = + S.getSourceManager().getCharacterData(Loc, &Invalid); if (Invalid) return false; const char *LineStart = SourceData; Index: clang/test/Sema/fallthrough-comment.c =================================================================== --- clang/test/Sema/fallthrough-comment.c +++ clang/test/Sema/fallthrough-comment.c @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s +#define SOME_CONSTANT 1 + int fallthrough_comment(int n) { switch (n) { case 0: @@ -10,9 +12,13 @@ /*fall-through.*/ - case 2: + case 3: + n += SOME_CONSTANT; + /* FALL THRU */ + + case 4: n++; - case 3: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '__attribute__((fallthrough));' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + case 5: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '__attribute__((fallthrough));' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} n++; break; }