xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/warn-unused-parameters.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify -std=c++11 %s
2*f4a2713aSLionel Sambuc template<typename T>
3*f4a2713aSLionel Sambuc struct X {
4*f4a2713aSLionel Sambuc   T f0(T x);
5*f4a2713aSLionel Sambuc   T f1(T x);
6*f4a2713aSLionel Sambuc   T f2(T);
7*f4a2713aSLionel Sambuc   template<typename U> U f3(U x);
8*f4a2713aSLionel Sambuc   template<typename U> U f4(U x);
9*f4a2713aSLionel Sambuc   template<typename U> U f5(U);
10*f4a2713aSLionel Sambuc };
11*f4a2713aSLionel Sambuc 
f0(T x)12*f4a2713aSLionel Sambuc template<typename T> T X<T>::f0(T x) { return x; }
f1(T)13*f4a2713aSLionel Sambuc template<typename T> T X<T>::f1(T) { return T(); }
f2(T x)14*f4a2713aSLionel Sambuc template<typename T> T X<T>::f2(T x) { return T(); } // expected-warning{{unused parameter 'x'}}
f3(U x)15*f4a2713aSLionel Sambuc template<typename T> template<typename U> U X<T>::f3(U x) { return x; }
f4(U)16*f4a2713aSLionel Sambuc template<typename T> template<typename U> U X<T>::f4(U) { return U(); }
f5(U x)17*f4a2713aSLionel Sambuc template<typename T> template<typename U> U X<T>::f5(U x) { return U(); } // expected-warning{{unused parameter 'x'}}
18*f4a2713aSLionel Sambuc 
test_X(X<int> & x,int i)19*f4a2713aSLionel Sambuc void test_X(X<int> &x, int i) {
20*f4a2713aSLionel Sambuc   x.f0(i);
21*f4a2713aSLionel Sambuc   x.f1(i);
22*f4a2713aSLionel Sambuc   x.f2(i);
23*f4a2713aSLionel Sambuc   x.f3(i);
24*f4a2713aSLionel Sambuc   x.f4(i);
25*f4a2713aSLionel Sambuc   x.f5(i);
26*f4a2713aSLionel Sambuc }
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // Make sure both parameters aren't considered unused.
29*f4a2713aSLionel Sambuc template <typename... T>
test_pack(T...t,T...s)30*f4a2713aSLionel Sambuc static int test_pack(T... t, T... s)
31*f4a2713aSLionel Sambuc {
32*f4a2713aSLionel Sambuc   auto l = [&t...]() { return sizeof...(s); };
33*f4a2713aSLionel Sambuc   return l();
34*f4a2713aSLionel Sambuc }
35