This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: Fix PR c++/11928
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 29 Aug 2003 16:52:57 -0700
- Subject: C++ PATCH: Fix PR c++/11928
- Reply-to: mark at codesourcery dot com
This patch fixes PR c++/11928, which is fallout from the way in which
I changed conversion operator naming to avoid problems with templates.
Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
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 Mark Mitchell <mark@codesourcery.com>
PR c++/11928
* g++.dg/inherit/conv1.C: New test.
Index: cp/search.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/search.c,v
retrieving revision 1.279
diff -c -5 -p -r1.279 search.c
*** cp/search.c 23 Aug 2003 13:02:15 -0000 1.279
--- cp/search.c 29 Aug 2003 23:46:39 -0000
*************** add_conversions (tree binfo, void *data)
*** 2321,2332 ****
name = DECL_NAME (OVL_CURRENT (tmp));
/* Make sure we don't already have this conversion. */
if (! IDENTIFIER_MARKED (name))
{
! *conversions = tree_cons (binfo, tmp, *conversions);
! IDENTIFIER_MARKED (name) = 1;
}
}
return NULL_TREE;
}
--- 2321,2351 ----
name = DECL_NAME (OVL_CURRENT (tmp));
/* Make sure we don't already have this conversion. */
if (! IDENTIFIER_MARKED (name))
{
! 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: testsuite/g++.dg/inherit/conv1.C
===================================================================
RCS file: testsuite/g++.dg/inherit/conv1.C
diff -N testsuite/g++.dg/inherit/conv1.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/inherit/conv1.C 29 Aug 2003 23:46:40 -0000
***************
*** 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);
+ }