call.c (joust): cp_pedwarn when using gnu extension concerning worst conversion sequences.

cp:
	* call.c (joust): cp_pedwarn when using gnu extension concerning
	worst conversion sequences.
testsuite:
	* g++.old-deja/g++.ext/overload1.C: New test.

From-SVN: r40182
This commit is contained in:
Nathan Sidwell 2001-03-02 11:32:45 +00:00 committed by Nathan Sidwell
parent 68af29ce9d
commit f86fdf68cf
4 changed files with 44 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2001-03-02 Nathan Sidwell <nathan@codesourcery.com>
* call.c (joust): cp_pedwarn when using gnu extension concerning
worst conversion sequences.
2001-03-01 Zack Weinberg <zackw@stanford.edu>
* decl.c: Replace all uses of 'boolean' with 'bool'.

View File

@ -5312,6 +5312,7 @@ tweak:
if (!pedantic)
{
int rank1 = IDENTITY_RANK, rank2 = IDENTITY_RANK;
struct z_candidate *w, *l;
for (i = 0; i < len; ++i)
{
@ -5320,11 +5321,22 @@ tweak:
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;
winner = 1, w = cand1, l = cand2;
if (rank1 > rank2)
return -1;
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);

View File

@ -1,3 +1,7 @@
2001-03-02 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.ext/overload1.C: New test.
2001-03-01 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.pt/using1.C: New test.

View File

@ -0,0 +1,20 @@
// 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
}