diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-02-16 01:20:36 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-02-16 01:20:36 +0000 |
| commit | 27055194b769d52c89fead4a4dc3614266fa59ba (patch) | |
| tree | 76a132240e2cf42693d542eb40b40f7f19a410a3 /clang/Lex/Preprocessor.cpp | |
| parent | 3ea23a45d97a38fdd893ad2738e3bb2dddaf10ff (diff) | |
| download | bcm5719-llvm-27055194b769d52c89fead4a4dc3614266fa59ba.tar.gz bcm5719-llvm-27055194b769d52c89fead4a4dc3614266fa59ba.zip | |
Fix CheckEndOfDirective to diagnose lines that contain macros that expand to
zero tokens. This fixes PR2045, thanks to Neil for finding another
incredibly subtle corner case :)
llvm-svn: 47203
Diffstat (limited to 'clang/Lex/Preprocessor.cpp')
| -rw-r--r-- | clang/Lex/Preprocessor.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/Lex/Preprocessor.cpp b/clang/Lex/Preprocessor.cpp index a291fe35dfb..7bd359ae18d 100644 --- a/clang/Lex/Preprocessor.cpp +++ b/clang/Lex/Preprocessor.cpp @@ -1498,11 +1498,14 @@ void Preprocessor::ReadMacroName(Token &MacroNameTok, char isDefineUndef) { /// not, emit a diagnostic and consume up until the eom. void Preprocessor::CheckEndOfDirective(const char *DirType) { Token Tmp; - Lex(Tmp); + // Lex unexpanded tokens: macros might expand to zero tokens, causing us to + // miss diagnosing invalid lines. + LexUnexpandedToken(Tmp); + // There should be no tokens after the directive, but we allow them as an // extension. while (Tmp.is(tok::comment)) // Skip comments in -C mode. - Lex(Tmp); + LexUnexpandedToken(Tmp); if (Tmp.isNot(tok::eom)) { Diag(Tmp, diag::ext_pp_extra_tokens_at_eol, DirType); |

