Warn if a variable marked with the "unused" attribute is used. Patch by Darin Adler!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117184 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/attr-unused.c b/test/Sema/attr-unused.c
index 2871514..795b083 100644
--- a/test/Sema/attr-unused.c
+++ b/test/Sema/attr-unused.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -Wunused-variable -fsyntax-only %s
+// RUN: %clang_cc1 -verify -Wunused -Wunused-parameter -Wunused -fsyntax-only %s
 
 static void (*fp0)(void) __attribute__((unused));
 
@@ -20,8 +20,24 @@
   int x; // expected-warning {{unused variable}}
 
   Int_not_unused i0; // expected-warning {{unused variable}}
-  Int_unused i1;
+  Int_unused i1; // expected-warning {{'Int_unused' was marked unused but was used}}
 
   struct Test0_not_unused s0; // expected-warning {{unused variable}}
-  struct Test0_unused s1;
+  struct Test0_unused s1; // expected-warning {{'Test0_unused' was marked unused but was used}}
+}
+
+int f3(int x) { // expected-warning{{unused parameter 'x'}}
+  return 0;
+}
+
+int f4(int x) {
+  return x;
+}
+
+int f5(int x __attribute__((__unused__))) {
+  return 0;
+}
+
+int f6(int x __attribute__((__unused__))) {
+  return x; // expected-warning{{'x' was marked unused but was used}}
 }