diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-09 17:25:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-09 17:25:05 +0000 |
commit | 1a4221cbe1912421ed7e29d0bbac39e9792af8a2 (patch) | |
tree | fbaa40c7340bf6478cf6e46ab8fcdb618469e67e | |
parent | 9f692a0308975cf24ef117c05e31284a1a944e86 (diff) |
Don't warn about unused static functions if they are marked with
attr constructor or destructor. Patch by Jean-Daniel Dupas!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100870 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | test/Sema/warn-unused-function.c | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 9d0d7ad133..7475ae4fbe 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3318,7 +3318,9 @@ 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->hasAttr<UnusedAttr>()) + && !NewFD->isUsed() && !NewFD->hasAttr<UnusedAttr>() + && !NewFD->hasAttr<ConstructorAttr>() + && !NewFD->hasAttr<DestructorAttr>()) UnusedStaticFuncs.push_back(NewFD); return NewFD; diff --git a/test/Sema/warn-unused-function.c b/test/Sema/warn-unused-function.c index 095532bcde..d5e676b116 100644 --- a/test/Sema/warn-unused-function.c +++ b/test/Sema/warn-unused-function.c @@ -30,3 +30,8 @@ static void f7(void) {} __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) { } |