Store on the CXXRecordDecl whether the class has, or would have, a copy
constructor/assignment operator with a const-qualified parameter type. The
prior method for determining this incorrectly used overload resolution.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168775 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CXX/special/class.copy/p18-cxx11.cpp b/test/CXX/special/class.copy/p18-cxx11.cpp
new file mode 100644
index 0000000..7b09dd6
--- /dev/null
+++ b/test/CXX/special/class.copy/p18-cxx11.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+// expected-no-diagnostics
+
+// C++98 [class.copy]p10 / C++11 [class.copy]p18.
+
+// The implicitly-declared copy assignment operator for a class X will have the form
+//   X& X::operator=(const X&)
+// if [every direct subobject] has a copy assignment operator whose first parameter is
+// of type 'const volatile[opt] T &' or 'T'. Otherwise, it will have the form
+//   X &X::operator=(X&)
+
+struct ConstCopy {
+  ConstCopy &operator=(const ConstCopy &);
+};
+
+struct NonConstCopy {
+  NonConstCopy &operator=(NonConstCopy &);
+};
+
+struct DeletedConstCopy {
+  DeletedConstCopy &operator=(const DeletedConstCopy &) = delete;
+};
+
+struct DeletedNonConstCopy {
+  DeletedNonConstCopy &operator=(DeletedNonConstCopy &) = delete;
+};
+
+struct ImplicitlyDeletedConstCopy {
+  ImplicitlyDeletedConstCopy &operator=(ImplicitlyDeletedConstCopy &&);
+};
+
+struct ByValueCopy {
+  ByValueCopy &operator=(ByValueCopy);
+};
+
+struct AmbiguousConstCopy {
+  AmbiguousConstCopy &operator=(const AmbiguousConstCopy&);
+  AmbiguousConstCopy &operator=(AmbiguousConstCopy);
+};
+
+
+struct A : ConstCopy {};
+struct B : NonConstCopy { ConstCopy a; };
+struct C : ConstCopy { NonConstCopy a; };
+struct D : DeletedConstCopy {};
+struct E : DeletedNonConstCopy {};
+struct F { ImplicitlyDeletedConstCopy a; };
+struct G : virtual B {};
+struct H : ByValueCopy {};
+struct I : AmbiguousConstCopy {};
+
+struct Test {
+  friend A &A::operator=(const A &);
+  friend B &B::operator=(B &);
+  friend C &C::operator=(C &);
+  friend D &D::operator=(const D &);
+  friend E &E::operator=(E &);
+  friend F &F::operator=(const F &);
+  friend G &G::operator=(G &);
+  friend H &H::operator=(const H &);
+  friend I &I::operator=(const I &);
+};
diff --git a/test/PCH/Inputs/cxx-method.h b/test/PCH/Inputs/cxx-method.h
index 6adb859..d5d56fe 100644
--- a/test/PCH/Inputs/cxx-method.h
+++ b/test/PCH/Inputs/cxx-method.h
@@ -1,6 +1,9 @@
 struct S {
   void m(int x);
 
+  S();
+  S(const S&);
+
   operator const char*();
   operator char*();
 };
diff --git a/test/PCH/cxx-method.cpp b/test/PCH/cxx-method.cpp
index 40490ea..c24ad92 100644
--- a/test/PCH/cxx-method.cpp
+++ b/test/PCH/cxx-method.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -x c++ -include %S/Inputs/cxx-method.h -verify %s
 // RUN: %clang_cc1 -x c++ -emit-pch %S/Inputs/cxx-method.h -o %t
 // RUN: %clang_cc1 -include-pch %t -verify %s
 // expected-no-diagnostics
@@ -7,3 +8,8 @@
 S::operator char *() { return 0; }
 
 S::operator const char *() { return 0; }
+
+struct T : S {};
+
+const T a = T();
+T b(a);