]> granicus.if.org Git - clang/commitdiff
[Sema] Only define function as move assignment when needed
authorErik Pilkington <erik.pilkington@gmail.com>
Mon, 20 Jun 2016 20:04:15 +0000 (20:04 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Mon, 20 Jun 2016 20:04:15 +0000 (20:04 +0000)
Fixes PR27941, a crash on invalid.

Differential revision: http://reviews.llvm.org/D20923

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

lib/Sema/SemaExpr.cpp
test/SemaCXX/cxx0x-defaulted-functions.cpp

index 6f23115f02a897a9f06afbc70a2ef0d5c73f6043..3a33319c376895cf16adc880692894c7c71c2fb3 100644 (file)
@@ -13012,7 +13012,7 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
       if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
         if (MethodDecl->isCopyAssignmentOperator())
           DefineImplicitCopyAssignment(Loc, MethodDecl);
-        else
+        else if (MethodDecl->isMoveAssignmentOperator())
           DefineImplicitMoveAssignment(Loc, MethodDecl);
       }
     } else if (isa<CXXConversionDecl>(MethodDecl) &&
index 2aaf6197b64107ad5c985144ed3c524456b9e33a..16e20ff4964d8c3b786ece267b9a6d977fbe87ef 100644 (file)
@@ -196,3 +196,15 @@ namespace PR15597 {
   A<int> a;
   B<int> b; // expected-note {{here}}
 }
+
+namespace PR27941 {
+struct ExplicitBool {
+  ExplicitBool &operator=(bool) = default; // expected-error{{only special member functions may be defaulted}}
+  int member;
+};
+
+int fn() {
+  ExplicitBool t;
+  t = true;
+}
+}