This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Need help understanding decl_handle_format_arg_attribute

On 09-Aug-2001, Philipp Thomas <> 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");
>       return;
>     }
> 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:

          extern int
          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 <>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <>  |     -- the last words of T. S. Garp.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]