This is the mail archive of the
mailing list for the GCC project.
Re: DECL_RESULT not available for declared (but not defined) function?
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Alexandre Courbot <Alexandre dot Courbot at lifl dot fr>
- Cc: gcc at gcc dot gnu dot org
- Date: 23 Sep 2003 11:24:06 +0200
- Subject: Re: DECL_RESULT not available for declared (but not defined) function?
- Organization: Integrable Solutions
- References: <200309231112.44361.Alexandre.Courbot@lifl.fr>
Alexandre Courbot <Alexandre.Courbot@lifl.fr> writes:
| Hi everybody,
| Every time I make a function call I need to know the return type of the
| callee. Fonction calls on my target can only happen on declared functions
| (not function pointers), so to get the return type I simply get the tree of
| the symbol_ref with SYMBOL_REF_DECL and the result node with DECL_RESULT.
| However, consider the following code:
| int tstfunc();
| void boo()
| int i = tstfunc();
for C, C++ (and probably any C-like front-end), the return type of a
function is given by the TREE_TYPE of its TREE_TYPE. If you have a
call, therefore an expression, then you can just look at its TREE_TYPE
just like for any expression.
If you have a funuction descriptor, e.g. tstfunc, then
TREE_TYPE (TREE_TYPE (tstfunc))
should return int.
Have a look at doc/c-tree.texi.