diff options
author | John McCall <rjmccall@apple.com> | 2010-02-06 01:50:47 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-02-06 01:50:47 +0000 |
commit | 68b6b87b6beb7922fc2c8ab923ba2ce125490363 (patch) | |
tree | 220f198bad4343f9bbe8f25f79084e77c85554b3 /lib | |
parent | 2d565b30689c5f79f22de7bad8723c48006d3a06 (diff) |
Teach Sema how to instantiate a local function declaration properly. Fixes
PR 5517.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95470 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 66a8b1f1e6..244b5f511b 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -738,9 +738,14 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, if (T.isNull()) return 0; - // Build the instantiated method declaration. - DeclContext *DC = SemaRef.FindInstantiatedContext(D->getDeclContext(), - TemplateArgs); + // If we're instantiating a local function declaration, put the result + // in the owner; otherwise we need to find the instantiated context. + DeclContext *DC; + if (D->getDeclContext()->isFunctionOrMethod()) + DC = Owner; + else + DC = SemaRef.FindInstantiatedContext(D->getDeclContext(), TemplateArgs); + FunctionDecl *Function = FunctionDecl::Create(SemaRef.Context, DC, D->getLocation(), D->getDeclName(), T, D->getTypeSourceInfo(), |