aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp6
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);
}