]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
typeck.c (c_expand_return): Handle the case that valtype is wider than the functions...
authorGavin Romig-Koch <gavin@cygnus.com>
Sun, 25 Oct 1998 16:54:35 +0000 (16:54 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 25 Oct 1998 16:54:35 +0000 (11:54 -0500)
* typeck.c (c_expand_return): Handle the case that valtype
is wider than the functions return type.

From-SVN: r23321

gcc/cp/ChangeLog
gcc/cp/typeck.c

index bb915a73168c9c9b588eeb7a92c0117d036f50c1..26dda44494689bc3747efd199b6ff5e8191e8b52 100644 (file)
@@ -33,6 +33,11 @@ Fri Oct  2 02:07:26 1998  Mumit Khan  <khan@xraylith.wisc.edu>
        * decl.c (duplicate_decls): Don't complain about different
        exceptions from an internal decl even if pedantic.
 
+1998-08-24  Gavin Romig-Koch  <gavin@cygnus.com>
+
+       * typeck.c (c_expand_return): Handle the case that valtype
+       is wider than the functions return type.
+
 1998-08-17  Mark Mitchell  <mark@markmitchell.com>
 
        * pt.c (check_explicit_specialization): Don't abort on bogus
index a1c1394d17b3c62a5fa9461eeefa4e139cca7f4f..197aab7d985adc1fe2b180f740c65dc495125156 100644 (file)
@@ -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.  */