forked from OSchip/llvm-project
Fix crash on zero-argument assignment operator.
Make sure we don't crash when checking whether an assignment operator without any arguments is a special member. <rdar://problem/14397774>. llvm-svn: 186137
This commit is contained in:
parent
6d8a38c537
commit
84c0143ea0
|
@ -1406,7 +1406,8 @@ bool CXXMethodDecl::isCopyAssignmentOperator() const {
|
|||
// type X, X&, const X&, volatile X& or const volatile X&.
|
||||
if (/*operator=*/getOverloadedOperator() != OO_Equal ||
|
||||
/*non-static*/ isStatic() ||
|
||||
/*non-template*/getPrimaryTemplate() || getDescribedFunctionTemplate())
|
||||
/*non-template*/getPrimaryTemplate() || getDescribedFunctionTemplate() ||
|
||||
getNumParams() != 1)
|
||||
return false;
|
||||
|
||||
QualType ParamType = getParamDecl(0)->getType();
|
||||
|
@ -1425,7 +1426,8 @@ bool CXXMethodDecl::isMoveAssignmentOperator() const {
|
|||
// non-template member function of class X with exactly one parameter of type
|
||||
// X&&, const X&&, volatile X&&, or const volatile X&&.
|
||||
if (getOverloadedOperator() != OO_Equal || isStatic() ||
|
||||
getPrimaryTemplate() || getDescribedFunctionTemplate())
|
||||
getPrimaryTemplate() || getDescribedFunctionTemplate() ||
|
||||
getNumParams() != 1)
|
||||
return false;
|
||||
|
||||
QualType ParamType = getParamDecl(0)->getType();
|
||||
|
|
|
@ -11535,6 +11535,7 @@ void Sema::SetDeclDefaulted(Decl *Dcl, SourceLocation DefaultLoc) {
|
|||
|
||||
CXXSpecialMember Member = getSpecialMember(MD);
|
||||
if (Member == CXXInvalid) {
|
||||
if (!MD->isInvalidDecl())
|
||||
Diag(DefaultLoc, diag::err_default_special_members);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
|
||||
class X { };
|
||||
|
||||
X operator+(X, X);
|
||||
|
@ -441,3 +441,7 @@ namespace test10 {
|
|||
a[bar<float>];
|
||||
}
|
||||
}
|
||||
|
||||
struct InvalidOperatorEquals {
|
||||
InvalidOperatorEquals operator=() = delete; // expected-error {{overloaded 'operator=' must be a binary operator}}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue