[cfe-commits] r90753 - in /cfe/trunk: lib/AST/RecordLayoutBuilder.cpp test/SemaTemplate/virtual-member-functions.cpp
Anders Carlsson
andersca at mac.com
Mon Dec 7 00:29:39 PST 2009
Author: andersca
Date: Mon Dec 7 02:29:39 2009
New Revision: 90753
URL: http://llvm.org/viewvc/llvm-project?rev=90753&view=rev
Log:
Instantiated or specialized class templates never have a key function. This (and the previous check-in) fixes PR5557.
Added:
cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=90753&r1=90752&r2=90753&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Mon Dec 7 02:29:39 2009
@@ -720,6 +720,11 @@
if (!RD->isPolymorphic())
return 0;
+ // A class template specialization or instantation does not have a key
+ // function.
+ if (RD->getTemplateSpecializationKind() != TSK_Undeclared)
+ return 0;
+
for (CXXRecordDecl::method_iterator I = RD->method_begin(),
E = RD->method_end(); I != E; ++I) {
const CXXMethodDecl *MD = *I;
Added: cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp?rev=90753&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp (added)
+++ cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp Mon Dec 7 02:29:39 2009
@@ -0,0 +1,22 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+namespace PR5557 {
+template <class T> struct A {
+ A();
+ virtual int a(T x);
+};
+template<class T> A<T>::A() {}
+template<class T> int A<T>::a(T x) {
+ return *x; // expected-error{{requires pointer operand}}
+}
+
+A<int> x; // expected-note{{instantiation}}
+
+template<typename T>
+struct X {
+ virtual void f();
+};
+
+template<>
+void X<int>::f() { }
+}
More information about the cfe-commits
mailing list