diff options
| -rw-r--r-- | clang/lib/Sema/Sema.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-func-not-needed.cpp | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index e195bbfff33..e444f3c3570 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -328,7 +328,7 @@ CastKind Sema::ScalarTypeToBooleanCastKind(QualType ScalarTy) { /// \brief Used to prune the decls of Sema's UnusedFileScopedDecls vector. static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) { - if (D->isUsed()) + if (D->getMostRecentDecl()->isUsed()) return true; if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { diff --git a/clang/test/SemaCXX/warn-func-not-needed.cpp b/clang/test/SemaCXX/warn-func-not-needed.cpp new file mode 100644 index 00000000000..437a428664f --- /dev/null +++ b/clang/test/SemaCXX/warn-func-not-needed.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s + +namespace test1 { + static void f() {} // expected-warning {{is not needed and will not be emitted}} + static void f(); + template <typename T> + void foo() { + f(); + } +} + +namespace test2 { + static void f() {} + static void f(); + static void g() { f(); } + void h() { g(); } +} |

