diff options
author | Chris Lattner <sabre@nondot.org> | 2007-11-23 06:50:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-11-23 06:50:21 +0000 |
commit | 0c3eb29e79e439a0d73e81e57cc130ddb45d50ea (patch) | |
tree | 482ebe15b0db8a77fc4b663e8ab5476849e7710d /Lex/Preprocessor.cpp | |
parent | b235fc2cf37621c7fc6511bb2b8788c95f9fb9fc (diff) |
Fix PR1820, an incredibly subtle macro expansion bug that Neil discovered.
Neil, please review this fix.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Lex/Preprocessor.cpp')
-rw-r--r-- | Lex/Preprocessor.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp index 0970590afe..a685b0b27b 100644 --- a/Lex/Preprocessor.cpp +++ b/Lex/Preprocessor.cpp @@ -941,6 +941,16 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, // If this is a comment token in the argument list and we're just in // -C mode (not -CC mode), discard the comment. continue; + } else if (Tok.is(tok::identifier)) { + // Reading macro arguments can cause macros that we are currently + // expanding from to be popped off the expansion stack. Doing so causes + // them to be reenabled for expansion. Here we record whether any + // identifiers we lex as macro arguments correspond to disabled macros. + // If so, we mark the token as noexpand. This is a subtle aspect of + // C99 6.10.3.4p2. + if (MacroInfo *MI = getMacroInfo(Tok.getIdentifierInfo())) + if (!MI->isEnabled()) + Tok.setFlag(Token::DisableExpand); } ArgTokens.push_back(Tok); |