From: Douglas Gregor Date: Fri, 30 Oct 2009 22:48:49 +0000 (+0000) Subject: When looking for a copy-assignment operator to determine the cv-qualifiers on its... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=682054c52e8e7ebd7280e13d2cb26f8a9a17485a;p=clang When looking for a copy-assignment operator to determine the cv-qualifiers on its argument type, ignore assignment operator templates git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85629 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 2e3bbce9e4..b4c0c59733 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -189,7 +189,10 @@ bool CXXRecordDecl::hasConstCopyAssignment(ASTContext &Context, // 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(*Op); + const CXXMethodDecl* Method = dyn_cast(*Op); + if (!Method) + continue; + if (Method->isStatic()) continue; if (Method->getPrimaryTemplate()) diff --git a/test/SemaTemplate/copy-ctor-assign.cpp b/test/SemaTemplate/copy-ctor-assign.cpp index 90fb0133a7..69481ea557 100644 --- a/test/SemaTemplate/copy-ctor-assign.cpp +++ b/test/SemaTemplate/copy-ctor-assign.cpp @@ -33,4 +33,20 @@ void test3(X &x, X xi, X xl, X xmptr) { x = xi; x = xl; x = xmptr; // expected-note{{instantiation}} -} \ No newline at end of file +} + +struct X1 { + X1 &operator=(const X1&); +}; + +template +struct X2 : X1 { + template X2 &operator=(const U&); +}; + +struct X3 : X2 { +}; + +void test_X2(X3 &to, X3 from) { + to = from; +}