From 9e7ac8eb610c3071096a639a9e39e6e50021465c Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 4 Mar 2011 15:17:55 +0000 Subject: [PATCH] PR c++/46220 * search.c (check_final_overrider): Allow pointer to same incomplete class type with different cv-quals. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170676 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/search.c | 14 ++++++++++---- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/inherit/covariant19.C | 14 ++++++++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/inherit/covariant19.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 747457a..ce4ade1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-03-04 Jason Merrill + + PR c++/46220 + * search.c (check_final_overrider): Allow pointer to same incomplete + class type with different cv-quals. + 2011-03-03 Paolo Carlini PR c++/47974 diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 188f0a5..07ec9ef 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1835,11 +1835,17 @@ check_final_overrider (tree overrider, tree basefn) if (CLASS_TYPE_P (base_return) && CLASS_TYPE_P (over_return)) { - tree binfo = lookup_base (over_return, base_return, - ba_check | ba_quiet, NULL); + /* Strictly speaking, the standard requires the return type to be + complete even if it only differs in cv-quals, but that seems + like a bug in the wording. */ + if (!same_type_ignoring_top_level_qualifiers_p (base_return, over_return)) + { + tree binfo = lookup_base (over_return, base_return, + ba_check | ba_quiet, NULL); - if (!binfo) - fail = 1; + if (!binfo) + fail = 1; + } } else if (!pedantic && can_convert (TREE_TYPE (base_type), TREE_TYPE (over_type))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e49bd79..c56bea4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-03-04 Jason Merrill + + * g++.dg/inherit/covariant19.C: New. + 2011-03-04 Richard Guenther PR middle-end/47968 diff --git a/gcc/testsuite/g++.dg/inherit/covariant19.C b/gcc/testsuite/g++.dg/inherit/covariant19.C new file mode 100644 index 0000000..22c2b0e --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/covariant19.C @@ -0,0 +1,14 @@ +// PR c++/46220 +// According to the letter of the standard this is invalid, +// but that seems like a bug. + +class Baz; +class Foo { +public: + virtual const Baz* getBaz() = 0; +}; +class Bar : public Foo { +public: + Baz* getBaz(); +}; + -- 2.7.4