diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2013-06-19 22:43:55 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2013-06-19 22:43:55 +0000 |
commit | f26b81b62a0b43982c59b2ce6e4565a3f1c0fbf9 (patch) | |
tree | 0006d99f10a24e9d63924865087847d3f5cb8e04 /clang | |
parent | 30f93859a9ebf4b46c789a1bd2b600710b9b4fb9 (diff) | |
download | bcm5719-llvm-f26b81b62a0b43982c59b2ce6e4565a3f1c0fbf9.tar.gz bcm5719-llvm-f26b81b62a0b43982c59b2ce6e4565a3f1c0fbf9.zip |
Improve diagnostic for redeclaring static member function. Fixes PR16382.
llvm-svn: 184378
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/overload-decl.cpp | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index d9c5fe0af8a..43db2962a7e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/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/clang/test/SemaCXX/overload-decl.cpp b/clang/test/SemaCXX/overload-decl.cpp index 9bba47adfdd..0153620d45b 100644 --- a/clang/test/SemaCXX/overload-decl.cpp +++ b/clang/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}} |