diff options
author | Jason Merrill <jason@redhat.com> | 2010-06-15 16:10:42 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-06-15 16:10:42 -0400 |
commit | 0842c29f7b4560244ff3038f90896c745a0bb77d (patch) | |
tree | 5e557130f1af4b6b8661ce657b7dc3339ed7a7f3 | |
parent | e14eaea4d4c3ce010cb58b428681e7d6723021a2 (diff) | |
download | gcc-0842c29f7b4560244ff3038f90896c745a0bb77d.zip gcc-0842c29f7b4560244ff3038f90896c745a0bb77d.tar.gz gcc-0842c29f7b4560244ff3038f90896c745a0bb77d.tar.bz2 |
call.c (convert_like_real): Give "initializing argument of" information for ambiguous conversion.
* call.c (convert_like_real): Give "initializing argument of"
information for ambiguous conversion. Give source position
of function.
From-SVN: r160809
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/call.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist15.C | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist19.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/cond8.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/ext/ext_pointer/1_neg.cc | 5 |
7 files changed, 25 insertions, 17 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d98eaae..4e30814 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index a735dc6..55089ed 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist15.C b/gcc/testsuite/g++.dg/cpp0x/initlist15.C index d59e5af..b75cc81 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist15.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist15.C @@ -1,5 +1,8 @@ // { dg-options "-std=c++0x" } +// Just discard errors pointing at header files +// { dg-prune-output "include" } + #include <vector> #include <typeinfo> diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist19.C b/gcc/testsuite/g++.dg/cpp0x/initlist19.C index 418cddc..9cb197c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist19.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist19.C @@ -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 } diff --git a/gcc/testsuite/g++.dg/expr/cond8.C b/gcc/testsuite/g++.dg/expr/cond8.C index f05c81a..11708ec 100644 --- a/gcc/testsuite/g++.dg/expr/cond8.C +++ b/gcc/testsuite/g++.dg/expr/cond8.C @@ -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" } } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C index 3826e08..c06cef1 100644 --- a/gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C @@ -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" } diff --git a/libstdc++-v3/testsuite/ext/ext_pointer/1_neg.cc b/libstdc++-v3/testsuite/ext/ext_pointer/1_neg.cc index bab32fa..c599aca 100644 --- a/libstdc++-v3/testsuite/ext/ext_pointer/1_neg.cc +++ b/libstdc++-v3/testsuite/ext/ext_pointer/1_neg.cc @@ -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" } - |