2010-09-20 07:03:35 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -verify %s
|
2009-10-09 05:35:42 +08:00
|
|
|
template<typename T> void f() {
|
2010-02-12 06:55:30 +08:00
|
|
|
T t;
|
|
|
|
t = 17;
|
2009-10-09 05:35:42 +08:00
|
|
|
}
|
2009-11-07 15:26:56 +08:00
|
|
|
|
2009-11-07 16:24:59 +08:00
|
|
|
// PR5407
|
2009-11-07 15:26:56 +08:00
|
|
|
struct A { A(); };
|
|
|
|
struct B { ~B(); };
|
|
|
|
void f() {
|
|
|
|
A a;
|
|
|
|
B b;
|
2009-11-07 16:24:59 +08:00
|
|
|
}
|
2009-11-18 01:11:23 +08:00
|
|
|
|
|
|
|
// PR5531
|
|
|
|
namespace PR5531 {
|
|
|
|
struct A {
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B {
|
|
|
|
B(int);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct C {
|
|
|
|
~C();
|
|
|
|
};
|
|
|
|
|
|
|
|
void test() {
|
2010-07-08 14:14:04 +08:00
|
|
|
A();
|
2009-11-18 01:11:23 +08:00
|
|
|
B(17);
|
|
|
|
C();
|
|
|
|
}
|
|
|
|
}
|
2009-12-24 08:28:18 +08:00
|
|
|
|
2010-02-12 06:55:30 +08:00
|
|
|
template<typename T>
|
|
|
|
struct X0 { };
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void test_dependent_init(T *p) {
|
|
|
|
X0<int> i(p);
|
|
|
|
(void)i;
|
|
|
|
}
|
2010-04-28 00:20:13 +08:00
|
|
|
|
|
|
|
namespace PR6948 {
|
|
|
|
template<typename T> class X;
|
|
|
|
|
|
|
|
void f() {
|
|
|
|
X<char> str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}}
|
|
|
|
}
|
|
|
|
}
|
2010-11-09 22:57:47 +08:00
|
|
|
|
|
|
|
void unused_local_static() {
|
|
|
|
static int x = 0;
|
|
|
|
static int y = 0; // expected-warning{{unused variable 'y'}}
|
|
|
|
#pragma unused(x)
|
|
|
|
}
|
2011-06-22 07:42:09 +08:00
|
|
|
|
|
|
|
// PR10168
|
|
|
|
namespace PR10168 {
|
|
|
|
// We expect a warning in the definition only for non-dependent variables, and
|
|
|
|
// a warning in the instantiation only for dependent variables.
|
|
|
|
template<typename T>
|
|
|
|
struct S {
|
|
|
|
void f() {
|
|
|
|
int a; // expected-warning {{unused variable 'a'}}
|
|
|
|
T b; // expected-warning 2{{unused variable 'b'}}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void f() {
|
|
|
|
int a; // expected-warning {{unused variable 'a'}}
|
|
|
|
T b; // expected-warning 2{{unused variable 'b'}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void g() {
|
|
|
|
S<int>().f(); // expected-note {{here}}
|
|
|
|
S<char>().f(); // expected-note {{here}}
|
|
|
|
f<int>(); // expected-note {{here}}
|
|
|
|
f<char>(); // expected-note {{here}}
|
|
|
|
}
|
|
|
|
}
|