diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-14 05:15:20 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-14 05:15:20 +0000 |
commit | 825676afdfb0505e93c6baecd5fa33d7ed32ef1a (patch) | |
tree | f6c984e4870ad68bd4b4c486ce00648e4ca8bc73 | |
parent | ce2ab6f425f4241186d3af7d43b8f30ee93d044d (diff) | |
download | bcm5719-llvm-825676afdfb0505e93c6baecd5fa33d7ed32ef1a.tar.gz bcm5719-llvm-825676afdfb0505e93c6baecd5fa33d7ed32ef1a.zip |
Offer a fixit hint for our warning about tokens at the end of a directive:
t.c:3:8: warning: extra tokens at end of #endif directive
#endif foo
^
//
Don't do this in strict-C89 mode because bcpl comments aren't
valid there, and it is too much trouble to analyze whether
C block comments are safe.
llvm-svn: 69024
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index affd9886f02..742076956d2 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -114,7 +114,13 @@ void Preprocessor::CheckEndOfDirective(const char *DirType) { LexUnexpandedToken(Tmp); if (Tmp.isNot(tok::eom)) { - Diag(Tmp, diag::ext_pp_extra_tokens_at_eol) << DirType; + // Add a fixit in GNU/C99/C++ mode. Don't offer a fixit for strict-C89, + // because it is more trouble than it is worth to insert /**/ and check that + // there is no /**/ in the range also. + CodeModificationHint FixItHint; + if (Features.GNUMode || Features.C99 || Features.CPlusPlus) + FixItHint = CodeModificationHint::CreateInsertion(Tmp.getLocation(),"//"); + Diag(Tmp, diag::ext_pp_extra_tokens_at_eol) << DirType << FixItHint; DiscardUntilEndOfDirective(); } } |