[PATCH] D29877: Warn about unused static file scope function template declarations.

Marshall Clow via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 11 08:35:24 PDT 2017


mclow.lists added a comment.

Complete reproducer:

// Tested with with:  clang++ -std=c++14 -Wunused-function UnusedFVassily.cpp 
//
// UnusedFVassily.cpp:8:39: warning: unused function '__test' [-Wunused-function]
//     template <class _Up> static __two __test(...);
//                                       ^
// UnusedFVassily.cpp:9:38: warning: unused function '__test' [-Wunused-function]
//     template <class _Up> static char __test(typename _Up::pointer* = 0);
//                                      ^
// 2 warnings generated.

#include <type_traits>

namespace foo {

struct __two {char __lx; char __lxx;};
namespace __has_pointer_type_imp
{

  template <class _Up> static __two __test(...);
  template <class _Up> static char __test(typename _Up::pointer* = 0);

}

template <class _Tp>
struct __has_pointer_type

  : public std::integral_constant<bool, sizeof(__has_pointer_type_imp::__test<_Tp>(0)) == 1>

{
};

}

struct S1 {};
struct S2 { typedef void *pointer; };

int main () {
	static_assert (!foo::__has_pointer_type<S1>::value, "" );
	static_assert ( foo::__has_pointer_type<S2>::value, "" );
}


https://reviews.llvm.org/D29877





More information about the cfe-commits mailing list