contexts. This prevents -Wunused-function from firing on friend function
definitions inside of class templates for example.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122763
91177308-0d34-0410-b5e6-
96231b3b80d8
return false;
// Ignore class templates.
- if (D->getDeclContext()->isDependentContext())
+ if (D->getDeclContext()->isDependentContext() ||
+ D->getLexicalDeclContext()->isDependentContext())
return false;
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
};
template <> int TS2<int>::x; // expected-warning{{unused}}
}
+
+namespace PR8841 {
+ // Ensure that friends of class templates are considered to have a dependent
+ // context and not marked unused.
+ namespace {
+ template <typename T> struct X {
+ friend bool operator==(const X&, const X&) { return false; }
+ };
+ }
+ template <typename T> void template_test(X<T> x) {
+ (void)(x == x);
+ }
+ void test(X<int> x) {
+ template_test(x);
+ }
+}