From cce2be438d67e6514c60ce887d0142c9b32dc407 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 24 Aug 1998 12:31:38 -0400 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 9 +++++++++ gcc/cp/decl.c | 25 +++---------------------- gcc/cp/typeck.c | 10 +++++++++- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3297c380046..d171e64820b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +1998-08-24 Jason Merrill + + * decl.c (start_decl): Remove redundant linkage check. + +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-24 Mark Mitchell * cp-tree.h (CLASS_TYPE_P): New macro. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 087df2fa934..8d3d6d9e492 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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); } } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 3bbd6bdd0a0..5800f79eef9 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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. */ -- 2.30.2