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: DECL_RESULT not available for declared (but not defined) function?


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.

-- Gaby


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