Commit 250b8e49 authored by Leandro Melo's avatar Leandro Melo Committed by hjk
Browse files

C++: Fix base template argument/param matching



Change-Id: I8c6be9e023a757c43eb4b8669ca8c37239ab579d
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent c636fc2e
......@@ -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));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment