This is the mail archive of the
mailing list for the GCC project.
Re: Getting format of arg_type
- From: Manuel LÃpez-IbÃÃez <lopezibanez at gmail dot com>
- To: Prasad Ghangal <prasad dot ghangal at gmail dot com>
- Cc: gcc Mailing List <gcc at gcc dot gnu dot org>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Sun, 17 Apr 2016 23:09:36 +0100
- Subject: Re: Getting format of arg_type
- Authentication-results: sourceware.org; auth=none
- References: <CAE+uiWYS1sJmozrPypCsmRHP5p-b2UjOHysndjEN=0t_zTzsXg at mail dot gmail dot com>
On 15 April 2016 at 14:34, Prasad Ghangal <firstname.lastname@example.org> wrote:
> Regarding PR64955, I was observing function format_type_warning() (in
> c-family/c-format.c), how can I get format specifier for arg_type?
> Say, if tree arg_type stores 'char', then how can I get its format i.e. 'c' ?
That information is in the various *_table that you can find near the
top of c-format.c. The types in the tables are defined by various
'#define T_*' in c-format.h. I wish the names were a bit more
As far as I know, there is no function that given a type, gives you
the most appropriate format. Writing such a function is the main
challenge in that PR. Basically you need to figure out what the
existing code is doing to find out, given a format such as 'c', that
the wanted_type is 'char', and reverse that logic. (There may be more
than one possible valid format given a type).
Moreover, the whole c-format.* is a very old piece of GCC. If you can
think about simplifications or additional comments that could help
people like you in understanding it, please do not hesitate to propose
patches in that direction. I don't think we even have a short
description on how to add new format specifiers or flags to the
tables. That would be extremely useful to add at the top of the file.