From: Jason Merrill Date: Thu, 25 Aug 2011 18:22:46 +0000 (-0400) Subject: re PR c++/50157 ([C++0x] Non-silent SFINAE in new expression with explicit conversion) X-Git-Tag: releases/gcc-4.7.0~4267 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7888350f3973a45d98581573bcf7773eb10d8322;p=thirdparty%2Fgcc.git re PR c++/50157 ([C++0x] Non-silent SFINAE in new expression with explicit conversion) PR c++/50157 * call.c (convert_like_real): Exit early if bad and !tf_error. From-SVN: r178081 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 390a7982ecb3..92363ff3fbb6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-08-25 Jason Merrill + + PR c++/50157 + * call.c (convert_like_real): Exit early if bad and !tf_error. + 2011-08-23 Jason Merrill * typeck2.c (build_functional_cast): Don't try to avoid calling diff --git a/gcc/cp/call.c b/gcc/cp/call.c index e5f65b31c6cf..d911b3aaeed2 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5642,6 +5642,9 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, diagnostic_t diag_kind; int flags; + if (convs->bad_p && !(complain & tf_error)) + return error_mark_node; + if (convs->bad_p && convs->kind != ck_user && convs->kind != ck_list @@ -5688,15 +5691,12 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, else if (t->kind == ck_identity) break; } - if (complain & tf_error) - { - permerror (input_location, "invalid conversion from %qT to %qT", TREE_TYPE (expr), totype); - if (fn) - permerror (DECL_SOURCE_LOCATION (fn), - " initializing argument %P of %qD", argnum, fn); - } - else - return error_mark_node; + + permerror (input_location, "invalid conversion from %qT to %qT", + TREE_TYPE (expr), totype); + if (fn) + permerror (DECL_SOURCE_LOCATION (fn), + " initializing argument %P of %qD", argnum, fn); return cp_convert (totype, expr); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c904def866d8..c64661263d8e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-08-25 Jason Merrill + + PR c++/50157 + * g++.dg/cpp0x/sfinae27.C: New. + 2011-08-25 Tobias Burnus * gfortran.dg/coarray_lib_token_4.f90: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae27.C b/gcc/testsuite/g++.dg/cpp0x/sfinae27.C new file mode 100644 index 000000000000..93327ba9cc5b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae27.C @@ -0,0 +1,20 @@ +// PR c++/50157 +// { dg-options -std=c++0x } + +template +T val(); + +template())) +> +auto test(int) -> char; + +template +auto test(...) -> char (&)[2]; + +struct P { + explicit operator bool(); // (#13) +}; + +typedef decltype(test(0)) type; // OK +typedef decltype(test(0)) type2; // Error (#17)