From: Jason Merrill Date: Mon, 17 Nov 1997 19:37:07 +0000 (+0000) Subject: search.c (dfs_record_inheritance): Ignore template type parms. X-Git-Tag: releases/egcs-1.0.0~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d65b9e64e07260e536573f89e9d666e9f6f57590;p=thirdparty%2Fgcc.git search.c (dfs_record_inheritance): Ignore template type parms. * search.c (dfs_record_inheritance): Ignore template type parms. Fixes 13688. * friend.c (do_friend): Warn about non-template friends in templates. * call.c (build_op_delete_call): Fix handling of inherited delete. From-SVN: r16552 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 597d7350550d..63a343589b95 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +Mon Nov 17 02:01:28 1997 Jason Merrill + + * friend.c (do_friend): Warn about non-template friends in templates. + + * call.c (build_op_delete_call): Fix handling of inherited delete. + + * search.c (dfs_record_inheritance): Ignore template type parms. + Sat Nov 15 00:30:51 1997 Jason Merrill * call.c (build_new_op): Fix copy error. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index e3086dda3952..a686dc2fd189 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5125,15 +5125,17 @@ build_op_delete_call (code, addr, size, flags) fnname = ansi_opname[code]; if (IS_AGGR_TYPE (type) && ! (flags & LOOKUP_GLOBAL)) - /* Here we make assumptions about how instantiate_type works. This comes - out as a simple TREE_LIST, so it looks like overloaded globals to - instantiate_type; this works out fine. If something changes we - might have to build this up like build_offset_ref does. */ fns = lookup_fnfields (TYPE_BINFO (type), fnname, 0); else fns = NULL_TREE; - if (fns == NULL_TREE) + if (fns) + { + /* Build this up like build_offset_ref does. */ + fns = build_tree_list (error_mark_node, fns); + TREE_TYPE (fns) = build_offset_type (type, unknown_type_node); + } + else fns = lookup_name_nonclass (fnname); /* We can recognize a placement delete because of LOOKUP_SPECULATIVELY; @@ -5182,7 +5184,7 @@ build_op_delete_call (code, addr, size, flags) { if (TREE_PURPOSE (fns)) /* TREE_PURPOSE is only set for lists of member functions. */ - enforce_access (TREE_PURPOSE (fns), fn); + enforce_access (TREE_PURPOSE (TREE_VALUE (fns)), fn); return build_function_call (fn, expr_tree_cons (NULL_TREE, addr, args)); } diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index fbfffe77f23a..28c0bb44a68e 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -381,10 +381,26 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag) DECL_CLASS_CONTEXT (decl) = current_class_type; if (! DECL_USE_TEMPLATE (decl)) - /* We can call pushdecl here, because the TREE_CHAIN of this - FUNCTION_DECL is not needed for other purposes. Don't do this - for a template instantiation. */ - decl = pushdecl (decl); + { + /* We can call pushdecl here, because the TREE_CHAIN of this + FUNCTION_DECL is not needed for other purposes. Don't do this + for a template instantiation. */ + decl = pushdecl (decl); + + if (! funcdef_flag && ! flag_guiding_decls + && current_template_parms && uses_template_parms (decl)) + { + static int explained; + cp_warning ("friend declaration `%#D'", decl); + warning (" will not be treated as a template instantiation"); + if (! explained) + { + warning (" unless you compile with -fguiding-decls"); + warning (" or add <> after the function name"); + explained = 1; + } + } + } make_decl_rtl (decl, NULL_PTR, 1); add_friend (current_class_type, decl); diff --git a/gcc/cp/search.c b/gcc/cp/search.c index d75fe62dff2b..03e00fa88985 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -3134,6 +3134,10 @@ dfs_record_inheritance (binfo) tree baseclass = BINFO_TYPE (base_binfo); mi_boolean *base_row = BINFO_DERIVES_FROM_STAR (base_binfo); + if (TREE_CODE (baseclass) == TEMPLATE_TYPE_PARM) + continue; + my_friendly_assert (CLASSTYPE_CID (baseclass) != 0, 2365); + /* Don't search if there's nothing there! MI_SIZE can be zero as a result of parse errors. */ if (TYPE_BINFO_BASETYPES (baseclass) && mi_size > 0)