aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-25 10:34:54 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-25 10:34:54 +0000
commit58b5259e959f42823cc93f66da1499723eae366c (patch)
tree7007ee7c58f8475124c85c98c3eb0db61aa2d05f
parent5baba9d98364a3525d6afa15a04cdad82fd6dd30 (diff)
Recursive functions should be marked when used from another function. Fixes http://llvm.org/PR7923.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112045 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp5
-rw-r--r--test/Sema/warn-unused-function.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index c8e8ecda86..6c25c272f3 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -7683,7 +7683,10 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) {
}
// FIXME: keep track of references to static functions
- Function->setUsed(true);
+
+ // Recursive functions should be marked when used from another function.
+ if (CurContext != Function)
+ Function->setUsed(true);
return;
}
diff --git a/test/Sema/warn-unused-function.c b/test/Sema/warn-unused-function.c
index 5ae0cce079..24d4fade9b 100644
--- a/test/Sema/warn-unused-function.c
+++ b/test/Sema/warn-unused-function.c
@@ -44,3 +44,6 @@ static void f11(void) { } // expected-warning{{unused}}
static void f12(void) { } // expected-warning{{unused}}
static void f12(void);
+
+// PR7923
+static void unused(void) { unused(); } // expected-warning{{unused}}