This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/4] environ-selftests: Ignore -Wself-move warning


On 06/22/2017 08:44 AM, Simon Marchi wrote:
> On 2017-06-21 23:28, Pedro Alves wrote:
>> On 06/21/2017 10:05 PM, Simon Marchi wrote:
>>
>>> Yeah, I didn't expect to have to put the #ifdefs for __clang__ though.
>>> Without them, gcc emits a warning [-Wunknown-pragma].  We always have
>>> the option to turn -Wunknown-pragma off globally, what do you prefer?
>>>
>>
>> Don't both GCC and Clang understand "#pragma GCC diagnostic" instead?
> 
> Yes, but then it's GCC that complains that it doesn't know the warning:
> 
> /home/emaisin/src/binutils-gdb/gdb/unittests/environ-selftests.c:141:32:
> error: unknown option after ‘#pragma GCC diagnostic’ kind [-Werror=pragmas]
>  #pragma GCC diagnostic ignored "-Wself-move"
>                                 ^
> 

Ah, but that's a different kind of complaint.  Since both compilers
understand "#pragma GCC" but only one understands "#pragma clang",
then it seems clearly better to me to write the infrastructure
macros in terms of the former.  It'll make it a bit easier to
reuse the macros for other warnings.

>> Or better even, wrap it in some macros (and use _Pragma):
>>
>>  #define DIAGNOSTIC_PUSH _Pragma ("GCC diagnostic push")
>>  #define DIAGNOSTIC_POP _Pragma ("GCC diagnostic pop")
>>  #define DIAGNOSTIC_IGNORE(option) \
>>    _Pragma (STRINGIFY (GCC diagnostic ignored option))
> 
> Oh that's interesting.  The gcc doc said that _Pragma was added exactly
> for this purpose (to be usable in macros).  I'll try that.

Right.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]