This is the mail archive of the gcc@gcc.gnu.org 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]
Other format: [Raw text]

Re: testing that a Gimple call argument is a string...


On Thu, Oct 18, 2012 at 10:33 PM, Basile Starynkevitch
<basile@starynkevitch.net> wrote:
> Hello
>
> I'm coding in MELT the ex06/ of https://github.com/bstarynk/melt-examples/
> which should typecheck calls to variadic functions json_pack & json_unpack
> from http://www.digip.org/jansson (a JSON library in C).
>
> I'm working on a MELT pass on Gimple/SSA after phiopt (maybe that place is wrong?)
>
> I don't understand well how to check that a given Gimple argument is a string.
> I was thinking of using useless_type_conversion_p or types_compatible_p on the TREE_TYPE of some POINTER_TYPE with char_type_node, but it seems to not work as I would expect
>
> How would you (in C++ or C for a 4.6) code such a test (that argument 2 of some GIMPLE_CALL is a string, ie. a char* in C parlance)?

You would look at the function signature of the function called, not at its
argument.  The argument can be a void * and still be a "string" (well, a pointer
to a string).  GIMPLE doesn't care about the actual type pointed to.

> (I'm coding in MELT, but I am not asking a MELT specific question; I have hard time understanding how that should be coded in C++).
>
> Or where is the typechecking for __attribute__((format(printf))) functions done in the GCC source tree?

> Regards.
>
> --
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mines, sont seulement les miennes} ***


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