diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 15 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 21 |
2 files changed, 21 insertions, 15 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 9f8f3cec28..b830d9ccfd 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1340,12 +1340,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, // Look at the next token to make sure that this isn't a function // declaration. We have to check this because __attribute__ might be the // start of a function definition in GCC-extended K&R C. - // FIXME. Delayed parsing not done for c/c++ functions nested in namespace - !isDeclarationAfterDeclarator() && - (!CurParsedObjCImpl || Tok.isNot(tok::l_brace) || - (getLangOpts().CPlusPlus && - (D.getCXXScopeSpec().isSet() || - !Actions.CurContext->isTranslationUnit())))) { + !isDeclarationAfterDeclarator()) { if (isStartOfFunctionDefinition(D)) { if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) { @@ -1401,14 +1396,6 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, DeclsInGroup.push_back(FirstDecl); bool ExpectSemi = Context != Declarator::ForContext; - - if (CurParsedObjCImpl && D.isFunctionDeclarator() && - Tok.is(tok::l_brace)) { - // Consume the tokens and store them for later parsing. - StashAwayMethodOrFunctionBodyTokens(FirstDecl); - CurParsedObjCImpl->HasCFunction = true; - ExpectSemi = false; - } // If we don't have a comma, it is either the end of the list (a ';') or an // error, bail out. diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 7314228b9f..3531deba4f 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -1025,7 +1025,26 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, } return DP; } - + else if (CurParsedObjCImpl && Tok.is(tok::l_brace) && + !TemplateInfo.TemplateParams && + Actions.CurContext->isTranslationUnit()) { + MultiTemplateParamsArg TemplateParameterLists(Actions, 0, 0); + ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope); + Scope *ParentScope = getCurScope()->getParent(); + + D.setFunctionDefinitionKind(FDK_Definition); + Decl *FuncDecl = Actions.HandleDeclarator(ParentScope, D, + move(TemplateParameterLists)); + D.complete(FuncDecl); + D.getMutableDeclSpec().abort(); + if (FuncDecl) { + // Consume the tokens and store them for later parsing. + StashAwayMethodOrFunctionBodyTokens(FuncDecl); + CurParsedObjCImpl->HasCFunction = true; + return FuncDecl; + } + } + // Enter a scope for the function body. ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope); |