fix PR5933: don't warn about unused variables if a function has other errors in it.

llvm-svn: 97498
This commit is contained in:
Chris Lattner 2010-03-01 21:06:03 +00:00
parent 30d0cfda35
commit efc83e60d3
2 changed files with 8 additions and 1 deletions

View File

@ -553,7 +553,8 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) {
if (!D->getDeclName()) continue;
// Diagnose unused variables in this scope.
if (ShouldDiagnoseUnusedDecl(D))
if (ShouldDiagnoseUnusedDecl(D) &&
NumErrorsAtStartOfFunction == getDiagnostics().getNumErrors())
Diag(D->getLocation(), diag::warn_unused_variable) << D->getDeclName();
// Remove this name from our lexical scope.

View File

@ -17,3 +17,9 @@ void f1(void) {
(void)sizeof(i);
return;
}
// PR5933
int f2() {
int X = 4; // Shouldn't have a bogus 'unused variable X' warning.
return Y + X; // expected-error {{use of undeclared identifier 'Y'}}
}