This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ patch]: virtual overriders and using
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ patch]: virtual overriders and using
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Wed, 03 Jan 2001 15:08:22 +0000
- Organization: Codesourcery LLC
Hi,
under the obvious rule I've installed the attached patch and testcase which
makes us now ignore using declarations when checking virtual overriders as per
[10.3]/2. As Jason's recent patch to lookup_field_r also stopped using
lookup_fnfields_here, that function's deleted.
built & tested on i686-pc-linux-gnu
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-01-03 Nathan Sidwell <nathan@codesourcery.com>
* search.c (lookup_fnfields_here): Remove.
(look_for_overrides_r): Use lookup_fnfields_1.
Ignore functions from using declarations.
Index: cp/search.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/search.c,v
retrieving revision 1.196
diff -c -3 -p -r1.196 search.c
*** search.c 2001/01/03 14:39:09 1.196
--- search.c 2001/01/03 14:45:20
*************** struct vbase_info
*** 85,91 ****
static tree get_vbase_1 PARAMS ((tree, tree, unsigned int *));
static tree lookup_field_1 PARAMS ((tree, tree));
- static int lookup_fnfields_here PARAMS ((tree, tree));
static int is_subobject_of_p PARAMS ((tree, tree, tree));
static tree virtual_context PARAMS ((tree, tree, tree));
static tree dfs_check_overlap PARAMS ((tree, void *));
--- 85,90 ----
*************** is_subobject_of_p (parent, binfo, most_d
*** 1249,1281 ****
return 0;
}
- /* Very similar to lookup_fnfields_1 but it ensures that at least one
- function was declared inside the class given by TYPE. It really should
- only return functions that match the given TYPE. Therefore, it should
- only be called for situations that ignore using-declarations, such as
- determining overrides. */
-
- static int
- lookup_fnfields_here (type, name)
- tree type, name;
- {
- int idx = lookup_fnfields_1 (type, name);
- tree fndecls;
-
- /* ctors and dtors are always only in the right class. */
- if (idx <= 1)
- return idx;
- fndecls = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), idx);
- while (fndecls)
- {
- if (TYPE_MAIN_VARIANT (DECL_CONTEXT (OVL_CURRENT (fndecls)))
- == TYPE_MAIN_VARIANT (type))
- return idx;
- fndecls = OVL_CHAIN (fndecls);
- }
- return -1;
- }
-
struct lookup_field_info {
/* The type in which we're looking. */
tree type;
--- 1248,1253 ----
*************** look_for_overrides_r (type, fndecl)
*** 2015,2021 ****
if (DECL_DESTRUCTOR_P (fndecl))
ix = CLASSTYPE_DESTRUCTOR_SLOT;
else
! ix = lookup_fnfields_here (type, DECL_NAME (fndecl));
if (ix >= 0)
{
tree fns = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), ix);
--- 1987,1993 ----
if (DECL_DESTRUCTOR_P (fndecl))
ix = CLASSTYPE_DESTRUCTOR_SLOT;
else
! ix = lookup_fnfields_1 (type, DECL_NAME (fndecl));
if (ix >= 0)
{
tree fns = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), ix);
*************** look_for_overrides_r (type, fndecl)
*** 2029,2035 ****
tree btypes = TYPE_ARG_TYPES (TREE_TYPE (fn));
if (!DECL_VIRTUAL_P (fn))
! ;
else if (thistype == NULL_TREE)
{
if (compparms (TREE_CHAIN (btypes), dtypes))
--- 2001,2009 ----
tree btypes = TYPE_ARG_TYPES (TREE_TYPE (fn));
if (!DECL_VIRTUAL_P (fn))
! /* Not a virtual */;
! else if (DECL_CONTEXT (fn) != type)
! /* Introduced with a using declaration */;
else if (thistype == NULL_TREE)
{
if (compparms (TREE_CHAIN (btypes), dtypes))
// Build don't link:
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 14 Nov 2000 <nathan@codesourcery.com>
// We failed to check virtual functions hidden by using declarations.
struct A
{
virtual int foo ();
};
struct B
{
virtual void foo (); // ERROR - of this function
};
struct C : A , B
{
};
struct D : C
{
void foo (short);
using A::foo;
};
struct E : D
{
virtual int foo (); // ERROR - invalid override
};