]> granicus.if.org Git - clang/commitdiff
When mapping from an injected-class-name to its corresponding
authorDouglas Gregor <dgregor@apple.com>
Wed, 14 Oct 2009 17:30:58 +0000 (17:30 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 14 Oct 2009 17:30:58 +0000 (17:30 +0000)
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

lib/Sema/SemaTemplate.cpp
test/SemaTemplate/default-arguments.cpp

index 4a410ecb1468d10b0293b62a053a4fd2384143bc..d56b4e114e74c1822a5cf04451507c87642c850c 100644 (file)
@@ -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();
 
index f9bb44ecb9c0ca32086cbeb05938bac0422762b1..33677aab73acb0c418c6aaa9ddf774a9ab70670a 100644 (file)
@@ -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;
+};