[cfe-commits] r171077 - in /cfe/trunk: lib/Sema/Sema.cpp test/SemaCXX/warn-func-not-needed.cpp
Rafael Espindola
rafael.espindola at gmail.com
Tue Dec 25 16:13:29 PST 2012
Author: rafael
Date: Tue Dec 25 18:13:29 2012
New Revision: 171077
URL: http://llvm.org/viewvc/llvm-project?rev=171077&view=rev
Log:
Use the most recent redecl to decide if it is needed.
This fixes pr14691, which I think is a regression from r168519.
Added:
cfe/trunk/test/SemaCXX/warn-func-not-needed.cpp
Modified:
cfe/trunk/lib/Sema/Sema.cpp
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=171077&r1=171076&r2=171077&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Dec 25 18:13:29 2012
@@ -328,7 +328,7 @@
/// \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)) {
Added: cfe/trunk/test/SemaCXX/warn-func-not-needed.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-func-not-needed.cpp?rev=171077&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-func-not-needed.cpp (added)
+++ cfe/trunk/test/SemaCXX/warn-func-not-needed.cpp Tue Dec 25 18:13:29 2012
@@ -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(); }
+}
More information about the cfe-commits
mailing list