[PATCH BZ#19239] Improve deprecation warnings
Zack Weinberg
zackw@panix.com
Mon Nov 14 13:23:00 GMT 2016
On Thu, Oct 13, 2016 at 5:40 PM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
> On 11/10/2016 10:09, Zack Weinberg wrote:
>> By using __glibc_macro_warning instead of __attribute_deprecated__,
>> we get the deprecation warnings whenever the macros are expanded, not
>> just when they compile to a function call. This is important for
>> unintentional uses like the test case in #19239.
>
> I am assuming you tested some platform and verified that it actually
> fixed the issue. Patch looks ok with some comments about the new
> macro definition.
Yes, I ran the test suite on x86_64-linux and I manually verified the
test case in #19329.
>> +/* Caution: if you change the whitespace in and around this macro,
>> + it may malfunction. Newline placement is tuned for GCC 6. */
>
> This comments is somewhat confusing, what does it mean to be 'tuned'
> for GCC 6? It is just that stylist it will be better formatted on
> GCC 6? Will it work correctly on older GCC releases? What kind of
> whitespaces constraints do we need to be aware of?
It will work correctly with any GCC release (that supports #pragma GCC
message), it just might not be word-wrapped as neatly.
After thinking about it some more, the fragility is not about
whitespace, it's about tokens. I have changed the comment to read
/* Caution: The text of this deprecation message is unquoted, so that
#symbol can be substituted. (It is converted to a string by
__SYSMACROS_DM1.) This means the message must be a sequence of
complete pp-tokens; in particular, English contractions (it's,
can't) cannot be used.
The message has been manually word-wrapped to fit in 80 columns
when output by GCC 5 and 6. The first line is shorter to leave
some room for the "foo.c:23: warning:" annotation. */
and I've also added a note to cdefs.h above the definition of
__glibc_macro_warning
/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is
intended for use in preprocessor macros.
Note: MESSAGE must be a _single_ string; concatenation of string
literals is not supported. */
and I'm going to go ahead and check it in like that.
zw
More information about the Libc-alpha
mailing list