summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2015-07-28 19:06:16 +0000
committerRichard Trieu <rtrieu@google.com>2015-07-28 19:06:16 +0000
commit8d4006a079532acb230f9bb3c1a0b2f07728a646 (patch)
tree893d2c7019f111740c291e0857a4d17ba4d90ab0 /clang/lib/Sema
parent7227cc1a48b64ceaad888495e7b9a4f3e4360316 (diff)
downloadbcm5719-llvm-8d4006a079532acb230f9bb3c1a0b2f07728a646.tar.gz
bcm5719-llvm-8d4006a079532acb230f9bb3c1a0b2f07728a646.zip
Do not give a -Wredundant-move warning when removing the move will result in an
error. If the object being moved has a move constructor and a deleted copy constructor, std::move is required, otherwise Clang will give a deleted constructor error. llvm-svn: 243463
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaInit.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index ed569635848..fd067775aca 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -5983,9 +5983,19 @@ static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr,
if (!VD || !VD->hasLocalStorage())
return;
- if (!VD->getType()->isRecordType())
+ QualType SourceType = VD->getType();
+ if (!SourceType->isRecordType())
return;
+ if (!S.Context.hasSameUnqualifiedType(DestType, SourceType)) {
+ if (CXXRecordDecl *RD = SourceType->getAsCXXRecordDecl()) {
+ for (auto* Construct : RD->ctors()) {
+ if (Construct->isCopyConstructor() && Construct->isDeleted())
+ return;
+ }
+ }
+ }
+
// If we're returning a function parameter, copy elision
// is not possible.
if (isa<ParmVarDecl>(VD))
OpenPOWER on IntegriCloud