]> granicus.if.org Git - clang/commitdiff
When adding the base and member initializers for an implicitly-defined
authorDouglas Gregor <dgregor@apple.com>
Wed, 10 Aug 2011 16:51:53 +0000 (16:51 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 10 Aug 2011 16:51:53 +0000 (16:51 +0000)
special member function, make sure to classify an explicitly-defaulted
copy constructor as a "copy" operation. Fixes PR10622.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137219 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/CXX/special/class.copy/p15-0x.cpp [new file with mode: 0644]

index b5b7a314f000156ec24f2c527efc1f21d2b43d85..05706d7d425662f3fc6d2fa6d31fe899a9029d18 100644 (file)
@@ -2155,7 +2155,8 @@ struct BaseAndFieldInfo {
   BaseAndFieldInfo(Sema &S, CXXConstructorDecl *Ctor, bool ErrorsInInits)
     : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
     // FIXME: Handle implicit move constructors.
-    if (Ctor->isImplicit() && Ctor->isCopyConstructor())
+    if ((Ctor->isImplicit() || Ctor->isDefaulted()) && 
+        Ctor->isCopyConstructor())
       IIK = IIK_Copy;
     else
       IIK = IIK_Default;
diff --git a/test/CXX/special/class.copy/p15-0x.cpp b/test/CXX/special/class.copy/p15-0x.cpp
new file mode 100644 (file)
index 0000000..42c83d5
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s
+
+namespace PR10622 {
+  struct foo {
+    const int first;
+    foo(const foo&) = default;
+  };
+  void find_or_insert(const foo& __obj) {
+    foo x(__obj);
+  }
+}