]> granicus.if.org Git - clang/commitdiff
Use the location of the copy assignment when diagnosing classes that are nontrivial...
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 30 Jul 2012 16:41:40 +0000 (16:41 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 30 Jul 2012 16:41:40 +0000 (16:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160962 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/cxx98-compat.cpp

index 81b94a4ecdd35a65ab4796cadfdd8dc0fd2b18a6..6dfd796f40bf88f177e6ee649f4ee91eb5eebae5 100644 (file)
@@ -9513,10 +9513,9 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) {
 
   case CXXCopyAssignment:
     if (RD->hasUserDeclaredCopyAssignment()) {
-      // FIXME: this should use the location of the copy
-      // assignment, not the type.
-      SourceLocation TyLoc = RD->getLocStart();
-      Diag(TyLoc, diag::note_nontrivial_user_defined) << QT << member;
+      SourceLocation AssignLoc =
+        RD->getCopyAssignmentOperator(0)->getLocation();
+      Diag(AssignLoc, diag::note_nontrivial_user_defined) << QT << member;
       return;
     }
     break;
index 9bd854a6645a32e31bb6c8aca75f0efe3c6c9623..37341f8856190d82d6c43ea31dcff8c5bf0d4126 100644 (file)
@@ -346,3 +346,19 @@ namespace PR13480 {
     basic_iterator it; // expected-warning {{union member 'it' with a non-trivial copy constructor is incompatible with C++98}}
   };
 }
+
+namespace AssignOpUnion {
+  struct a {
+    void operator=(const a &it) {}
+    void operator=(a &it) {} // expected-note {{because type 'AssignOpUnion::a' has a user-declared copy assignment operator}}
+  };
+
+  struct b {
+    void operator=(const b &it) {} // expected-note {{because type 'AssignOpUnion::b' has a user-declared copy assignment operator}}
+  };
+
+  union test1 {
+    a x; // expected-warning {{union member 'x' with a non-trivial copy assignment operator is incompatible with C++98}}
+    b y; // expected-warning {{union member 'y' with a non-trivial copy assignment operator is incompatible with C++98}}
+  };
+}