summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-03 15:32:18 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-03 15:32:18 +0000
commit95c70ec678b9584c7e7516d420b95176eb5a0e11 (patch)
tree626255ac80cb3e6539b0078d2e563878906a7de4 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
parent456ad1a81743cf00c71a68a4aa570f18b29d4c29 (diff)
downloadbcm5719-llvm-95c70ec678b9584c7e7516d420b95176eb5a0e11.tar.gz
bcm5719-llvm-95c70ec678b9584c7e7516d420b95176eb5a0e11.zip
When instantiating a member function declared via a typedef, don't try
to enter the instantiated parameter declarations into the local instantiation scope; they can't be referenced anyway. Fixes PR7022. llvm-svn: 102914
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 48b517ef22f..8974ecbdf42 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1776,28 +1776,32 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
if (NewTInfo != OldTInfo) {
// Get parameters from the new type info.
TypeLoc OldTL = OldTInfo->getTypeLoc();
- FunctionProtoTypeLoc *OldProtoLoc = cast<FunctionProtoTypeLoc>(&OldTL);
- TypeLoc NewTL = NewTInfo->getTypeLoc();
- FunctionProtoTypeLoc *NewProtoLoc = cast<FunctionProtoTypeLoc>(&NewTL);
- assert(NewProtoLoc && "Missing prototype?");
- for (unsigned i = 0, i_end = NewProtoLoc->getNumArgs(); i != i_end; ++i) {
- // FIXME: Variadic templates will break this.
- Params.push_back(NewProtoLoc->getArg(i));
- SemaRef.CurrentInstantiationScope->InstantiatedLocal(
+ if (FunctionProtoTypeLoc *OldProtoLoc
+ = dyn_cast<FunctionProtoTypeLoc>(&OldTL)) {
+ TypeLoc NewTL = NewTInfo->getTypeLoc();
+ FunctionProtoTypeLoc *NewProtoLoc = cast<FunctionProtoTypeLoc>(&NewTL);
+ assert(NewProtoLoc && "Missing prototype?");
+ for (unsigned i = 0, i_end = NewProtoLoc->getNumArgs(); i != i_end; ++i) {
+ // FIXME: Variadic templates will break this.
+ Params.push_back(NewProtoLoc->getArg(i));
+ SemaRef.CurrentInstantiationScope->InstantiatedLocal(
OldProtoLoc->getArg(i),
NewProtoLoc->getArg(i));
+ }
}
} else {
// The function type itself was not dependent and therefore no
// substitution occurred. However, we still need to instantiate
// the function parameters themselves.
TypeLoc OldTL = OldTInfo->getTypeLoc();
- FunctionProtoTypeLoc *OldProtoLoc = cast<FunctionProtoTypeLoc>(&OldTL);
- for (unsigned i = 0, i_end = OldProtoLoc->getNumArgs(); i != i_end; ++i) {
- ParmVarDecl *Parm = VisitParmVarDecl(OldProtoLoc->getArg(i));
- if (!Parm)
- return 0;
- Params.push_back(Parm);
+ if (FunctionProtoTypeLoc *OldProtoLoc
+ = dyn_cast<FunctionProtoTypeLoc>(&OldTL)) {
+ for (unsigned i = 0, i_end = OldProtoLoc->getNumArgs(); i != i_end; ++i) {
+ ParmVarDecl *Parm = VisitParmVarDecl(OldProtoLoc->getArg(i));
+ if (!Parm)
+ return 0;
+ Params.push_back(Parm);
+ }
}
}
return NewTInfo;
OpenPOWER on IntegriCloud