xref: /llvm-project/clang/test/SemaCXX/warn-unused-variables.cpp (revision c095b5361a5a8d949f42a5f6ce50b80254e88396)
1 // RUN: %clang -fsyntax-only -Wunused-variable -verify %s
2 
3 template<typename T> void f() {
4 	T t;
5 	t = 17;
6 }
7 
8 // PR5407
9 struct A { A(); };
10 struct B { ~B(); };
11 void f() {
12   A a;
13   B b;
14 }
15 
16 // PR5531
17 namespace PR5531 {
18   struct A {
19   };
20 
21   struct B {
22     B(int);
23   };
24 
25   struct C {
26     ~C();
27   };
28 
29   void test() {
30     A();
31     B(17);
32     C();
33   }
34 }
35 
36 
37 struct X {
38  int foo() __attribute__((warn_unused_result));
39 };
40 
41 void bah() {
42   X x, *x2;
43   x.foo(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
44   x2->foo(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
45 }
46