Re: [PATCH v2] environ-selftests: Ignore -Wself-move warning

Pedro Alves
2017-06-22T09:51:24Z

On 06/22/2017 09:31 AM, Simon Marchi wrote:
> +#if defined (__clang__)
> +
> +#define DIAG_PUSH_IGNORE_SELF_MOVE \
> + _Pragma("clang diagnostic push") \
> + _Pragma("clang diagnostic ignored \"-Wself-move\"")
> +#define DIAG_POP_IGNORE_SELF_MOVE _Pragma("clang diagnostic pop")
> +
> +#else
> +
> +#define DIAG_PUSH_IGNORE_SELF_MOVE
> +#define DIAG_POP_IGNORE_SELF_MOVE
> +
> +#endif

Let me try writing a quick patch that puts a "STRINGIZE" macro
in common/preprocessor.h, so we can write the above like I had
suggested before, which is a bit more generic. There are several
copies in the tree of such a macro, so that'll be a good thing
on its own anyway, IMO.

I'm not sure whether the single push-ignore macro is a good idea,
since if we follow the pattern going forward, it requires more
boilerplace if we need different warnings around the same code:

{
DIAG_PUSH_IGNORE_WARN1
DIAG_PUSH_IGNORE_WARN2
DIAG_PUSH_IGNORE_WARN3
...

// some code

DIAG_POP_IGNORE_WARN3
DIAG_POP_IGNORE_WARN2
DIAG_POP_IGNORE_WARN1
}

vs:

{
DIAG_PUSH
DIAG_IGNORE_WARN1
DIAG_IGNORE_WARN2
DIAG_IGNORE_WARN3
...

// some code

DIAG_POP
}

Though we can always support both styles.

Thanks,
Pedro Alves