[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / warn-unused-parameters.cpp
blobac4e21490a62440606ee560b99f3556bc0a1427e
1 // RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify -std=c++11 %s
2 template<typename T>
3 struct X {
4 T f0(T x);
5 T f1(T x);
6 T f2(T);
7 template<typename U> U f3(U x);
8 template<typename U> U f4(U x);
9 template<typename U> U f5(U);
12 template<typename T> T X<T>::f0(T x) { return x; }
13 template<typename T> T X<T>::f1(T) { return T(); }
14 template<typename T> T X<T>::f2(T x) { return T(); } // expected-warning{{unused parameter 'x'}}
15 template<typename T> template<typename U> U X<T>::f3(U x) { return x; }
16 template<typename T> template<typename U> U X<T>::f4(U) { return U(); }
17 template<typename T> template<typename U> U X<T>::f5(U x) { return U(); } // expected-warning{{unused parameter 'x'}}
19 void test_X(X<int> &x, int i) {
20 x.f0(i);
21 x.f1(i);
22 x.f2(i);
23 x.f3(i);
24 x.f4(i);
25 x.f5(i);
28 // Make sure both parameters aren't considered unused.
29 template <typename... T>
30 static int test_pack(T... t, T... s)
32 auto l = [&t...]() { return sizeof...(s); };
33 return l();
36 // Do not warn on naked functions.
37 [[gnu::naked]] int nakedFunction(int a, float b, const char* c) { ; }
38 __attribute__((naked)) void nakedFunction(int a, int b) { ; }