+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>
/* 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;
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
* g++.dg/ext/label1.C: New test.
* g++.dg/ext/label2.C: Likewise.
--- /dev/null
+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);
+}