This is the mail archive of the
mailing list for the GCC project.
Re: Need help understanding decl_handle_format_arg_attribute
- To: Philipp Thomas <pthomas at suse dot de>, gcc at gcc dot gnu dot org
- Subject: Re: Need help understanding decl_handle_format_arg_attribute
- From: Fergus Henderson <fjh at cs dot mu dot oz dot au>
- Date: Thu, 9 Aug 2001 21:54:59 +1000
- References: <20010809133358.F7087@jeffreys.suse.de>
On 09-Aug-2001, Philipp Thomas <firstname.lastname@example.org> wrote:
> While trying to translate gcc messages, I stumbled over a message in
> format.c(decl_handle_format_arg_attribute), that I can't make sense of.
> Therefore I'd like some help from someone understanding that code.
> d_h_f_a_a has at the top this code:
> while (TREE_CODE (format_num_expr) == NOP_EXPR
> || TREE_CODE (format_num_expr) == CONVERT_EXPR
> || TREE_CODE (format_num_expr) == NON_LVALUE_EXPR)
> format_num_expr = TREE_OPERAND (format_num_expr, 0);
> if (TREE_CODE (format_num_expr) != INTEGER_CST
> || TREE_INT_CST_HIGH (format_num_expr) != 0)
> error ("format string has invalid operand number");
> Now could anyone enlighten me what this error message means? Specifically
> what 'operand number' refers to?
This function is checking the syntax of __attribute__((format(...)))
declarations. See "function attributes" in the "C extensions"
section of the GCC manual. For example:
my_printf (void *my_object, const char *my_format, ...)
__attribute__ ((format (printf, 2, 3)));
The numbers 2 and 3 are the "operand numbers"; they specify which argument of
my_printf is the format string and which is the first variable argument.
The error message above occurs when you have an invalid operand number
instead of "2" or "3" in the example above.
Fergus Henderson <email@example.com> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.