1 // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -verify %s
2 template<typename T> void f() {
39 void test_dependent_init(T *p) {
45 template<typename T> class X;
48 X<char> str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}}
52 void unused_local_static() {
54 static int y = 0; // expected-warning{{unused variable 'y'}}
60 // We expect a warning in the definition only for non-dependent variables, and
61 // a warning in the instantiation only for dependent variables.
65 int a; // expected-warning {{unused variable 'a'}}
66 T b; // expected-warning 2{{unused variable 'b'}}
72 int a; // expected-warning {{unused variable 'a'}}
73 T b; // expected-warning 2{{unused variable 'b'}}
77 S<int>().f(); // expected-note {{here}}
78 S<char>().f(); // expected-note {{here}}
79 f<int>(); // expected-note {{here}}
80 f<char>(); // expected-note {{here}}
90 // This constructor call can be elided.
91 S1 x = makeS1(); // expected-warning {{unused variable 'x'}}
93 // This one cannot, so no warning.
96 // This call cannot, but the constructor is trivial.
97 S1 z = a; // expected-warning {{unused variable 'z'}}
100 // The same is true even when we know thet constructor has side effects.
109 S2 x = makeS2(); // expected-warning {{unused variable 'x'}}
111 S2 z = a; // expected-warning {{unused variable 'z'}}
114 // Or when the constructor is not declared by the user.
120 S3 x = makeS3(); // expected-warning {{unused variable 'x'}}
122 S3 z = a; // expected-warning {{unused variable 'z'}}