forked from OSchip/llvm-project
Improve diagnostic for redeclaring static member function. Fixes PR16382.
llvm-svn: 184378
This commit is contained in:
parent
30f93859a9
commit
f26b81b62a
|
@ -2499,7 +2499,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S) {
|
|||
// -- Member function declarations with the same name and the
|
||||
// same parameter types cannot be overloaded if any of them
|
||||
// is a static member function declaration.
|
||||
if (OldMethod->isStatic() || NewMethod->isStatic()) {
|
||||
if (OldMethod->isStatic() != NewMethod->isStatic()) {
|
||||
Diag(New->getLocation(), diag::err_ovl_static_nonstatic_member);
|
||||
Diag(Old->getLocation(), PrevDiag) << Old << Old->getType();
|
||||
return true;
|
||||
|
|
|
@ -26,8 +26,9 @@ class X {
|
|||
void g(int, float); // expected-note {{previous declaration is here}}
|
||||
int g(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}}
|
||||
|
||||
static void g(float);
|
||||
static void g(float); // expected-note {{previous declaration is here}}
|
||||
static void g(int); // expected-error {{static and non-static member functions with the same parameter types cannot be overloaded}}
|
||||
static void g(float); // expected-error {{class member cannot be redeclared}}
|
||||
};
|
||||
|
||||
int main() {} // expected-note {{previous definition is here}}
|
||||
|
|
Loading…
Reference in New Issue