This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: casting return values
Jim Wilson <wilson@specifixinc.com> writes:
> Dan Nicolaescu wrote:
> > Currently return values for C/C++ functions that return types for
> > which c_promoting_integer_type_p is true are cast to integer (see
> > c-decl.c:start_function and cp/decl.c:start_function)
>
> This came up in another thread recently, though I don't recall which
> one.
Probably here: http://gcc.gnu.org/ml/gcc-patches/2004-04/msg01958.html
Feedback on the patch would be appreciated.
> I looked at this code, and noticed that it has been there since
> at least gcc-1.42. I didn't bother looking back any further. I think
> this is some left over K&R C code. I don't know of any reason why gcc
> needs to be promoting return values here. I suspect the right fix is
> to just delete it.
Is this an approval for the patch? (obviously if it passes testing).
> I don't see the need for any langhook. A langhook is used when the
> middle end needs different behaviour for different languages, but if
> the C languages requires promotion for function return values, then it
> is likely part of the ABI, and will have to apply to all languages.
> Thus the existing TARGET_PROMOTE_FUNCTION_RETURN should be OK.
The only reason I suggested a langhook was because C and C++ were not
doing exactly the same thing, you are probably right it should not be
needed.
Thanks.
--dan