diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-01-18 19:50:15 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-01-18 19:50:15 +0000 |
commit | a33e0504f61132ac43f4f89af43b12c87e987c20 (patch) | |
tree | 635589212b1c31ffc26cd1ff2ff38b5b36fd7d13 /lib | |
parent | e188933adf2cfe2821b8acba2de6d5d152bc246b (diff) |
When redefining a macro don't warn twice if it's not used and don't warn for duplicate
definition by command line options. Fixes rdar://8875916.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123767 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index f422d254f0..0f0d25b887 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -1527,7 +1527,7 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) { // then don't bother calling MacroInfo::isIdenticalTo. if (!getDiagnostics().getSuppressSystemWarnings() || !SourceMgr.isInSystemHeader(DefineTok.getLocation())) { - if (!OtherMI->isUsed()) + if (!OtherMI->isUsed() && OtherMI->isWarnIfUnused()) Diag(OtherMI->getDefinitionLoc(), diag::pp_macro_not_used); // Macros must be identical. This means all tokens and whitespace @@ -1539,6 +1539,8 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) { Diag(OtherMI->getDefinitionLoc(), diag::note_previous_definition); } } + if (OtherMI->isWarnIfUnused()) + WarnUnusedMacroLocs.erase(OtherMI->getDefinitionLoc()); ReleaseMacroInfo(OtherMI); } |