[cfe-commits] r85629 - in /cfe/trunk: lib/AST/DeclCXX.cpp test/SemaTemplate/copy-ctor-assign.cpp
Douglas Gregor
dgregor at apple.com
Fri Oct 30 15:48:50 PDT 2009
Author: dgregor
Date: Fri Oct 30 17:48:49 2009
New Revision: 85629
URL: http://llvm.org/viewvc/llvm-project?rev=85629&view=rev
Log:
When looking for a copy-assignment operator to determine the cv-qualifiers on its argument type, ignore assignment operator templates
Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/SemaTemplate/copy-ctor-assign.cpp
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=85629&r1=85628&r2=85629&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Oct 30 17:48:49 2009
@@ -189,7 +189,10 @@
// A user-declared copy assignment operator is a non-static non-template
// member function of class X with exactly one parameter of type X, X&,
// const X&, volatile X& or const volatile X&.
- const CXXMethodDecl* Method = cast<CXXMethodDecl>(*Op);
+ const CXXMethodDecl* Method = dyn_cast<CXXMethodDecl>(*Op);
+ if (!Method)
+ continue;
+
if (Method->isStatic())
continue;
if (Method->getPrimaryTemplate())
Modified: cfe/trunk/test/SemaTemplate/copy-ctor-assign.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/copy-ctor-assign.cpp?rev=85629&r1=85628&r2=85629&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/copy-ctor-assign.cpp (original)
+++ cfe/trunk/test/SemaTemplate/copy-ctor-assign.cpp Fri Oct 30 17:48:49 2009
@@ -33,4 +33,20 @@
x = xi;
x = xl;
x = xmptr; // expected-note{{instantiation}}
-}
\ No newline at end of file
+}
+
+struct X1 {
+ X1 &operator=(const X1&);
+};
+
+template<typename T>
+struct X2 : X1 {
+ template<typename U> X2 &operator=(const U&);
+};
+
+struct X3 : X2<int> {
+};
+
+void test_X2(X3 &to, X3 from) {
+ to = from;
+}
More information about the cfe-commits
mailing list