1 // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -verify %s
2 template<typename T> void f() {
39 void test_dependent_init(T *p) {
44 void unused_local_static() {
46 static int y = 0; // expected-warning{{unused variable 'y'}}
52 // We expect a warning in the definition only for non-dependent variables, and
53 // a warning in the instantiation only for dependent variables.
57 int a; // expected-warning {{unused variable 'a'}}
58 T b; // expected-warning 2{{unused variable 'b'}}
64 int a; // expected-warning {{unused variable 'a'}}
65 T b; // expected-warning 2{{unused variable 'b'}}
69 S<int>().f(); // expected-note {{here}}
70 S<char>().f(); // expected-note {{here}}
71 f<int>(); // expected-note {{here}}
72 f<char>(); // expected-note {{here}}
82 // This constructor call can be elided.
83 S1 x = makeS1(); // expected-warning {{unused variable 'x'}}
85 // This one cannot, so no warning.
88 // This call cannot, but the constructor is trivial.
89 S1 z = a; // expected-warning {{unused variable 'z'}}
92 // The same is true even when we know thet constructor has side effects.
101 S2 x = makeS2(); // expected-warning {{unused variable 'x'}}
103 S2 z = a; // expected-warning {{unused variable 'z'}}
106 // Or when the constructor is not declared by the user.
112 S3 x = makeS3(); // expected-warning {{unused variable 'x'}}
114 S3 z = a; // expected-warning {{unused variable 'z'}}
118 namespace ctor_with_cleanups {
130 #include "Inputs/warn-unused-variables.h"