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
This commit is contained in:
Chris Lattner 2009-04-14 05:15:20 +00:00
parent ce2ab6f425
commit 825676afdf
1 changed files with 7 additions and 1 deletions

View File

@ -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();
}
}