This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PR 18064] Deprecate covariant extension
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 01 Nov 2004 18:22:03 +0000
- Subject: [PR 18064] Deprecate covariant extension
- Organization: Codesourcery LLC
This patch fixes 18064 by deprecating the gnu covariant extension of allowing
a 'void *' function to be overridden by a 'T *' function. The feedback
on my post asking about preferences was all infavour of removal.
booted & tested on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2004-11-01 Nathan Sidwell <nathan@codesourcery.com>
PR c++/18064
* search.c (check_final_overrider): Deprecate gnu covariant extension.
PR c++/18064
* doc/extend.texi (Deprecated Features): Deprecate G++ covariant
extension.
PR c++/18064
* g++.old-deja/g++.mike/p811.C: Avoid covariant extension.
Index: cp/search.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/search.c,v
retrieving revision 1.337
diff -c -3 -p -r1.337 search.c
*** cp/search.c 27 Oct 2004 05:51:24 -0000 1.337
--- cp/search.c 1 Nov 2004 18:07:11 -0000
*************** check_final_overrider (tree overrider, t
*** 1830,1835 ****
--- 1830,1841 ----
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;
Index: doc/extend.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/extend.texi,v
retrieving revision 1.227
diff -c -3 -p -r1.227 extend.texi
*** doc/extend.texi 28 Oct 2004 01:00:28 -0000 1.227
--- doc/extend.texi 1 Nov 2004 18:07:36 -0000
*************** parameters, as C++ demands. This featur
*** 9711,9716 ****
--- 9711,9721 ----
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++.
Index: testsuite/g++.old-deja/g++.mike/p811.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.mike/p811.C,v
retrieving revision 1.5
diff -c -3 -p -r1.5 p811.C
*** testsuite/g++.old-deja/g++.mike/p811.C 23 Sep 2004 21:27:21 -0000 1.5
--- testsuite/g++.old-deja/g++.mike/p811.C 1 Nov 2004 18:07:37 -0000
*************** inline istream& WS(istream& str) { retur
*** 511,524 ****
class Y {
public:
Y() {}
! 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 *stringify2() const; // { dg-error "candidate|conflicting return type" }
};
--- 511,524 ----
class Y {
public:
Y() {}
! virtual const char *stringify() = 0;
virtual char *stringify2() const = 0; // { dg-error "overriding" }
};
class X: public Y {
public:
X(): Y() {}
! const char *stringify(); // { dg-error "candidate" }
const char *stringify2() const; // { dg-error "candidate|conflicting return type" }
};