From: Nathan Sidwell Date: Fri, 2 Mar 2001 11:32:45 +0000 (+0000) Subject: call.c (joust): cp_pedwarn when using gnu extension concerning worst conversion seque... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f86fdf68cfe35212160b8d337c7db7110ad0da8d;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 41a7a0681ef..78899b633a2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2001-03-02 Nathan Sidwell + + * call.c (joust): cp_pedwarn when using gnu extension concerning + worst conversion sequences. + 2001-03-01 Zack Weinberg * decl.c: Replace all uses of 'boolean' with 'bool'. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index a9af4027f78..69c58db2d43 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0a1a3ecaf40..6c43b68b00e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-03-02 Nathan Sidwell + + * g++.old-deja/g++.ext/overload1.C: New test. + 2001-03-01 Nathan Sidwell * g++.old-deja/g++.pt/using1.C: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.ext/overload1.C b/gcc/testsuite/g++.old-deja/g++.ext/overload1.C new file mode 100644 index 00000000000..d99e04fecb8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/overload1.C @@ -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 + +// 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 +}