call.c (build_user_type_conversion_1): Don't set ICS_BAD_FLAG on an ambiguous conversion.
authorJason Merrill <jason@redhat.com>
Tue, 3 Dec 2002 17:29:43 +0000 (12:29 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 3 Dec 2002 17:29:43 +0000 (12:29 -0500)
        * call.c (build_user_type_conversion_1): Don't set ICS_BAD_FLAG on
        an ambiguous conversion.

From-SVN: r59775

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/overload/ambig1.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.benjamin/15799.C
gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C
gcc/testsuite/g++.old-deja/g++.mike/net2.C

index 2399b18e0e37c54b900f95ad8cd74bd18c5e5585..611557b9821469613f1563b4a85796bbc6690883 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-03  Jason Merrill  <jason@redhat.com>
+
+       * call.c (build_user_type_conversion_1): Don't set ICS_BAD_FLAG on
+       an ambiguous conversion.
+
 2002-12-03  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/8688
index a7f9a917d15169f60cd5e1ea9fdb9d7d45751b0c..1678ed25337d2cb1170234e8157d4af24958ee85 100644 (file)
@@ -2620,7 +2620,8 @@ build_user_type_conversion_1 (totype, expr, flags)
       cand = candidates;       /* any one will do */
       cand->second_conv = build1 (AMBIG_CONV, totype, expr);
       ICS_USER_FLAG (cand->second_conv) = 1;
-      ICS_BAD_FLAG (cand->second_conv) = 1;
+      /* Don't set ICS_BAD_FLAG; an ambiguous conversion is no worse than
+        another user-defined conversion.  */
 
       return cand;
     }
diff --git a/gcc/testsuite/g++.dg/overload/ambig1.C b/gcc/testsuite/g++.dg/overload/ambig1.C
new file mode 100644 (file)
index 0000000..2adc78c
--- /dev/null
@@ -0,0 +1,23 @@
+// [over.best.ics]: For the purpose of ranking implicit conversion
+// sequences as described in _over.ics.rank_, the ambiguous conversion
+// sequence is treated as a user-defined sequence that is indistinguishable
+// from any other user- defined conversion sequence.
+
+struct A
+{
+  A(long);
+  A(char);
+};
+
+struct B
+{
+  B(int);
+};
+
+void f(A);                     // { dg-error "" "candidate" }
+void f(B);                     // { dg-error "" "candidate" }
+
+int main()
+{
+  f (42);                      // { dg-error "ambiguous" "ambiguous" }
+}
index 5309daf8c631e9fe57b6038489b93f2e7edb78d2..01a06b042d54359c23bb8956b30ef7da8a6353e7 100644 (file)
@@ -15,7 +15,7 @@ typedef unsigned long uint_32;
 class sanjose {
 public:
    sanjose();
-   sanjose(const sanjose&);  
+   sanjose(const sanjose&);  // ERROR - candidate
    sanjose(int_8 value);  // ERROR -  // ERROR -
    sanjose(uint_32 value);  // ERROR -  // ERROR -
 };
index 7c4089a1bbf8953dc5a729897453c43740b680e0..370a4603c17e9edca9042b439d38b594fb9f4bea 100644 (file)
@@ -7,13 +7,15 @@
 // the explicit cast syntax disambiguates the constructor as one which
 // invokes the type conversion operator rather than the conversion.
 
+// NO, IT DOESN'T.  It's still ambiguous.  --jason 2002-12-03
+
 // cfront 2.0 passes this test.
 
 // keywords: user-defined type conversion operator, constructor
 
 struct t_0_st_0;
 
-struct t_0_st_1 { // ERROR - 
+struct t_0_st_1 {
   int member;
 
   t_0_st_1 (t_0_st_0&);// ERROR - 
@@ -80,7 +82,7 @@ void t_1_local_init ()
 
 struct t_2_st_0;
 
-struct t_2_st_1 {              // ERROR - candidate
+struct t_2_st_1 {
   int member;
 
   t_2_st_1 (t_2_st_0);         // ERROR - candidate
index ffc14ef2115635eb2bc60a7ce9d4b4cc3138c49c..e525130c00f2bb825be368d1bc765b196771d34d 100644 (file)
@@ -3,7 +3,7 @@
 
 class B;
 
-class A {
+class A {                      // ERROR - copy ctor candidate
   private:
     A(B *);                    // ERROR - 
   public: