From: Gavin Romig-Koch Date: Sun, 25 Oct 1998 16:54:35 +0000 (+0000) Subject: typeck.c (c_expand_return): Handle the case that valtype is wider than the functions... X-Git-Tag: prereleases/egcs-1.1.1-pre~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b5cd767752d3c436b8675040bafa663a4b2cf06;p=thirdparty%2Fgcc.git typeck.c (c_expand_return): Handle the case that valtype is wider than the functions return type. * typeck.c (c_expand_return): Handle the case that valtype is wider than the functions return type. From-SVN: r23321 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bb915a73168c..26dda4449468 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -33,6 +33,11 @@ Fri Oct 2 02:07:26 1998 Mumit Khan * decl.c (duplicate_decls): Don't complain about different exceptions from an internal decl even if pedantic. +1998-08-24 Gavin Romig-Koch + + * typeck.c (c_expand_return): Handle the case that valtype + is wider than the functions return type. + 1998-08-17 Mark Mitchell * pt.c (check_explicit_specialization): Don't abort on bogus diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a1c1394d17b3..197aab7d985a 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -7291,10 +7291,18 @@ c_expand_return (retval) } else { + tree functype = TREE_TYPE (TREE_TYPE (current_function_decl)); + + /* First convert the value to the function's return type, then + to the type of return value's location to handle the + case that functype is thiner than the valtype. */ + retval = convert_for_initialization - (NULL_TREE, valtype, retval, LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING, + (NULL_TREE, functype, retval, LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING, "return", NULL_TREE, 0); + retval = convert (valtype, retval); + if (retval == error_mark_node) { /* Avoid warning about control reaching end of function. */