[PATCH 1/4] environ-selftests: Ignore -Wself-move warning
Simon Marchi
simon.marchi@polymtl.ca
Thu Jun 22 07:44:00 GMT 2017
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"
^
> 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.
> Alternatively, you could replace the std::move with a cast
> to rvalue ref, which is just what std::move really is:
>
> -env = std::move (env);
> +env = static_cast<gdb_environ &&> (env);
I guess that with a comment explaining why we use that it would be ok,
but that would not be my first choice either.
Thanks,
Simon
More information about the Gdb-patches
mailing list