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
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index c8e8ecd..6c25c27 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -7683,7 +7683,10 @@
}
// 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 5ae0cce..24d4fad 100644
--- a/test/Sema/warn-unused-function.c
+++ b/test/Sema/warn-unused-function.c
@@ -44,3 +44,6 @@
static void f12(void) { } // expected-warning{{unused}}
static void f12(void);
+
+// PR7923
+static void unused(void) { unused(); } // expected-warning{{unused}}