Don't warn for unused macro when undef'ing it, if it comes from an included file. rdar://9745065

llvm-svn: 134919
This commit is contained in:
Argyrios Kyrtzidis 2011-07-11 20:39:47 +00:00
parent a59dbea017
commit 2299889f87
2 changed files with 6 additions and 1 deletions

View File

@ -1594,7 +1594,7 @@ void Preprocessor::HandleUndefDirective(Token &UndefTok) {
// If the macro is not defined, this is a noop undef, just return.
if (MI == 0) return;
if (!MI->isUsed())
if (!MI->isUsed() && MI->isWarnIfUnused())
Diag(MI->getDefinitionLoc(), diag::pp_macro_not_used);
// If the callbacks want to know, tell them about the macro #undef.

View File

@ -1,5 +1,10 @@
// RUN: %clang_cc1 %s -Wunused-macros -Dfoo -Dfoo -verify
#include "warn-macro-unused.h"
#define unused // expected-warning {{macro is not used}}
#define unused
unused
// rdar://9745065
#undef unused_from_header // no warning