[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / SemaCXX / warn-unused-but-set-variables-cpp.cpp
blob400e9d7681b3103b42175fcf85249707e0ad45b0
1 // RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused-but-set-variable -verify %s
3 struct S {
4 int i;
5 };
7 struct __attribute__((warn_unused)) SWarnUnused {
8 int j;
9 void operator +=(int);
12 int f0() {
13 int y; // expected-warning{{variable 'y' set but not used}}
14 y = 0;
16 int z __attribute__((unused));
17 z = 0;
19 // In C++, don't warn for structs. (following gcc's behavior)
20 struct S s;
21 struct S t;
22 s = t;
24 // Unless it's marked with the warn_unused attribute.
25 struct SWarnUnused swu; // expected-warning{{variable 'swu' set but not used}}
26 struct SWarnUnused swu2;
27 swu = swu2;
29 int x;
30 x = 0;
31 return x + 5;
34 void f1(void) {
35 (void)^() {
36 int y; // expected-warning{{variable 'y' set but not used}}
37 y = 0;
39 int x;
40 x = 0;
41 return x;
45 void f2() {
46 // Don't warn for either of these cases.
47 constexpr int x = 2;
48 const int y = 1;
49 char a[x];
50 char b[y];
53 void f3(int n) {
54 // Don't warn for overloaded compound assignment operators.
55 SWarnUnused swu;
56 swu += n;
59 template<typename T> void f4(T n) {
60 // Don't warn for (potentially) overloaded compound assignment operators in
61 // template code.
62 SWarnUnused swu;
63 swu += n;