[cfe-commits] r84119 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaTemplate/default-arguments.cpp
Douglas Gregor
dgregor at apple.com
Wed Oct 14 10:30:58 PDT 2009
Author: dgregor
Date: Wed Oct 14 12:30:58 2009
New Revision: 84119
URL: http://llvm.org/viewvc/llvm-project?rev=84119&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/default-arguments.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=84119&r1=84118&r2=84119&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Oct 14 12:30:58 2009
@@ -45,7 +45,7 @@
// 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();
Modified: cfe/trunk/test/SemaTemplate/default-arguments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments.cpp?rev=84119&r1=84118&r2=84119&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/default-arguments.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-arguments.cpp Wed Oct 14 12:30:58 2009
@@ -22,3 +22,23 @@
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;
+};
More information about the cfe-commits
mailing list