aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PPDirectives.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-14 05:15:20 +0000
committerChris Lattner <sabre@nondot.org>2009-04-14 05:15:20 +0000
commit959875a66d74d38b8f2d499662afb142d249bf3e (patch)
tree325fb11c54248beb3ff0a4b505482d4d3ef6f899 /lib/Lex/PPDirectives.cpp
parent35410d5cbbb18735d76e00496540d416dc49b577 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69024 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPDirectives.cpp')
-rw-r--r--lib/Lex/PPDirectives.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index affd9886f0..742076956d 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/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();
}
}