diff options
author | Leandro Melo <leandro.melo@nokia.com> | 2012-08-27 09:29:40 +0200 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2012-08-27 13:18:28 +0200 |
commit | 250b8e4934ae8cfb2bf80617f15c94199fe2624b (patch) | |
tree | 29d648604dbe8a99883900d2c2fa31909fd822a1 /src/libs/cplusplus/LookupContext.cpp | |
parent | c636fc2efed8ec16ce8e7ac6e86ccd4154db527d (diff) | |
download | qt-creator-250b8e4934ae8cfb2bf80617f15c94199fe2624b.tar.gz |
C++: Fix base template argument/param matching
Change-Id: I8c6be9e023a757c43eb4b8669ca8c37239ab579d
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/libs/cplusplus/LookupContext.cpp')
-rw-r--r-- | src/libs/cplusplus/LookupContext.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 5fb0e2e3ec..743e9a0fca 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -668,6 +668,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac // It gets a bit complicated if the reference is actually a class template because we // now must worry about dependent names in base classes. if (Template *templ = referenceClass->enclosingTemplate()) { + const unsigned argumentCount = templId->templateArgumentCount(); QHash<const Name*, unsigned> templParams; for (unsigned i = 0; i < templ->templateParameterCount(); ++i) templParams.insert(templ->templateParameterAt(i)->name(), i); @@ -679,15 +680,20 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac // This is the simple case in which a template parameter is itself a base. // Ex.: template <class T> class A : public T {}; if (templParams.contains(nameId)) { - const FullySpecifiedType &fullType = - templId->templateArgumentAt(templParams.value(nameId)); - if (NamedType *namedType = fullType.type()->asNamedType()) - baseBinding = lookupType(namedType->name()); + const unsigned parameterIndex = templParams.value(nameId); + if (parameterIndex < argumentCount) { + const FullySpecifiedType &fullType = + templId->templateArgumentAt(parameterIndex); + if (fullType.isValid()) { + if (NamedType *namedType = fullType.type()->asNamedType()) + baseBinding = lookupType(namedType->name()); + } + } } } else { SubstitutionMap map; for (unsigned i = 0; - i < templ->templateParameterCount() && i < templId->templateArgumentCount(); + i < templ->templateParameterCount() && i < argumentCount; ++i) { map.bind(templ->templateParameterAt(i)->name(), templId->templateArgumentAt(i)); |