decl.c (start_decl): Remove redundant linkage check.
authorJason Merrill <jason@gcc.gnu.org>
Mon, 24 Aug 1998 16:31:38 +0000 (12:31 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 24 Aug 1998 16:31:38 +0000 (12:31 -0400)
* decl.c (start_decl): Remove redundant linkage check.
* typeck.c (c_expand_return): Handle the case that valtype
is wider than the functions return type.

From-SVN: r21950

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

index 3297c38004612948073bf8db3d1784e4a3d5caef..d171e64820b7e963005cc898deb405845ec199a5 100644 (file)
@@ -1,3 +1,12 @@
+1998-08-24  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * decl.c (start_decl): Remove redundant linkage check.
+
+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-24  Mark Mitchell  <mark@markmitchell.com>
 
        * cp-tree.h (CLASS_TYPE_P): New macro.
index 087df2fa93421098775bedfe4adef8c5092ba04f..8d3d6d9e492953a9c6a386a770b48a43bd8b0d8d 100644 (file)
@@ -6642,26 +6642,6 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
   /* Corresponding pop_obstacks is done in `cp_finish_decl'.  */
   push_obstacks_nochange ();
 
-  /* [basic.link]: A name with no linkage (notably, the name of a class or
-     enumeration declared in a local scope) shall not be used to declare an
-     entity with linkage.
-
-     Only check this for public decls for now.  */
-  if (TREE_PUBLIC (tem))
-    {
-      tree t = no_linkage_check (TREE_TYPE (tem));
-      if (t)
-       {
-         if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)))
-           {
-             if (TREE_CODE (tem) == FUNCTION_DECL)
-               cp_pedwarn ("public decl `%#D' uses anonymous type", tem);
-           }
-         else
-           cp_pedwarn ("non-local decl `%#D' uses local type `%T'", tem, t);
-       }
-    }
-
 #if 0
   /* We have no way of knowing whether the initializer will need to be
      evaluated at run-time or not until we've parsed it, so let's just put
@@ -7939,9 +7919,10 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
       if (t)
        {
          if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)))
-           cp_pedwarn ("function `%#D' uses anonymous type", decl);
+           cp_pedwarn ("non-local function `%#D' uses anonymous type", decl);
          else
-           cp_pedwarn ("function `%#D' uses local type `%T'", decl, t);
+           cp_pedwarn ("non-local function `%#D' uses local type `%T'",
+                       decl, t);
        }
     }
 
index 3bbd6bdd0a07c50f166db6cda955109626d78e66..5800f79eef98dc07379345cf611ad155161bcd16 100644 (file)
@@ -7362,10 +7362,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.  */