From d90c3c92d58a2757aab06b5d6d034a8f199c1ab5 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 27 Aug 2011 06:37:51 +0000 Subject: Take an entirely different approach to handling the "parsing" of __import__ within the preprocessor, since the prior one foolishly assumed that Preprocessor::Lex() was re-entrant. We now handle __import__ at the top level (only), after macro expansion. This should fix the buildbot failures. llvm-svn: 138704 --- clang/lib/Lex/Preprocessor.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'clang/lib/Lex/Preprocessor.cpp') diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 1d1687d84b9..51908bdb878 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -88,6 +88,8 @@ Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts, // We haven't read anything from the external source. ReadMacrosFromExternalSource = false; + LexDepth = 0; + // "Poison" __VA_ARGS__, which can only appear in the expansion of a macro. // This gets unpoisoned where it is allowed. (Ident__VA_ARGS__ = getIdentifierInfo("__VA_ARGS__"))->setIsPoisoned(); @@ -484,7 +486,7 @@ void Preprocessor::HandleIdentifier(Token &Identifier) { if (!DisableMacroExpansion && !Identifier.isExpandDisabled()) { if (MI->isEnabled()) { if (!HandleMacroExpandedIdentifier(Identifier, MI)) - goto finish; + return; } else { // C99 6.10.3.4p2 says that a disabled macro may never again be // expanded, even if it's in a context where it could be expanded in the @@ -506,12 +508,6 @@ void Preprocessor::HandleIdentifier(Token &Identifier) { // like "#define TY typeof", "TY(1) x". if (II.isExtensionToken() && !DisableMacroExpansion) Diag(Identifier, diag::ext_token_used); - -finish: - // If we have the start of a module import, handle it now. - if (Identifier.is(tok::kw___import__) && - !InMacroArgs && !DisableMacroExpansion) - HandleModuleImport(Identifier); } void Preprocessor::HandleModuleImport(Token &Import) { -- cgit v1.2.3