]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/11928 (c++ typedef handling)
authorMark Mitchell <mark@codesourcery.com>
Fri, 29 Aug 2003 23:51:17 +0000 (23:51 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 29 Aug 2003 23:51:17 +0000 (23:51 +0000)
PR c++/11928
* search.c (add_conversions): Avoid adding two conversion
operators for the same type.

PR c++/11928
* g++.dg/inherit/conv1.C: New test.

From-SVN: r70934

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

index 503a3b86e5be5746aee5afa878a8337ae6903863..fc18cc116f8e272daf4d91e3ef4bba2c05087b4b 100644 (file)
@@ -1,3 +1,9 @@
+2003-08-29  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/11928
+       * search.c (add_conversions): Avoid adding two conversion
+       operators for the same type.
+
 2003-08-29  Richard Henderson  <rth@redhat.com>
            Jason Merrill <jason@redhat.com>
 
index 29e6172c325fc2003ee73b5c8d43a637240440a1..3751c006d131b72fce019ae9fc7b81ee5d25c641 100644 (file)
@@ -2323,8 +2323,27 @@ add_conversions (tree binfo, void *data)
       /* Make sure we don't already have this conversion.  */
       if (! IDENTIFIER_MARKED (name))
        {
-         *conversions = tree_cons (binfo, tmp, *conversions);
-         IDENTIFIER_MARKED (name) = 1;
+         tree t;
+
+         /* Make sure that we do not already have a conversion
+            operator for this type.  Merely checking the NAME is not
+            enough because two conversion operators to the same type
+            may not have the same NAME.  */
+         for (t = *conversions; t; t = TREE_CHAIN (t))
+           {
+             tree fn;
+             for (fn = TREE_VALUE (t); fn; fn = OVL_NEXT (fn))
+               if (same_type_p (TREE_TYPE (name),
+                                DECL_CONV_FN_TYPE (OVL_CURRENT (fn))))
+                 break;
+             if (fn)
+               break;
+           }
+         if (!t)
+           {
+             *conversions = tree_cons (binfo, tmp, *conversions);
+             IDENTIFIER_MARKED (name) = 1;
+           }
        }
     }
   return NULL_TREE;
index 7b983d8e743b8da0f4b83df332834d459b9faf21..c057ea2644a4b72316bb8ea9a54030b93dced732 100644 (file)
@@ -1,3 +1,8 @@
+2003-08-29  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/11928
+       * g++.dg/inherit/conv1.C: New test.
+
 2003-08-29  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/6196
diff --git a/gcc/testsuite/g++.dg/inherit/conv1.C b/gcc/testsuite/g++.dg/inherit/conv1.C
new file mode 100644 (file)
index 0000000..e16c489
--- /dev/null
@@ -0,0 +1,23 @@
+typedef struct _A A;
+typedef struct _A B;
+
+void some_function(B *b);
+
+class AClass {
+
+public:
+  operator A*() { return 0;}
+
+};
+
+class BClass :public AClass {
+
+public:
+  operator B*() { return 0;}
+
+};
+
+int main(int argc, char **argv) {
+  BClass b;
+  some_function(b);
+}
This page took 0.120287 seconds and 5 git commands to generate.