aboutsummaryrefslogtreecommitdiff
path: root/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-16 01:20:36 +0000
committerChris Lattner <sabre@nondot.org>2008-02-16 01:20:36 +0000
commite9ba32357c380f587fc1296992822e1b47fbd22d (patch)
tree46fc0308a67aed17b8f8373f1d18b7f82ee22388 /Lex/Preprocessor.cpp
parent6a24acbb3dbb3bea9426716bee6ad6023ad15f3f (diff)
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 :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47203 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Lex/Preprocessor.cpp')
-rw-r--r--Lex/Preprocessor.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp
index a291fe35df..7bd359ae18 100644
--- a/Lex/Preprocessor.cpp
+++ b/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);