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]

DECL_RESULT not available for declared (but not defined) function?


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();
}

From tstfunc's proto one can guess that the return type will be an int. 
Calling SYMBOL_REF_DECL on the symbol_ref of the function returns a valid 
FUNCTION_DECL node, on which I successfully applied some macros (DECL_NAME 
for instance). But DECL_RESULT returns NULL.

If I change the tstfunc declaration line into:

int tstfunc() { return 1; }

Then DECL_RESULT returns a valid RESULT_DECL.

Couldn't RESULT_DECL be set from a function declaration? Could it be fixed? Or 
is there another way to guess the function's return type?

Thanks,
Alex.


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