xref: /llvm-project/clang/test/SemaCXX/warn-unused-variables.cpp (revision d05b352b0e5b036d67e9916936b1e59e742039fd)
1 // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -verify %s
2 template<typename T> void f() {
3   T t;
4   t = 17;
5 }
6 
7 // PR5407
8 struct A { A(); };
9 struct B { ~B(); };
10 void f() {
11   A a;
12   B b;
13 }
14 
15 // PR5531
16 namespace PR5531 {
17   struct A {
18   };
19 
20   struct B {
21     B(int);
22   };
23 
24   struct C {
25     ~C();
26   };
27 
28   void test() {
29     A();
30     B(17);
31     C();
32   }
33 }
34 
35 template<typename T>
36 struct X0 { };
37 
38 template<typename T>
39 void test_dependent_init(T *p) {
40   X0<int> i(p);
41   (void)i;
42 }
43 
44 namespace PR6948 {
45   template<typename T> class X;
46 
47   void f() {
48     X<char> str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}}
49   }
50 }
51 
52 void unused_local_static() {
53   static int x = 0;
54   static int y = 0; // expected-warning{{unused variable 'y'}}
55 #pragma unused(x)
56 }
57