Author: efriedma
Date: Wed Jun 19 17:43:55 2013
New Revision: 184378

URL: http://llvm.org/viewvc/llvm-project?rev=184378&view=rev
Log:
Improve diagnostic for redeclaring static member function.  Fixes PR16382.


Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/overload-decl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=184378&r1=184377&r2=184378&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jun 19 17:43:55 2013
@@ -2499,7 +2499,7 @@ bool Sema::MergeFunctionDecl(FunctionDec
         //    -- 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;

Modified: cfe/trunk/test/SemaCXX/overload-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-decl.cpp?rev=184378&r1=184377&r2=184378&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/overload-decl.cpp (original)
+++ cfe/trunk/test/SemaCXX/overload-decl.cpp Wed Jun 19 17:43:55 2013
@@ -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}}


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to