OSDN Git Service

cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Mar 2001 11:32:45 +0000 (11:32 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Mar 2001 11:32:45 +0000 (11:32 +0000)
* call.c (joust): cp_pedwarn when using gnu extension concerning
worst conversion sequences.
testsuite:
* g++.old-deja/g++.ext/overload1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@40182 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.ext/overload1.C [new file with mode: 0644]

index 41a7a06..78899b6 100644 (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'.
index a9af402..69c58db 100644 (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);
index 0a1a3ec..6c43b68 100644 (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.
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 (file)
index 0000000..d99e04f
--- /dev/null
@@ -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
+}