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.
(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'}}
+}