aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/Sema.cpp15
-rw-r--r--test/SemaCXX/unused-functions.cpp8
2 files changed, 15 insertions, 8 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index ccfbe1e00a..2bb1ed8ce9 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -197,14 +197,7 @@ void Sema::DeleteStmt(StmtTy *S) {
/// ActOnEndOfTranslationUnit - This is called at the very end of the
/// translation unit when EOF is reached and all but the top-level scope is
/// popped.
-void Sema::ActOnEndOfTranslationUnit() {
-
- // Remove functions that turned out to be used.
- UnusedStaticFuncs.erase(std::remove_if(UnusedStaticFuncs.begin(),
- UnusedStaticFuncs.end(),
- std::mem_fun(&FunctionDecl::isUsed)),
- UnusedStaticFuncs.end());
-
+void Sema::ActOnEndOfTranslationUnit() {
while (1) {
// C++: Perform implicit template instantiations.
//
@@ -225,6 +218,12 @@ void Sema::ActOnEndOfTranslationUnit() {
break;
}
+ // Remove functions that turned out to be used.
+ UnusedStaticFuncs.erase(std::remove_if(UnusedStaticFuncs.begin(),
+ UnusedStaticFuncs.end(),
+ std::mem_fun(&FunctionDecl::isUsed)),
+ UnusedStaticFuncs.end());
+
// Check for #pragma weak identifiers that were never declared
// FIXME: This will cause diagnostics to be emitted in a non-determinstic
// order! Iterating over a densemap like this is bad.
diff --git a/test/SemaCXX/unused-functions.cpp b/test/SemaCXX/unused-functions.cpp
new file mode 100644
index 0000000000..cefa9e118a
--- /dev/null
+++ b/test/SemaCXX/unused-functions.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused -verify %s
+
+static int foo(int x) { return x; }
+
+template<typename T>
+T get_from_foo(T y) { return foo(y); }
+
+int g(int z) { return get_from_foo(z); }