From: Tanya Lattner Date: Wed, 17 Feb 2010 04:48:01 +0000 (+0000) Subject: Do not add functions marked with the unused attribute to the list of unused functions... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c777221d22e2687938c061de6698ddcccbe00fdc;p=clang Do not add functions marked with the unused attribute to the list of unused functions to warn about. Update test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96452 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 1fc08ce031..3821113439 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3135,7 +3135,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // FIXME: Also include static functions declared but not defined. if (!NewFD->isInvalidDecl() && IsFunctionDefinition && !NewFD->isInlined() && NewFD->getLinkage() == InternalLinkage - && !NewFD->isUsed()) + && !NewFD->isUsed() && !NewFD->hasAttr()) UnusedStaticFuncs.push_back(NewFD); return NewFD; diff --git a/test/Sema/warn-unused-function.c b/test/Sema/warn-unused-function.c index 1a2a50e1aa..b52f676ac5 100644 --- a/test/Sema/warn-unused-function.c +++ b/test/Sema/warn-unused-function.c @@ -24,3 +24,7 @@ static void f7(void); void f8(void(*a0)(void)); void f9(void) { f8(f7); } static void f7(void) {} + +__attribute__((unused)) static void bar(void); +void bar(void) { } +