]> granicus.if.org Git - clang/commitdiff
Improve diagnostic for redeclaring static member function. Fixes PR16382.
authorEli Friedman <eli.friedman@gmail.com>
Wed, 19 Jun 2013 22:43:55 +0000 (22:43 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Wed, 19 Jun 2013 22:43:55 +0000 (22:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184378 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/overload-decl.cpp

index d9c5fe0af8ac883fe7d9d689e8ce276f7f88d06b..43db2962a7e978486e2e24048e3618c7ad51a0df 100644 (file)
@@ -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;
index 9bba47adfddaa628622be5bcfdc372f35c01ea7b..0153620d45b9b2542e8017154f2a454e1de25666 100644 (file)
@@ -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}}