diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-05-04 18:18:31 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-05-04 18:18:31 +0000 |
| commit | c8be95274d615a6ca3d4b717267100531ff84ed2 (patch) | |
| tree | 16207c834f17e11f4a46d55c7a35958bc7102140 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
| parent | a25ee78fc0afc78dd363037daef4245f92e23218 (diff) | |
| download | bcm5719-llvm-c8be95274d615a6ca3d4b717267100531ff84ed2.tar.gz bcm5719-llvm-c8be95274d615a6ca3d4b717267100531ff84ed2.zip | |
When instantiating a function that was declared via a typedef, e.g.,
typedef int functype(int, int);
functype func;
also instantiate the synthesized function parameters for the resulting
function declaration.
With this change, Boost.Wave builds and passes all of its regression
tests.
llvm-svn: 103025
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 8b851b21eac..da8480633d5 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1169,6 +1169,27 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, return 0; QualType T = TInfo->getType(); + // \brief If the type of this function is not *directly* a function + // type, then we're instantiating the a function that was declared + // via a typedef, e.g., + // + // typedef int functype(int, int); + // functype func; + // + // In this case, we'll just go instantiate the ParmVarDecls that we + // synthesized in the method declaration. + if (!isa<FunctionProtoType>(T)) { + assert(!Params.size() && "Instantiating type could not yield parameters"); + for (unsigned I = 0, N = D->getNumParams(); I != N; ++I) { + ParmVarDecl *P = SemaRef.SubstParmVarDecl(D->getParamDecl(I), + TemplateArgs); + if (!P) + return 0; + + Params.push_back(P); + } + } + NestedNameSpecifier *Qualifier = D->getQualifier(); if (Qualifier) { Qualifier = SemaRef.SubstNestedNameSpecifier(Qualifier, |

