@@ -112,11 +112,21 @@ extern "C" {
112
112
# define _INTL_ASM (cname )
113
113
#endif
114
114
115
+ /* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
116
+ its n-th argument literally. This enables GCC to warn for example about
117
+ printf (gettext ("foo %y")). */
118
+ #if __GNUC__ >= 3 && !(__APPLE_CC__ > 1 && defined __cplusplus)
119
+ # define _INTL_MAY_RETURN_STRING_ARG (n ) __attribute__ ((__format_arg__ (n)))
120
+ #else
121
+ # define _INTL_MAY_RETURN_STRING_ARG (n )
122
+ #endif
123
+
115
124
/* Look up MSGID in the current default message catalog for the current
116
125
LC_MESSAGES locale. If not found, returns MSGID itself (the default
117
126
text). */
118
127
#ifdef _INTL_REDIRECT_INLINE
119
- extern char *libintl_gettext (const char *__msgid);
128
+ extern char *libintl_gettext (const char *__msgid)
129
+ _INTL_MAY_RETURN_STRING_ARG (1 );
120
130
static inline char *gettext (const char *__msgid)
121
131
{
122
132
return libintl_gettext (__msgid);
@@ -126,13 +136,15 @@ static inline char *gettext (const char *__msgid)
126
136
# define gettext libintl_gettext
127
137
#endif
128
138
extern char *gettext _INTL_PARAMS ((const char *__msgid))
129
- _INTL_ASM (libintl_gettext);
139
+ _INTL_ASM (libintl_gettext)
140
+ _INTL_MAY_RETURN_STRING_ARG (1 );
130
141
#endif
131
142
132
143
/* Look up MSGID in the DOMAINNAME message catalog for the current
133
144
LC_MESSAGES locale. */
134
145
#ifdef _INTL_REDIRECT_INLINE
135
- extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
146
+ extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
147
+ _INTL_MAY_RETURN_STRING_ARG (2 );
136
148
static inline char *dgettext (const char *__domainname, const char *__msgid)
137
149
{
138
150
return libintl_dgettext (__domainname, __msgid);
@@ -143,14 +155,16 @@ static inline char *dgettext (const char *__domainname, const char *__msgid)
143
155
#endif
144
156
extern char *dgettext _INTL_PARAMS ((const char *__domainname,
145
157
const char *__msgid))
146
- _INTL_ASM (libintl_dgettext);
158
+ _INTL_ASM (libintl_dgettext)
159
+ _INTL_MAY_RETURN_STRING_ARG (2 );
147
160
#endif
148
161
149
162
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
150
163
locale. */
151
164
#ifdef _INTL_REDIRECT_INLINE
152
165
extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
153
- int __category);
166
+ int __category)
167
+ _INTL_MAY_RETURN_STRING_ARG (2 );
154
168
static inline char *dcgettext (const char *__domainname, const char *__msgid,
155
169
int __category)
156
170
{
@@ -163,15 +177,17 @@ static inline char *dcgettext (const char *__domainname, const char *__msgid,
163
177
extern char *dcgettext _INTL_PARAMS ((const char *__domainname,
164
178
const char *__msgid,
165
179
int __category))
166
- _INTL_ASM (libintl_dcgettext);
180
+ _INTL_ASM (libintl_dcgettext)
181
+ _INTL_MAY_RETURN_STRING_ARG (2 );
167
182
#endif
168
183
169
184
170
185
/* Similar to `gettext' but select the plural form corresponding to the
171
186
number N. */
172
187
#ifdef _INTL_REDIRECT_INLINE
173
188
extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
174
- unsigned long int __n);
189
+ unsigned long int __n)
190
+ _INTL_MAY_RETURN_STRING_ARG (1 ) _INTL_MAY_RETURN_STRING_ARG (2 );
175
191
static inline char *ngettext (const char *__msgid1, const char *__msgid2,
176
192
unsigned long int __n)
177
193
{
@@ -184,14 +200,16 @@ static inline char *ngettext (const char *__msgid1, const char *__msgid2,
184
200
extern char *ngettext _INTL_PARAMS ((const char *__msgid1,
185
201
const char *__msgid2,
186
202
unsigned long int __n))
187
- _INTL_ASM (libintl_ngettext);
203
+ _INTL_ASM (libintl_ngettext)
204
+ _INTL_MAY_RETURN_STRING_ARG (1 ) _INTL_MAY_RETURN_STRING_ARG (2 );
188
205
#endif
189
206
190
207
/* Similar to `dgettext' but select the plural form corresponding to the
191
208
number N. */
192
209
#ifdef _INTL_REDIRECT_INLINE
193
210
extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
194
- const char *__msgid2, unsigned long int __n);
211
+ const char *__msgid2, unsigned long int __n)
212
+ _INTL_MAY_RETURN_STRING_ARG (2 ) _INTL_MAY_RETURN_STRING_ARG (3 );
195
213
static inline char *dngettext (const char *__domainname, const char *__msgid1,
196
214
const char *__msgid2, unsigned long int __n)
197
215
{
@@ -205,15 +223,17 @@ extern char *dngettext _INTL_PARAMS ((const char *__domainname,
205
223
const char *__msgid1,
206
224
const char *__msgid2,
207
225
unsigned long int __n))
208
- _INTL_ASM (libintl_dngettext);
226
+ _INTL_ASM (libintl_dngettext)
227
+ _INTL_MAY_RETURN_STRING_ARG (2 ) _INTL_MAY_RETURN_STRING_ARG (3 );
209
228
#endif
210
229
211
230
/* Similar to `dcgettext' but select the plural form corresponding to the
212
231
number N. */
213
232
#ifdef _INTL_REDIRECT_INLINE
214
233
extern char *libintl_dcngettext (const char *__domainname,
215
234
const char *__msgid1, const char *__msgid2,
216
- unsigned long int __n, int __category);
235
+ unsigned long int __n, int __category)
236
+ _INTL_MAY_RETURN_STRING_ARG (2 ) _INTL_MAY_RETURN_STRING_ARG (3 );
217
237
static inline char *dcngettext (const char *__domainname,
218
238
const char *__msgid1, const char *__msgid2,
219
239
unsigned long int __n, int __category)
@@ -229,7 +249,8 @@ extern char *dcngettext _INTL_PARAMS ((const char *__domainname,
229
249
const char *__msgid2,
230
250
unsigned long int __n,
231
251
int __category))
232
- _INTL_ASM (libintl_dcngettext);
252
+ _INTL_ASM (libintl_dcngettext)
253
+ _INTL_MAY_RETURN_STRING_ARG (2 ) _INTL_MAY_RETURN_STRING_ARG (3 );
233
254
#endif
234
255
235
256
0 commit comments