When mapping from an injected-class-name to its corresponding

template, make sure to get the template that corresponds to *this*
declaration of the class template or specialization, rather than the
canonical specialization. Fixes PR5187.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84119 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2009-10-14 17:30:58 +00:00
Родитель 31b63beefa
Коммит 542b548e04
2 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -45,7 +45,7 @@ static NamedDecl *isAcceptableTemplateName(ASTContext &Context, NamedDecl *D) {
// which could be the current specialization or another
// specialization.
if (Record->isInjectedClassName()) {
Record = cast<CXXRecordDecl>(Record->getCanonicalDecl());
Record = cast<CXXRecordDecl>(Record->getDeclContext());
if (Record->getDescribedClassTemplate())
return Record->getDescribedClassTemplate();

Просмотреть файл

@ -22,3 +22,23 @@ template<class T, bool = a<T>::v> struct p { }; // expected-error {{no member na
template struct p<bool>; // expected-note {{in instantiation of default argument for 'p<bool>' required here}}
template struct p<int>;
// PR5187
template<typename T, typename U>
struct A;
template<typename T, typename U = T>
struct A;
template<typename T, typename U>
struct A {
void f(A<T>);
};
template<typename T>
struct B { };
template<>
struct B<void> {
typedef B<void*> type;
};