This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [C++] deprecate overload resolution extension?
Mark Mitchell wrote:
> Nathan, if you care to implement that, go for it.
Gone for it. Built & tested on i686-pc-linux-gnu, ok for
mainline & branch?
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-02-28 Nathan Sidwell <nathan@codesourcery.com>
* call.c (joust): cp_pedwarn when using gnu extension concerning
worst conversion sequences.
Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/call.c,v
retrieving revision 1.262
diff -c -3 -p -r1.262 call.c
*** call.c 2001/02/26 15:59:30 1.262
--- call.c 2001/02/28 12:32:49
*************** tweak:
*** 5312,5317 ****
--- 5312,5318 ----
if (!pedantic)
{
int rank1 = IDENTITY_RANK, rank2 = IDENTITY_RANK;
+ struct z_candidate *w, *l;
for (i = 0; i < len; ++i)
{
*************** tweak:
*** 5320,5330 ****
if (ICS_RANK (TREE_VEC_ELT (cand2->convs, i+off2)) > rank2)
rank2 = ICS_RANK (TREE_VEC_ELT (cand2->convs, i+off2));
}
-
if (rank1 < rank2)
! return 1;
if (rank1 > rank2)
! return -1;
}
my_friendly_assert (!winner, 20010121);
--- 5321,5342 ----
if (ICS_RANK (TREE_VEC_ELT (cand2->convs, i+off2)) > rank2)
rank2 = ICS_RANK (TREE_VEC_ELT (cand2->convs, i+off2));
}
if (rank1 < rank2)
! winner = 1, w = cand1, l = cand2;
if (rank1 > rank2)
! winner = -1, w = cand2, l = cand1;
! if (winner)
! {
! if (warn)
! {
! cp_pedwarn ("choosing `%D' over `%D'", w->fn, l->fn);
! cp_pedwarn (
! " because worst conversion for the former is better than worst conversion for the latter");
! }
! else
! add_warning (w, l);
! return winner;
! }
}
my_friendly_assert (!winner, 20010121);
// Build don't link:
// Special g++ Options: -fpermissive
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 28 Feb 2001 <nathan@codesourcery.com>
// Make sure we warn about our overload extension about picking the
// one with the least worse conversion
struct X
{
X (int);
};
void Foo (int, float, bool);
void Foo (float, int, X);
void Baz ()
{
Foo (1, 1, 0); // WARNING - least worse
}