]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* call.c (convert_like_real): Give "initializing argument of"
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Jun 2010 20:10:42 +0000 (20:10 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Jun 2010 20:10:42 +0000 (20:10 +0000)
information for ambiguous conversion.  Give source position
of function.

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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/initlist15.C
gcc/testsuite/g++.dg/cpp0x/initlist19.C
gcc/testsuite/g++.dg/expr/cond8.C
gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C
libstdc++-v3/testsuite/ext/ext_pointer/1_neg.cc

index d98eaae9d58cc90790fb74ee23fd5c87b088d743..4e30814f6b82ea9d38a184aab97112bfa6a6b6bf 100644 (file)
@@ -1,5 +1,9 @@
 2010-06-15  Jason Merrill  <jason@redhat.com>
 
+       * call.c (convert_like_real): Give "initializing argument of"
+       information for ambiguous conversion.  Give source position
+       of function.
+
        * call.c (print_z_candidates): Do print viable deleted candidates.
        (joust): Don't choose a deleted function just because its worst
        conversion is better than another candidate's worst.
index a735dc69630652088e7f9d49085f069b4c8939cf..55089edbf1d9d8fd7416a29c481459d655441367 100644 (file)
@@ -4934,7 +4934,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
        {
          permerror (input_location, "invalid conversion from %qT to %qT", TREE_TYPE (expr), totype);
          if (fn)
-           permerror (input_location, "  initializing argument %P of %qD", argnum, fn);
+           permerror (DECL_SOURCE_LOCATION (fn),
+                      "  initializing argument %P of %qD", argnum, fn);
        }
       else
        return error_mark_node;
@@ -5018,11 +5019,14 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
         }
       return expr;
     case ck_ambig:
-      if (!(complain & tf_error))
-       return error_mark_node;
-      /* Call build_user_type_conversion again for the error.  */
-      return build_user_type_conversion
-       (totype, convs->u.expr, LOOKUP_NORMAL);
+      if (complain & tf_error)
+       {
+         /* Call build_user_type_conversion again for the error.  */
+         build_user_type_conversion (totype, convs->u.expr, LOOKUP_NORMAL);
+         if (fn)
+           error ("  initializing argument %P of %q+D", argnum, fn);
+       }
+      return error_mark_node;
 
     case ck_list:
       {
@@ -5110,7 +5114,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
       if (diag_kind && fn)
        {
          if ((complain & tf_error))
-           emit_diagnostic (diag_kind, input_location, 0, 
+           emit_diagnostic (diag_kind, DECL_SOURCE_LOCATION (fn), 0,
                             "  initializing argument %P of %qD", argnum, fn);
          else if (diag_kind == DK_ERROR)
            return error_mark_node;
index d59e5af640b3f38869d8bda35760b5c83cc053bd..b75cc81729f5dc44373c9e6125129c033cf04254 100644 (file)
@@ -1,5 +1,8 @@
 // { dg-options "-std=c++0x" }
 
+// Just discard errors pointing at header files
+// { dg-prune-output "include" }
+
 #include <vector>
 #include <typeinfo>
 
index 418cddc618a9c5484f441cca169e4035e4bd42a7..9cb197c9be26a90dcd880c99b537e853f3105d09 100644 (file)
@@ -1,8 +1,10 @@
 // { dg-options "-std=c++0x" }
 
+// Allow other errors, too
+// { dg-prune-output "error" }
+
 void f(double);
 int main()
 {
   f({{1}});                    // { dg-error "too many braces" }
-  // { dg-error "" "" { target *-*-* } 6 } allow other errors, too
 }
index f05c81a26ce7bb30e2a7422e9a09d1b615eb56bc..11708ec0f6f27ac4b6a653c581ee0c2d79186f6f 100644 (file)
@@ -3,11 +3,11 @@
 
 struct A
 {
-  A(void*);
+  A(void*);                    // { dg-error "initializing" }
   ~A();
 };
 
 void foo(const int i, bool b)
 {
-  b ? A(0) : i; // { dg-error "conversion|initializing" } 
+  b ? A(0) : i; // { dg-error "conversion" }
 }
index 3826e08e009f1683b8ba2f60d6624a51a7385676..c06cef1838030855ac9cc0cf4243e991b9dffc13 100644 (file)
@@ -16,7 +16,7 @@
 
 struct t_0_st_0;
 
-struct t_0_st_1 {
+struct t_0_st_1 {              // { dg-error "initializing" }
   int member;
 
   t_0_st_1 (t_0_st_0&);// { dg-message "note" } 
@@ -83,7 +83,7 @@ void t_1_local_init ()
 
 struct t_2_st_0;
 
-struct t_2_st_1 {
+struct t_2_st_1 {              // { dg-error "initializing" }
   int member;
 
   t_2_st_1 (t_2_st_0);         // { dg-message "note" }
index bab32fa0049f81049cb34ad1241129f73b239b42..c599acaebd03960323e00a33cf98be2a6e72ac2e 100644 (file)
@@ -92,12 +92,7 @@ void test01(void) {
 }
 
 // { dg-error "invalid conversion " "" { target *-*-* } 314 }
-// { dg-error "initializing argument 1 of" "" { target *-*-* } 314 }
 // { dg-error "invalid conversion " "" { target *-*-* } 308 }
-// { dg-error "initializing argument 1 of" "" { target *-*-* } 308 }
 // { dg-error "invalid conversion " "" { target *-*-* } 331 }
-// { dg-error "initializing argument 1 of" "" { target *-*-* } 331 }
 // { dg-error "invalid conversion " "" { target *-*-* } 339 }
-// { dg-error "initializing argument 1 of" "" { target *-*-* } 339 }
 // { dg-excess-errors "In constructor" }
-