From: Douglas Gregor Date: Wed, 10 Aug 2011 16:51:53 +0000 (+0000) Subject: When adding the base and member initializers for an implicitly-defined X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=136da1c4320156fe8924139f58fbeed2e32cc6e8;p=clang When adding the base and member initializers for an implicitly-defined 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 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index b5b7a314f0..05706d7d42 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -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 index 0000000000..42c83d5b4e --- /dev/null +++ b/test/CXX/special/class.copy/p15-0x.cpp @@ -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); + } +}