forked from OSchip/llvm-project
Use the location of the copy assignment when diagnosing classes that are nontrivial because of it.
llvm-svn: 160962
This commit is contained in:
parent
bc7dd9ea02
commit
e3895eb050
|
@ -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;
|
||||
|
|
|
@ -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}}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue