diff options
author | Mark Mitchell <mark@codesourcery.com> | 2003-08-29 23:51:17 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-08-29 23:51:17 +0000 |
commit | 20d6556070b6952b34cb92622fd61f051216bc37 (patch) | |
tree | c0a5cc434b3f8c8eb3b9c6539cd08a9664d7c38e /gcc | |
parent | 4985cde3ef44391a43fd95c0972bf72c86e127cb (diff) | |
download | gcc-20d6556070b6952b34cb92622fd61f051216bc37.zip gcc-20d6556070b6952b34cb92622fd61f051216bc37.tar.gz gcc-20d6556070b6952b34cb92622fd61f051216bc37.tar.bz2 |
re PR c++/11928 (c++ typedef handling)
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/search.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/inherit/conv1.C | 23 |
4 files changed, 55 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 503a3b8..fc18cc1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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> diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 29e6172..3751c00 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7b983d8..c057ea2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 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. diff --git a/gcc/testsuite/g++.dg/inherit/conv1.C b/gcc/testsuite/g++.dg/inherit/conv1.C new file mode 100644 index 0000000..e16c489 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/conv1.C @@ -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); +} |