Help with format checking for accepting parameters equivalent to "tree"
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Fri Jun 20 16:10:00 GMT 2003
> From: "Joseph S. Myers" <jsm28@cam.ac.uk>
>
> On Thu, 19 Jun 2003, Kaveh R. Ghazi wrote:
>
> > So can I assume you're confirming that if I do this the format code
> > will handle the four cases I included in my testcase? If so, great.
>
> I'm suggesting that if you register "union tree_node" (maybe via a magic
> typedef for that type, as used for HOST_WIDE_INT) then it would at least
> fit the design of the code for that to work.
That doesn't work, e.g. if I declare "typedef union tree_node __tn__;"
use "__tn__" as my magic identifier and set pointer_count to 1, I get:
mytree.c:9: warning: __tn__ format, tree_node arg (arg 2)
mytree.c:10: warning: __tn__ format, tree_node arg (arg 2)
mytree.c:11: warning: __tn__ format, tree_node arg (arg 2)
mytree.c:12: warning: __tn__ format, tree_node arg (arg 2)
The format matching code seems very fragile. IMHO, making this more
robust is a prerequisite to extensible format checking so any effort
you could put into getting this to work better would not be a waste.
Anyway, I seem to be able to get it to work with the current code if I
stick with "tree" and pull out the type of the pointer directly out of
the "tree" typedef. Then it'll refer to the exact same type as
declared in the user's source code.
I.e. instead of (pseudo code):
t = maybe_get_identifier ("tree");
t = TREE_TYPE (identifier_global_value (t));
pointer_count = 0;
I used:
t = maybe_get_identifier ("tree");
t = TREE_TYPE (TREE_TYPE (identifier_global_value (t)));
pointer_count = 1;
and it works for all four cases.
I'll do a full test over the GCC source and see if any cases there
spuriously fail or cause any crashes.
--Kaveh
--
Kaveh R. Ghazi ghazi@caip.rutgers.edu
More information about the Gcc-patches
mailing list