aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/warn-unused-function.c
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-04-19 19:51:10 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-04-19 19:51:10 +0000
commit6b6b42aed07726178f61954ac6e51f47da00275c (patch)
treedc03f21bd2fd89c3f94984cc3ee9d1713dfcea4e /test/Sema/warn-unused-function.c
parent1c860d5640e8eebb11a5d515a761242b66761b0b (diff)
We regard a function as 'unused' from the codegen perspective, so our warnings diverge from
gcc's unused warnings which don't get emitted if the function is referenced even in an unevaluated context (e.g. in templates, sizeof, etc.). Also, saying that a function is 'unused' because it won't get codegen'ed is somewhat misleading. - Don't emit 'unused' warnings for functions that are referenced in any part of the user's code. - A warning that an internal function/variable won't get emitted is useful though, so introduce -Wunneeded-internal-declaration which will warn if a function/variable with internal linkage is not "needed" ('used' from the codegen perspective), e.g: static void foo() { } template <int> void bar() { foo(); } test.cpp:1:13: warning: function 'foo' is not needed and will not be emitted static void foo() { } ^ Addresses rdar://8733476. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129794 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/warn-unused-function.c')
-rw-r--r--test/Sema/warn-unused-function.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/Sema/warn-unused-function.c b/test/Sema/warn-unused-function.c
index 5bbcf18a62..8f4cdcba88 100644
--- a/test/Sema/warn-unused-function.c
+++ b/test/Sema/warn-unused-function.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused-function -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-function -Wunneeded-internal-declaration -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
@@ -6,7 +6,7 @@ void foo() {}
static void f2() {}
static void f1() {f2();} // expected-warning{{unused}}
-static int f0() { return 17; } // expected-warning{{unused}}
+static int f0() { return 17; } // expected-warning{{not needed and will not be emitted}}
int x = sizeof(f0());
static void f3();
@@ -46,7 +46,7 @@ static void f12(void) { } // expected-warning{{unused}}
static void f12(void);
// PR7923
-static void unused(void) { unused(); } // expected-warning{{unused}}
+static void unused(void) { unused(); } // expected-warning{{not needed and will not be emitted}}
// rdar://8728293
static void cleanupMalloc(char * const * const allocation) { }