annotate clang/test/SemaCXX/warn-unused-parameters.cpp @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify -std=c++11 %s
anatofuz
parents:
diff changeset
2 template<typename T>
anatofuz
parents:
diff changeset
3 struct X {
anatofuz
parents:
diff changeset
4 T f0(T x);
anatofuz
parents:
diff changeset
5 T f1(T x);
anatofuz
parents:
diff changeset
6 T f2(T);
anatofuz
parents:
diff changeset
7 template<typename U> U f3(U x);
anatofuz
parents:
diff changeset
8 template<typename U> U f4(U x);
anatofuz
parents:
diff changeset
9 template<typename U> U f5(U);
anatofuz
parents:
diff changeset
10 };
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 template<typename T> T X<T>::f0(T x) { return x; }
anatofuz
parents:
diff changeset
13 template<typename T> T X<T>::f1(T) { return T(); }
anatofuz
parents:
diff changeset
14 template<typename T> T X<T>::f2(T x) { return T(); } // expected-warning{{unused parameter 'x'}}
anatofuz
parents:
diff changeset
15 template<typename T> template<typename U> U X<T>::f3(U x) { return x; }
anatofuz
parents:
diff changeset
16 template<typename T> template<typename U> U X<T>::f4(U) { return U(); }
anatofuz
parents:
diff changeset
17 template<typename T> template<typename U> U X<T>::f5(U x) { return U(); } // expected-warning{{unused parameter 'x'}}
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 void test_X(X<int> &x, int i) {
anatofuz
parents:
diff changeset
20 x.f0(i);
anatofuz
parents:
diff changeset
21 x.f1(i);
anatofuz
parents:
diff changeset
22 x.f2(i);
anatofuz
parents:
diff changeset
23 x.f3(i);
anatofuz
parents:
diff changeset
24 x.f4(i);
anatofuz
parents:
diff changeset
25 x.f5(i);
anatofuz
parents:
diff changeset
26 }
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 // Make sure both parameters aren't considered unused.
anatofuz
parents:
diff changeset
29 template <typename... T>
anatofuz
parents:
diff changeset
30 static int test_pack(T... t, T... s)
anatofuz
parents:
diff changeset
31 {
anatofuz
parents:
diff changeset
32 auto l = [&t...]() { return sizeof...(s); };
anatofuz
parents:
diff changeset
33 return l();
anatofuz
parents:
diff changeset
34 }