On Monday 01 of July 2013, Eli Friedman wrote: > On Sun, Jun 30, 2013 at 12:01 AM, Lubos Lunak <[email protected]> wrote: > > Hello, > > > > could somebody please review and commit the atached patch for pr15610 > > (it needs the patch for pr15610 applied first in order to apply cleanly). > > Thank you. > > > > Testcase?
Updated. -- Lubos Lunak [email protected]
From c6c972b397f14b261c5350cb45bd94cea6609e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <[email protected]> Date: Sun, 28 Jul 2013 11:32:55 +0200 Subject: [PATCH] do not emit -Wunused-macros warnings in -frewrite-includes mode (PR15614) -frewrite-includes calls PP.SetMacroExpansionOnlyInDirectives() to avoid macro expansions that are useless in that mode, but this can lead to -Wunused-macros false positives. As -frewrite-includes does not emit normal warnings, block -Wunused-macros too. --- lib/Lex/PPDirectives.cpp | 3 ++- test/Frontend/rewrite-includes-warnings.c | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index c70019f..06f7283 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -2039,7 +2039,8 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok, // warn-because-unused-macro set. If it gets used it will be removed from set. if (isInPrimaryFile() && // don't warn for include'd macros. Diags->getDiagnosticLevel(diag::pp_macro_not_used, - MI->getDefinitionLoc()) != DiagnosticsEngine::Ignored) { + MI->getDefinitionLoc()) != DiagnosticsEngine::Ignored && + !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 1fb98db..c4f38ed 100644 --- a/test/Frontend/rewrite-includes-warnings.c +++ b/test/Frontend/rewrite-includes-warnings.c @@ -1,4 +1,9 @@ -// 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 +// PR14831 #pragma GCC visibility push (default) + +// PR15614 +#define FOO 1 +int foo = FOO; -- 1.8.1.4
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
