OSDN Git Service

PR c++/13323
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 6 Dec 2003 22:11:45 +0000 (22:11 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 6 Dec 2003 22:11:45 +0000 (22:11 +0000)
* class.c (same_signature_p): Handle conversion operators
correctly.
(check_for_override): Likewise.

PR c++/13323
* g++.dg/inherit/operator2.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/inherit/operator2.C [new file with mode: 0644]

index 7127625..f2ec0e7 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-06  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/13323
+       * class.c (same_signature_p): Handle conversion operators
+       correctly.
+       (check_for_override): Likewise.
+
 2003-12-06  Kelley Cook  <kcook@gcc.gnu.org>
 
        * Make-lang.in (GXX_CROSS_NAME, CXX_CROSS_NAME): Delete.
index 1e1b71c..72f03a2 100644 (file)
@@ -1900,7 +1900,11 @@ same_signature_p (tree fndecl, tree base_fndecl)
   if (DECL_DESTRUCTOR_P (base_fndecl) || DECL_DESTRUCTOR_P (fndecl))
     return 0;
 
-  if (DECL_NAME (fndecl) == DECL_NAME (base_fndecl))
+  if (DECL_NAME (fndecl) == DECL_NAME (base_fndecl)
+      || (DECL_CONV_FN_P (fndecl)
+         && DECL_CONV_FN_P (base_fndecl)
+         && same_type_p (DECL_CONV_FN_TYPE (fndecl),
+                         DECL_CONV_FN_TYPE (base_fndecl))))
     {
       tree types, base_types;
       types = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
@@ -2439,7 +2443,8 @@ check_for_override (tree decl, tree ctype)
          override a virtual function from a base class.  */
     return;
   if ((DECL_DESTRUCTOR_P (decl)
-       || IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)))
+       || IDENTIFIER_VIRTUAL_P (DECL_NAME (decl))
+       || DECL_CONV_FN_P (decl))
       && look_for_overrides (ctype, decl)
       && !DECL_STATIC_FUNCTION_P (decl))
     /* Set DECL_VINDEX to a value that is neither an INTEGER_CST nor
index f6fd9ff..d65ed73 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-06  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/13323
+       * g++.dg/inherit/operator2.C: New test.
+
 2003-12-05  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/13305
diff --git a/gcc/testsuite/g++.dg/inherit/operator2.C b/gcc/testsuite/g++.dg/inherit/operator2.C
new file mode 100644 (file)
index 0000000..09407e1
--- /dev/null
@@ -0,0 +1,22 @@
+typedef int INT_TYPEDEF;
+
+template<class T>
+class TypedIfc
+{
+public:
+  virtual ~TypedIfc() { }
+  virtual operator const T&() const = 0;
+  virtual const T& operator= (const T& t) = 0;
+};
+
+template<class Tnative>
+class NullIfc : public TypedIfc<Tnative>
+{
+public:
+  const Tnative& operator= (const Tnative& t) { return t; }
+  operator const Tnative&() const { return *(Tnative *)0; }
+};
+
+typedef TypedIfc<INT_TYPEDEF> INT_TYPEDEFIfc;
+
+NullIfc<int> i32;