llvm-capstone/clang/test/SemaCXX/warn-func-not-needed.cpp
Rafael Espindola 77c60085af Consider hidden decls for isUsed checks.
This fixes pr17624.

A FIXME from Richard Smith:

It seems to me that the root cause is that a per-Decl 'used' flag doesn't
really make much sense in the way we use it now. I think we should either track
whether that particular declaration is used (with isUsed scanning the entire
redecl chain), or we should only have one flag for the entire redeclaration
chain (perhaps by always looking at the flag on either the most recent decl or
the canonical decl). Modeling it as "is this declaration or any previous
declaration used" is weird, and requires contortions like the loop at the end
of Sema::MarkFunctionReferenced.

llvm-svn: 193202
2013-10-22 21:56:29 +00:00

54 lines
769 B
C++

// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
namespace test1 {
static void f() {} // expected-warning {{is not needed and will not be emitted}}
static void f();
template <typename T>
void foo() {
f();
}
}
namespace test2 {
static void f() {}
static void f();
static void g() { f(); }
void h() { g(); }
}
namespace test3 {
static void f();
template<typename T>
static void g() {
f();
}
static void f() {
}
void h() {
g<int>();
}
}
namespace test4 {
static void f();
static void f();
template<typename T>
static void g() {
f();
}
static void f() {
}
void h() {
g<int>();
}
}
namespace test4 {
static void func();
void bar() {
void func();
func();
}
static void func() {}
}