aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorMatt Beaumont-Gay <matthewbg@google.com>2013-04-10 00:47:10 +0000
committerMatt Beaumont-Gay <matthewbg@google.com>2013-04-10 00:47:10 +0000
commit19b6a707a86302adc80d64464cbc3cb8a7a7f3a6 (patch)
tree6cf3a4f01e7e76e11c016cb803bbf65f5891e12c /lib/Sema/Sema.cpp
parent8da488dc0bf10d0b6b8861653e8014f0d06fe322 (diff)
Suppress -Wunused-variable for variables declared in headers, which may in
fact be defined and used in another TU. Reshuffle some test cases because we suppress -Wunused-variable after we've emitted an error. This fixes PR15558. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179138 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r--lib/Sema/Sema.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 6bab9e80cb..e271f78ed0 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -751,9 +751,13 @@ void Sema::ActOnEndOfTranslationUnit() {
if (DiagD->isReferenced()) {
Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
<< /*variable*/1 << DiagD->getDeclName();
- } else {
+ } else if (getSourceManager().isFromMainFile(DiagD->getLocation())) {
+ // If the declaration is in a header which is included into multiple
+ // TUs, it will declare one variable per TU, and one of the other
+ // variables may be used. So, only warn if the declaration is in the
+ // main file.
Diag(DiagD->getLocation(), diag::warn_unused_variable)
- << DiagD->getDeclName();
+ << DiagD->getDeclName();
}
}
}