This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix __has_{cpp_}attribute with -traditional-cpp (PR preprocessor/65238)
- From: Dodji Seketeli <dodji at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Jakub Jelinek <jakub at redhat dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, Marek Polacek <polacek at redhat dot com>, Dodji Seketeli <dseketel at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 20 Mar 2015 18:34:22 +0100
- Subject: Re: [PATCH] Fix __has_{cpp_}attribute with -traditional-cpp (PR preprocessor/65238)
- Authentication-results: sourceware.org; auth=none
- References: <20150311191054 dot GQ1746 at tucnak dot redhat dot com> <550C4B34 dot 7010203 at redhat dot com> <20150320164849 dot GK1746 at tucnak dot redhat dot com> <550C55C8 dot 4010304 at redhat dot com>
Jason Merrill <jason@redhat.com> writes:
> On 03/20/2015 12:48 PM, Jakub Jelinek wrote:
>> On Fri, Mar 20, 2015 at 12:30:44PM -0400, Jason Merrill wrote:
>>> On 03/11/2015 03:10 PM, Jakub Jelinek wrote:
>>>> __has_{cpp_,}attribute builtin macros are effectively function-like macros
>>>> taking one argument (and the ISO preprocessor expands macros in the argument
>>>> which is IMHO desirable), but the traditional preprocessor has been crashing
>>>> on them or reporting errors.
>>>
>>> Why do we want ISO preprocessor behavior in this specific situation?
>>
>> You mean that we would handle
>> #define U unused
>> #if __has_attribute(U)
>> int u __attribute__((unused));
>> #endif
>> differently between ISO and traditional preprocessing?
>
>> That would be surprising to users.
>
> Why surprising? Don't users of the traditional preprocessor expect
> traditional preprocessor behavior?
One of the reasons why I thought it'd be "nice" to have the traditionnal
mode support the macro-expansion of the arguments here is that there
already are cases where the traditionnal mode supports ISO behaviour.
For instance, the documentation of cpp says:
10.3 Traditional miscellany
===========================
Here are some things to be aware of when using the traditional
preprocessor.
[...]
* A true traditional C preprocessor does not recognize '#error' or
'#pragma', and may not recognize '#elif'. CPP supports all the
directives in traditional mode that it supports in ISO mode,
including extensions, with the exception that the effects of
'#pragma GCC poison' are undefined.
So I thought this useful particular use case of __has_attribute(U) might
well be another of such case even if it's not a directive.
Just my 2 cents.
--
Dodji