]> granicus.if.org Git - clang/commitdiff
Don't warn for unused macro when undef'ing it, if it comes from an included file...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 11 Jul 2011 20:39:47 +0000 (20:39 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 11 Jul 2011 20:39:47 +0000 (20:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134919 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPDirectives.cpp
test/Preprocessor/warn-macro-unused.c

index f74aad3c8164c7b4faa4e10e2b429c768289c9b4..efa188f752906237d7e75da35d4ca2f37819ecf3 100644 (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.
index 8a6d7c25ca5f746988179441ab248876d7256bf8..c33aeb5df9d9f282e4eb972ea6877af3bca6a9ab 100644 (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