]> granicus.if.org Git - clang/commitdiff
When looking for a copy-assignment operator to determine the cv-qualifiers on its...
authorDouglas Gregor <dgregor@apple.com>
Fri, 30 Oct 2009 22:48:49 +0000 (22:48 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 30 Oct 2009 22:48:49 +0000 (22:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85629 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp
test/SemaTemplate/copy-ctor-assign.cpp

index 2e3bbce9e42ff7f8ebb7938aa9204dabb5af7044..b4c0c59733e53087a8fa5abc24bf023a78aaad0c 100644 (file)
@@ -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<CXXMethodDecl>(*Op);
+    const CXXMethodDecl* Method = dyn_cast<CXXMethodDecl>(*Op);
+    if (!Method)
+      continue;
+
     if (Method->isStatic())
       continue;
     if (Method->getPrimaryTemplate())
index 90fb0133a7217c72fca6b5ca8e07bec408f8a1a6..69481ea557f452e8837d34c3f732e8b866369457 100644 (file)
@@ -33,4 +33,20 @@ void test3(X<int> &x, X<int> xi, X<long> xl, X<int Y::*> xmptr) {
   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;
+}