aboutsummaryrefslogtreecommitdiff
path: root/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-07-19 00:07:36 +0000
committerChris Lattner <sabre@nondot.org>2007-07-19 00:07:36 +0000
commit0ea793e5e37a7b2283ef0c64676ffc7201b1b417 (patch)
treec90b4762f546d6355aaeb601ca39dc10a16a39d0 /Lex/Preprocessor.cpp
parent76e773a443be9f006610f46529e07d4c8d857680 (diff)
Correctly respect C99 5.1.1.2p4 when searching for the first '(' of
a function-like macro invocation. Patch contributed by Neil Booth. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40026 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Lex/Preprocessor.cpp')
-rw-r--r--Lex/Preprocessor.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp
index 93017937d5..bc7ad12e56 100644
--- a/Lex/Preprocessor.cpp
+++ b/Lex/Preprocessor.cpp
@@ -554,14 +554,24 @@ bool Preprocessor::isNextPPTokenLParen() {
Val = CurMacroExpander->isNextTokenLParen();
if (Val == 2) {
- // If we ran off the end of the lexer or macro expander, walk the include
- // stack, looking for whatever will return the next token.
- for (unsigned i = IncludeMacroStack.size(); Val == 2 && i != 0; --i) {
+ // We have run off the end. If it's a source file we don't
+ // examine enclosing ones (C99 5.1.1.2p4). Otherwise walk up the
+ // macro stack.
+ if (CurLexer)
+ return false;
+ for (unsigned i = IncludeMacroStack.size(); i != 0; --i) {
IncludeStackInfo &Entry = IncludeMacroStack[i-1];
if (Entry.TheLexer)
Val = Entry.TheLexer->isNextPPTokenLParen();
else
Val = Entry.TheMacroExpander->isNextTokenLParen();
+
+ if (Val != 2)
+ break;
+
+ // Ran off the end of a source file?
+ if (Entry.TheLexer)
+ return false;
}
}