From fa0d3f815e6de3f5129572b179b8027c4a3eecde Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 19 Jun 2013 22:43:55 +0000 Subject: [PATCH] Improve diagnostic for redeclaring static member function. Fixes PR16382. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184378 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 2 +- test/SemaCXX/overload-decl.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d9c5fe0af8..43db2962a7 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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; diff --git a/test/SemaCXX/overload-decl.cpp b/test/SemaCXX/overload-decl.cpp index 9bba47adfd..0153620d45 100644 --- a/test/SemaCXX/overload-decl.cpp +++ b/test/SemaCXX/overload-decl.cpp @@ -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}} -- 2.40.0