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/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp
index 0921156..d7290c3 100644
--- a/lib/Sema/SemaAttr.cpp
+++ b/lib/Sema/SemaAttr.cpp
@@ -288,6 +288,10 @@
continue;
}
+ // Warn if this was used before being marked unused.
+ if (VD->isUsed())
+ Diag(PragmaLoc, diag::warn_used_but_marked_unused) << Name;
+
VD->addAttr(::new (Context) UnusedAttr(Tok.getLocation(), Context));
}
}