summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Lex/PPDirectives.cpp3
-rw-r--r--test/Frontend/rewrite-includes-warnings.c5
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index c4f660f88c..fe57f37f09 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -2782,7 +2782,8 @@ void Preprocessor::HandleDefineDirective(
// If we need warning for not using the macro, add its location in the
// warn-because-unused-macro set. If it gets used it will be removed from set.
if (getSourceManager().isInMainFile(MI->getDefinitionLoc()) &&
- !Diags->isIgnored(diag::pp_macro_not_used, MI->getDefinitionLoc())) {
+ !Diags->isIgnored(diag::pp_macro_not_used, MI->getDefinitionLoc()) &&
+ !MacroExpansionInDirectivesOverride) {
MI->setIsWarnIfUnused(true);
WarnUnusedMacroLocs.insert(MI->getDefinitionLoc());
}
diff --git a/test/Frontend/rewrite-includes-warnings.c b/test/Frontend/rewrite-includes-warnings.c
index 1fb98db301..d955f86f82 100644
--- a/test/Frontend/rewrite-includes-warnings.c
+++ b/test/Frontend/rewrite-includes-warnings.c
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -verify -Wall -Wextra -E -frewrite-includes %s
+// RUN: %clang_cc1 -verify -Wall -Wextra -Wunused-macros -E -frewrite-includes %s
// expected-no-diagnostics
#pragma GCC visibility push (default)
+
+#define USED_MACRO 1
+int test() { return USED_MACRO; }