summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-10-14 17:30:58 +0000
committerDouglas Gregor <dgregor@apple.com>2009-10-14 17:30:58 +0000
commit568a071dd2384788c6319935709f77a4dff15f7a (patch)
tree9265c0c61dcea72a520a4fb3bca06b112e1ff167
parent92f86199236e914aad6d98213c860478b88e98d4 (diff)
downloadbcm5719-llvm-568a071dd2384788c6319935709f77a4dff15f7a.tar.gz
bcm5719-llvm-568a071dd2384788c6319935709f77a4dff15f7a.zip
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. llvm-svn: 84119
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp2
-rw-r--r--clang/test/SemaTemplate/default-arguments.cpp20
2 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 4a410ecb146..d56b4e114e7 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -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();
diff --git a/clang/test/SemaTemplate/default-arguments.cpp b/clang/test/SemaTemplate/default-arguments.cpp
index f9bb44ecb9c..33677aab73a 100644
--- a/clang/test/SemaTemplate/default-arguments.cpp
+++ b/clang/test/SemaTemplate/default-arguments.cpp
@@ -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;
+};
OpenPOWER on IntegriCloud