[cfe-commits] r134919 - in /cfe/trunk: lib/Lex/PPDirectives.cpp test/Preprocessor/warn-macro-unused.c
Eli Friedman
eli.friedman at gmail.com
Mon Jul 11 14:44:58 PDT 2011
On Mon, Jul 11, 2011 at 1:39 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
> Author: akirtzidis
> Date: Mon Jul 11 15:39:47 2011
> New Revision: 134919
>
> URL: http://llvm.org/viewvc/llvm-project?rev=134919&view=rev
> Log:
> Don't warn for unused macro when undef'ing it, if it comes from an included file. rdar://9745065
>
> Modified:
> cfe/trunk/lib/Lex/PPDirectives.cpp
> cfe/trunk/test/Preprocessor/warn-macro-unused.c
>
> Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=134919&r1=134918&r2=134919&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
> +++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Jul 11 15:39:47 2011
> @@ -1594,7 +1594,7 @@
> // 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.
>
> Modified: cfe/trunk/test/Preprocessor/warn-macro-unused.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/warn-macro-unused.c?rev=134919&r1=134918&r2=134919&view=diff
> ==============================================================================
> --- cfe/trunk/test/Preprocessor/warn-macro-unused.c (original)
> +++ cfe/trunk/test/Preprocessor/warn-macro-unused.c Mon Jul 11 15:39:47 2011
> @@ -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
I XFAIL'ed this test in r134925; please take a look.
-Eli
More information about the cfe-commits
mailing list