diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-10-08 21:35:42 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-10-08 21:35:42 +0000 |
commit | b5352cf949898cd42c8c5bc96a17a831b61ac2e5 (patch) | |
tree | 574a96542b2b77e6c86b0821b2149b2ac9ac189d /lib/Sema/SemaDecl.cpp | |
parent | b46f57d9daa0c30d79dc8149d30c3e3a12fe2b32 (diff) |
Implement support for -Wunused-variable, from Oscar Bonilla!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83577 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index fa6d623ae3..c2a83cdc6f 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -434,6 +434,12 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) { if (!D->getDeclName()) continue; + // Diagnose unused variables in this scope. + if (!D->isUsed() && !D->hasAttr<UnusedAttr>() && isa<VarDecl>(D) && + !isa<ParmVarDecl>(D) && !isa<ImplicitParamDecl>(D) && + D->getDeclContext()->isFunctionOrMethod()) + Diag(D->getLocation(), diag::warn_unused_variable) << D->getDeclName(); + // Remove this name from our lexical scope. IdResolver.RemoveDecl(D); } |