OSDN Git Service

cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 3 Jan 2001 15:01:16 +0000 (15:01 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 3 Jan 2001 15:01:16 +0000 (15:01 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38661 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/search.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/virtual11.C [new file with mode: 0644]

index bee60d6..492a4dc 100644 (file)
@@ -1,5 +1,11 @@
 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.
+
+2001-01-03  Nathan Sidwell  <nathan@codesourcery.com>
+
        Implement exceptions specifiers for implicit member functions.
        * cp-tree.h (merge_exceptions_specifiers): Declare new function.
        * method.c (synthesize_exception_spec): New function.
index e2fab52..5beedb0 100644 (file)
@@ -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))
index c45ae5c..32b8349 100644 (file)
@@ -1,5 +1,9 @@
 2001-01-03  Nathan Sidwell  <nathan@codesourcery.com>
 
+       * g++.old-deja/g++.other/virtual11.C: New test.
+
+2001-01-03  Nathan Sidwell  <nathan@codesourcery.com>
+
        * g++.old-deja/g++.eh/spec6.C: Remove remaining XFAIL.
 
 2001-01-02  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
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 (file)
index 0000000..62c9b24
--- /dev/null
@@ -0,0 +1,31 @@
+// 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
+};