bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gettext] _INTL_MAY_RETURN_STRING_ARG -vs- clang


From: Tom Tromey
Subject: [bug-gettext] _INTL_MAY_RETURN_STRING_ARG -vs- clang
Date: Tue, 03 Jul 2018 07:24:06 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux)

Hi.

I was trying to get gdb to build warning-free on macOS.  Most of the
warnings came from the `_' macro.

You can see the start of the thread here:
    https://sourceware.org/ml/gdb-patches/2018-06/msg00728.html
It continues in the next month:
    https://sourceware.org/ml/gdb-patches/2018-07/msg00010.html

gdb and gcc are still using 0.12.  I'm not sure why.  But, I looked and
the problems still apply to git master.


Currently gettext-runtime/intl/libgnuintl.in.h has:

    /* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may 
return
       its n-th argument literally.  This enables GCC to warn for example about
       printf (gettext ("foo %y")).  */
    #if defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && 
__APPLE_CC__ > 1 && defined __cplusplus)
    # define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
    #else
    # define _INTL_MAY_RETURN_STRING_ARG(n)
    #endif

However, it seems that clang handles __format_arg__ just fine.
So, first, this test ought to be refined somehow.  I don't know exactly
how, though.  Perhaps detecting clang would be sufficient?

I don't have any historical Mac compilers, just the system one from a
recent version of macOS (10.13).  If it's any help, though, I can
compile test programs for you to see what is pre-defined, etc.


Second, there is code like this:

    #ifdef _INTL_REDIRECT_INLINE
    extern char *libintl_gettext (const char *__msgid)
           _INTL_MAY_RETURN_STRING_ARG (1);
    static inline char *gettext (const char *__msgid)
    {
      return libintl_gettext (__msgid);
    }
    #else
    [...]

Here, the inline "gettext" must also be marked as _INTL_MAY_RETURN_STRING_ARG.

I think this applies to gettext, dgettext, dcgettext, ngettext,
dngettext, and dcngettext.

thanks,
Tom



reply via email to

[Prev in Thread] Current Thread [Next in Thread]