This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: casting return values
- From: Jim Wilson <wilson at specifixinc dot com>
- To: Dan Nicolaescu <dann at godzilla dot ics dot uci dot edu>
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 16 May 2004 19:52:10 -0700
- Subject: Re: casting return values
- References: <200405140243.i4E2hhGK003752@scanner2.ics.uci.edu>
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. 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.
However, there is the concern that removing this may accidentally break
some targets, because it will effectively be an ABI change. Targets
that do need return values promoted should be defining
TARGET_PROMOTE_FUNCTION_RETURN and PROMOTE_FUNCTION_MODE. However,
there are likely some targets that require the promotion but do not
currently define these macros.
Maybe there is already enough breakage in gcc-3.5 because of the
tree-ssa merge that we can justify the risk of one more?
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.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com