+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.
/* 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
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);
}
}
}
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. */