Sent from my iPhone
On Dec 25, 2012, at 2:48 AM, Rafael Espíndola <[email protected]> wrote: > On 24 December 2012 17:12, Rafael Ávila de Espíndola > <[email protected]> wrote: >> This fixes pr14691, which I think is a regression from r168519. >> >> Let me know if you think we should mark all previous decls instead, but as >> far as I can tell we only ever look at the current or at the first decl. > > Now that I think of it, it is probably best to just change > ShouldRemoveFromUnused. The attached patch does that. Do we propagate the used bit to redeclarations? If not, we should. I like this version a lot better. > >> --- >> lib/Sema/SemaExpr.cpp | 5 +++++ >> test/SemaCXX/warn-func-not-needed.cpp | 17 +++++++++++++++++ >> 2 files changed, 22 insertions(+) >> create mode 100644 test/SemaCXX/warn-func-not-needed.cpp >> >> diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp >> index 191a26d..a5dd1dc 100644 >> --- a/lib/Sema/SemaExpr.cpp >> +++ b/lib/Sema/SemaExpr.cpp >> @@ -10497,6 +10497,11 @@ void Sema::MarkFunctionReferenced(SourceLocation >> Loc, FunctionDecl *Func) { >> } >> >> Func->setUsed(true); >> + >> + // We use the first declaration to keep track of unused global >> declarations >> + // (see UnusedFileScopedDecls), so mark it used too. >> + FunctionDecl *First = Func->getFirstDeclaration(); >> + First->setUsed(true); >> } >> >> static void >> diff --git a/test/SemaCXX/warn-func-not-needed.cpp >> b/test/SemaCXX/warn-func-not-needed.cpp >> new file mode 100644 >> index 0000000..437a428 >> --- /dev/null >> +++ b/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(); } >> +} >> -- >> 1.7.11.7 > <t.patch> _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
