1cd1af3d68b00aa729e382fe2cde186f237630804Anders Carlsson// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s 2d3f2c10f881311831a84114179342ff4db55e0c3Daniel Dunbar 3d3f2c10f881311831a84114179342ff4db55e0c3Daniel Dunbarstatic void (*fp0)(void) __attribute__((unused)); 4d3f2c10f881311831a84114179342ff4db55e0c3Daniel Dunbar 5d3f2c10f881311831a84114179342ff4db55e0c3Daniel Dunbarstatic void __attribute__((unused)) f0(void); 6d3f2c10f881311831a84114179342ff4db55e0c3Daniel Dunbar 7d3f2c10f881311831a84114179342ff4db55e0c3Daniel Dunbar// On K&R 8d3f2c10f881311831a84114179342ff4db55e0c3Daniel Dunbarint f1() __attribute__((unused)); 9d3f2c10f881311831a84114179342ff4db55e0c3Daniel Dunbar 10d3f2c10f881311831a84114179342ff4db55e0c3Daniel Dunbarint g0 __attribute__((unused)); 11d3f2c10f881311831a84114179342ff4db55e0c3Daniel Dunbar 12baec77865b3ce64bb942dddc5dc2fada84ce5099Aaron Ballmanint f2() __attribute__((unused(1, 2))); // expected-error {{'unused' attribute takes no arguments}} 13aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCall 14aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCallstruct Test0_unused {} __attribute__((unused)); 15aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCallstruct Test0_not_unused {}; 16aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCalltypedef int Int_unused __attribute__((unused)); 17aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCalltypedef int Int_not_unused; 18aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCall 19aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCallvoid test0() { 20aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCall int x; // expected-warning {{unused variable}} 21aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCall 22aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCall Int_not_unused i0; // expected-warning {{unused variable}} 232127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson Int_unused i1; // expected-warning {{'Int_unused' was marked unused but was used}} 24aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCall 25aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCall struct Test0_not_unused s0; // expected-warning {{unused variable}} 262127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson struct Test0_unused s1; // expected-warning {{'Test0_unused' was marked unused but was used}} 272127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson} 282127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson 292127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlssonint f3(int x) { // expected-warning{{unused parameter 'x'}} 302127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson return 0; 312127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson} 322127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson 332127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlssonint f4(int x) { 342127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson return x; 352127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson} 362127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson 372127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlssonint f5(int x __attribute__((__unused__))) { 382127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson return 0; 392127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson} 402127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson 412127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlssonint f6(int x __attribute__((__unused__))) { 422127eccbe15fd3b1b29aa53ccedd2e0f55ad27f9Anders Carlsson return x; // expected-warning{{'x' was marked unused but was used}} 43aec586056d8670c99ba7c4833be13e4eb123cddbJohn McCall} 44