Commit cce2be43 by Jason Merrill

decl.c (start_decl): Remove redundant linkage check.

	* 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
parent 5637343a
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.
......
......@@ -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);
}
}
......
......@@ -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. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment