[cfe-commits] r100870 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/warn-unused-function.c
Chris Lattner
sabre at nondot.org
Fri Apr 9 10:25:06 PDT 2010
Author: lattner
Date: Fri Apr 9 12:25:05 2010
New Revision: 100870
URL: http://llvm.org/viewvc/llvm-project?rev=100870&view=rev
Log:
Don't warn about unused static functions if they are marked with
attr constructor or destructor. Patch by Jean-Daniel Dupas!
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/warn-unused-function.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=100870&r1=100869&r2=100870&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Apr 9 12:25:05 2010
@@ -3318,7 +3318,9 @@
// FIXME: Also include static functions declared but not defined.
if (!NewFD->isInvalidDecl() && IsFunctionDefinition
&& !NewFD->isInlined() && NewFD->getLinkage() == InternalLinkage
- && !NewFD->isUsed() && !NewFD->hasAttr<UnusedAttr>())
+ && !NewFD->isUsed() && !NewFD->hasAttr<UnusedAttr>()
+ && !NewFD->hasAttr<ConstructorAttr>()
+ && !NewFD->hasAttr<DestructorAttr>())
UnusedStaticFuncs.push_back(NewFD);
return NewFD;
Modified: cfe/trunk/test/Sema/warn-unused-function.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-unused-function.c?rev=100870&r1=100869&r2=100870&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-unused-function.c (original)
+++ cfe/trunk/test/Sema/warn-unused-function.c Fri Apr 9 12:25:05 2010
@@ -30,3 +30,8 @@
__attribute__((unused)) static void bar(void);
void bar(void) { }
+__attribute__((constructor)) static void bar2(void);
+void bar2(void) { }
+
+__attribute__((destructor)) static void bar3(void);
+void bar3(void) { }
More information about the cfe-commits
mailing list