aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-03-02 11:32:45 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-03-02 11:32:45 +0000
commitf86fdf68cfe35212160b8d337c7db7110ad0da8d (patch)
tree076e53a672290384755954f3a9c2aa2931ac5068
parent68af29ce9d38679a82821886eb776aa5b423e117 (diff)
downloadgcc-f86fdf68cfe35212160b8d337c7db7110ad0da8d.zip
gcc-f86fdf68cfe35212160b8d337c7db7110ad0da8d.tar.gz
gcc-f86fdf68cfe35212160b8d337c7db7110ad0da8d.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/call.c18
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.ext/overload1.C20
4 files changed, 44 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 41a7a06..78899b6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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'.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index a9af402..69c58db 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 0a1a3ec..6c43b68 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
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 0000000..d99e04f
--- /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 <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
+}