From: Nathan Sidwell Date: Wed, 3 Jan 2001 15:01:16 +0000 (+0000) Subject: search.c (lookup_fnfields_here): Remove. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c505507d343cb5d3f9634dea4a8c96675546629;p=gcc.git search.c (lookup_fnfields_here): Remove. cp: * search.c (lookup_fnfields_here): Remove. (look_for_overrides_r): Use lookup_fnfields_1. Ignore functions from using declarations. testsuite: * g++.old-deja/g++.other/virtual11.C: New test. From-SVN: r38661 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bee60d6bbc1..492a4dc4619 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2001-01-03 Nathan Sidwell + + * search.c (lookup_fnfields_here): Remove. + (look_for_overrides_r): Use lookup_fnfields_1. + Ignore functions from using declarations. + 2001-01-03 Nathan Sidwell Implement exceptions specifiers for implicit member functions. diff --git a/gcc/cp/search.c b/gcc/cp/search.c index e2fab522fa9..5beedb0a607 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -85,7 +85,6 @@ struct vbase_info 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 *)); @@ -1249,33 +1248,6 @@ is_subobject_of_p (parent, binfo, most_derived) 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; @@ -2015,7 +1987,7 @@ look_for_overrides_r (type, fndecl) if (DECL_DESTRUCTOR_P (fndecl)) ix = CLASSTYPE_DESTRUCTOR_SLOT; else - ix = lookup_fnfields_here (type, DECL_NAME (fndecl)); + ix = lookup_fnfields_1 (type, DECL_NAME (fndecl)); if (ix >= 0) { tree fns = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), ix); @@ -2029,7 +2001,9 @@ look_for_overrides_r (type, fndecl) 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)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c45ae5cbef8..32b834958af 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-01-03 Nathan Sidwell + + * g++.old-deja/g++.other/virtual11.C: New test. + 2001-01-03 Nathan Sidwell * g++.old-deja/g++.eh/spec6.C: Remove remaining XFAIL. diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual11.C b/gcc/testsuite/g++.old-deja/g++.other/virtual11.C new file mode 100644 index 00000000000..62c9b24613f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual11.C @@ -0,0 +1,31 @@ +// Build don't link: + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Nov 2000 + +// 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 +};