From ae209f284cc478ff5839488722fd4f52a04c2eee Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 1 Nov 2004 18:24:33 +0000 Subject: [PATCH] re PR c++/18064 (gcc accepts different pointer types as covariant return types) cp: PR c++/18064 * search.c (check_final_overrider): Deprecate gnu covariant extension. doc: PR c++/18064 * doc/extend.texi (Deprecated Features): Deprecate G++ covariant extension. testsuite: PR c++/18064 * g++.old-deja/g++.mike/p811.C: Avoid covariant extension. From-SVN: r89946 --- gcc/ChangeLog | 6 ++++++ gcc/cp/ChangeLog | 5 +++++ gcc/cp/search.c | 6 ++++++ gcc/doc/extend.texi | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.old-deja/g++.mike/p811.C | 4 ++-- 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bfae47a04d3..067be2934f8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-11-01 Nathan Sidwell + + PR c++/18064 + * doc/extend.texi (Deprecated Features): Deprecate G++ covariant + extension. + 2004-10-16 Daniel Berlin Fix PR tree-optimization/17672 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bea717b65fe..022148e9165 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2004-11-01 Nathan Sidwell + + PR c++/18064 + * search.c (check_final_overrider): Deprecate gnu covariant extension. + 2004-10-31 Gabriel Dos Reis Convert diagnostics to use quoting flag q 9/n diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 68a42f2630f..9e6178ea286 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1830,6 +1830,12 @@ check_final_overrider (tree overrider, tree basefn) over_return = non_reference (TREE_TYPE (over_type)); if (CLASS_TYPE_P (over_return)) fail = 2; + else + { + cp_warning_at ("deprecated covariant return type for %q#D", + overrider); + cp_warning_at (" overriding %q#D", basefn); + } } else fail = 2; diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 45653b12277..a4cbb2f69c0 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -9711,6 +9711,11 @@ parameters, as C++ demands. This feature has been removed, except where it is required for backwards compatibility @xref{Backwards Compatibility}. @end table +G++ allows a virtual function returning @samp{void *} to be overridden +by one returning a different pointer type. This extension to the +covariant return type rules is now deprecated and will be removed from a +future version. + The named return value extension has been deprecated, and is now removed from G++. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 994723eb5c4..3b08af5d047 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-11-01 Nathan Sidwell + + PR c++/18064 + * g++.old-deja/g++.mike/p811.C: Avoid covariant extension. + 2004-10-31 Mark Mitchell PR c++/15172 diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p811.C b/gcc/testsuite/g++.old-deja/g++.mike/p811.C index 7d15e9ed8aa..260c6459cb8 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/p811.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/p811.C @@ -511,14 +511,14 @@ inline istream& WS(istream& str) { return ws(str); } class Y { public: Y() {} - virtual const char *stringify() = 0; + virtual const char *stringify() = 0; virtual char *stringify2() const = 0; // { dg-error "overriding" } }; class X: public Y { public: X(): Y() {} - char *stringify(); // { dg-error "candidate" } + const char *stringify(); // { dg-error "candidate" } const char *stringify2() const; // { dg-error "candidate|conflicting return type" } };