1// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -Wused-but-marked-unused -Wunused -verify %s
2
3void f1(void) {
4  int x, y, z;
5  #pragma unused(x)
6  #pragma unused(y, z)
7
8  int w; // expected-warning {{unused}}
9  #pragma unused w // expected-warning{{missing '(' after '#pragma unused' - ignoring}}
10}
11
12void f2(void) {
13  int x, y; // expected-warning {{unused}} expected-warning {{unused}}
14  #pragma unused(x,) // expected-warning{{expected '#pragma unused' argument to be a variable name}}
15  #pragma unused() // expected-warning{{expected '#pragma unused' argument to be a variable name}}
16}
17
18void f3(void) {
19  #pragma unused(x) // expected-warning{{undeclared variable 'x' used as an argument for '#pragma unused'}}
20}
21
22void f4(void) {
23  int w; // expected-warning {{unused}}
24  #pragma unused((w)) // expected-warning{{expected '#pragma unused' argument to be a variable name}}
25}
26
27void f6(void) {
28  int z; // no-warning
29  {
30    #pragma unused(z) // no-warning
31  }
32}
33
34void f7() {
35  int y;
36  #pragma unused(undeclared, undefined, y) // expected-warning{{undeclared variable 'undeclared' used as an argument for '#pragma unused'}} expected-warning{{undeclared variable 'undefined' used as an argument for '#pragma unused'}}
37}
38
39int f8(int x) { // expected-warning{{unused parameter 'x'}}
40  return 0;
41}
42
43int f9(int x) {
44  return x;
45}
46
47int f10(int x) {
48  #pragma unused(x)
49  return 0;
50}
51
52int f11(int x) {
53  #pragma unused(x)
54  return x; // expected-warning{{'x' was marked unused but was used}}
55}
56
57int f12(int x) {
58  int y = x;
59  #pragma unused(x) // expected-warning{{'x' was marked unused but was used}}
60  return y;
61}
62
63// rdar://8793832
64static int glob_var = 0;
65#pragma unused(glob_var)
66