]> granicus.if.org Git - clang/commitdiff
Do not add functions marked with the unused attribute to the list of unused functions...
authorTanya Lattner <tonic@nondot.org>
Wed, 17 Feb 2010 04:48:01 +0000 (04:48 +0000)
committerTanya Lattner <tonic@nondot.org>
Wed, 17 Feb 2010 04:48:01 +0000 (04:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96452 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/warn-unused-function.c

index 1fc08ce03197e66a68063e5a60f704987356e0ba..38211134393058d2fc6d2496b6d34513062289a8 100644 (file)
@@ -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<UnusedAttr>())
     UnusedStaticFuncs.push_back(NewFD);
   
   return NewFD;
index 1a2a50e1aa08a0988601704af76104fd76273de8..b52f676ac58a431b2457f70e3f47850f4d22fd1f 100644 (file)
@@ -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) { }
+