r173952 - [preprocessor] Don't warn about "disabled expansion of recursive macro"

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Jan 30 13:33:06 PST 2013


On Jan 30, 2013, at 1:23 PM, Richard Smith <richard at metafoo.co.uk> wrote:

> On Wed, Jan 30, 2013 at 12:44 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
>> On Jan 30, 2013, at 11:54 AM, Abramo Bagnara <abramo.bagnara at gmail.com> wrote:
>> 
>>> Il 30/01/2013 19:55, Argyrios Kyrtzidis ha scritto:
>>>> Author: akirtzidis
>>>> Date: Wed Jan 30 12:55:52 2013
>>>> New Revision: 173952
>>>> 
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=173952&view=rev
>>>> Log:
>>>> [preprocessor] Don't warn about "disabled expansion of recursive macro"
>>>> for "#define X X".
>>>> 
>>>> This is a pattern that, for example, stdbool.h uses.
>>>> rdar://12435773
>>> 
>>> Please revert this commit: this has already been discussed in detail in
>>> past and we decided otherwise. Last time it has been discussed in this
>>> thread:
>>> 
>>> http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20121029/067098.html
>> 
>> Reverted in r173970.
>> 
>>> 
>>>> 
>>>> Modified:
>>>>   cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>>>>   cfe/trunk/test/Headers/stdbool.cpp
>>>>   cfe/trunk/test/Preprocessor/warn-disabled-macro-expansion.c
>>>> 
>>>> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=173952&r1=173951&r2=173952&view=diff
>>>> ==============================================================================
>>>> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
>>>> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Jan 30 12:55:52 2013
>>>> @@ -459,7 +459,10 @@ bool Preprocessor::HandleMacroExpandedId
>>>>      if (MacroInfo *NewMI = getMacroInfo(NewII))
>>>>        if (!NewMI->isEnabled() || NewMI == MI) {
>>>>          Identifier.setFlag(Token::DisableExpand);
>>>> -          Diag(Identifier, diag::pp_disabled_macro_expansion);
>>>> +          // Don't warn for "#define X X" like "#define bool bool" from
>>>> +          // stdbool.h.
>>> 
>>> Would you be so kind to add a comment here to remember that the choice
>>> to have this warning for thar case (although disabled by default) is
>>> deliberate?
>> 
>> Just to make sure, are you of the opinion that we should warn when <stdbool.h> is included and its macros are used ?
> 
> As discussed on that thread, we should modify <stdbool.h> to suppress
> the warning.

I don't think this is feasible due to compatibility concerns.
But we can avoid warning for a "#define X X" that came from a system header. This depends on whether Abramo, or anyone else, considers warning for <stdbool.h> desirable behavior.





More information about the cfe-commits mailing list