mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-11 19:50:54 +08:00
c++: fix tourney logic
In r13-3766 I changed the logic at the end of tourney to avoid redundant comparisons, but the change also meant skipping any less-good matches between the champ_compared_to_predecessor candidate and champ itself. This should not be a correctness issue, since we believe that joust is a partial order. But it can lead to missed warnings, as in this testcase. gcc/cp/ChangeLog: * call.cc (tourney): Only skip champ_compared_to_predecessor. gcc/testsuite/ChangeLog: * g++.dg/warn/Wsign-promo1.C: New test.
This commit is contained in:
parent
084addf8a7
commit
ff04531b66
@ -13227,10 +13227,11 @@ tourney (struct z_candidate *candidates, tsubst_flags_t complain)
|
||||
been compared to. */
|
||||
|
||||
for (challenger = candidates;
|
||||
challenger != champ
|
||||
&& challenger != champ_compared_to_predecessor;
|
||||
challenger != champ;
|
||||
challenger = challenger->next)
|
||||
{
|
||||
if (challenger == champ_compared_to_predecessor)
|
||||
continue;
|
||||
fate = joust (champ, challenger, 0, complain);
|
||||
if (fate != 1)
|
||||
return NULL;
|
||||
|
15
gcc/testsuite/g++.dg/warn/Wsign-promo1.C
Normal file
15
gcc/testsuite/g++.dg/warn/Wsign-promo1.C
Normal file
@ -0,0 +1,15 @@
|
||||
// Check that we get joust warnings from comparing the final champ to a
|
||||
// candidate between it and the previous champ.
|
||||
|
||||
// { dg-additional-options -Wsign-promo }
|
||||
|
||||
struct A { A(int); };
|
||||
|
||||
enum E { e };
|
||||
|
||||
int f(int, A);
|
||||
int f(unsigned, A);
|
||||
int f(int, int);
|
||||
|
||||
int i = f(e, 42); // { dg-warning "passing 'E'" }
|
||||
// { dg-warning "in call to 'int f" "" { target *-*-* } .-1 }
|
Loading…
Reference in New Issue
Block a user