Re: [C++ Patch] PR 52422 (new patch)
Hi again, Hi Jason, I have a new patch for this issue, another SFINAE issue noticed by Daniel. Compared to the last version, I extended the complain-ization ;) to a few more functions in typeck.c (I think the set is more consistent now) and thoroughly double checked that the return values of all the functions which now get a tsubst_flags_t argument are checked for error_mark_node and in case early return back error_mark_node itself, as you requested last time. As usual, tested x86_64-linux. The below is what I'm going to actually commit, as approved by Jason off-list with a change to the convert_member_func_to_ptr bits. Tested x86_64-linux. Thanks, Paolo. / /cp 2012-04-18 Paolo Carlini paolo.carl...@oracle.com PR c++/52422 * cp-tree.h (build_addr_func, decay_conversion, get_member_function_from_ptrfunc, build_m_component_ref, convert_member_func_to_ptr): Add tsubst_flags_t parameter. * typeck.c (cp_default_conversion): Add. (decay_conversion, default_conversion, get_member_function_from_ptrfunc, convert_member_func_to_ptr): Add tsubst_flags_t parameter and use it throughout. (cp_build_indirect_ref, cp_build_array_ref, cp_build_function_call_vec, convert_arguments, build_x_binary_op, cp_build_binary_op, cp_build_unary_op, build_reinterpret_cast_1, build_const_cast_1, expand_ptrmemfunc_cst, convert_for_initialization): Adjust. * init.c (build_vec_init): Adjust. * decl.c (grok_reference_init, get_atexit_node): Likewise. * rtti.c (build_dynamic_cast_1, tinfo_base_init): Likewise. * except.c (build_throw): Likewise. * typeck2.c (build_x_arrow): Likewise. (build_m_component_ref): Add tsubst_flags_t parameter and use it throughout. * pt.c (convert_nontype_argument): Adjust. * semantics.c (finish_asm_stmt, maybe_add_lambda_conv_op): Likewise. * decl2.c (build_offset_ref_call_from_tree): Likewise. * call.c (build_addr_func): Add tsubst_flags_t parameter and use it throughout. (build_call_a, build_conditional_expr_1, build_new_op_1, convert_like_real, convert_arg_to_ellipsis, build_over_call, build_special_member_call): Adjust. * cvt.c (cp_convert_to_pointer, force_rvalue, build_expr_type_conversion): Likewise. /testsuite 2012-04-18 Paolo Carlini paolo.carl...@oracle.com PR c++/52422 * g++.dg/cpp0x/sfinae33.C: New. * g++.dg/cpp0x/sfinae34.C: Likewise. Index: testsuite/g++.dg/cpp0x/sfinae33.C === --- testsuite/g++.dg/cpp0x/sfinae33.C (revision 0) +++ testsuite/g++.dg/cpp0x/sfinae33.C (revision 0) @@ -0,0 +1,27 @@ +// PR c++/52422 +// { dg-options -std=c++11 } + +templateclass T +struct add_rval_ref +{ + typedef T type; +}; + +template +struct add_rval_refvoid +{ + typedef void type; +}; + +templateclass T +typename add_rval_refT::type create(); + +templateclass T, + class = decltype(createT()()) + +auto f(int) - char()[1]; + +templateclass +auto f(...) - char()[2]; + +static_assert(sizeof(fvoid(0)) != 1, ); Index: testsuite/g++.dg/cpp0x/sfinae34.C === --- testsuite/g++.dg/cpp0x/sfinae34.C (revision 0) +++ testsuite/g++.dg/cpp0x/sfinae34.C (revision 0) @@ -0,0 +1,27 @@ +// PR c++/52422 +// { dg-options -std=c++11 } + +templateclass T +struct add_rval_ref +{ + typedef T type; +}; + +template +struct add_rval_refvoid +{ + typedef void type; +}; + +templateclass T +typename add_rval_refT::type create(); + +templateclass T, class U, + class = decltype( (createT().*createU())() ) + +auto f(int) - char()[1]; + +templateclass, class +auto f(...) - char()[2]; + +static_assert(sizeof(fvoid, void(0)) != 1, ); Index: cp/typeck.c === --- cp/typeck.c (revision 186563) +++ cp/typeck.c (working copy) @@ -1818,7 +1818,7 @@ unlowered_expr_type (const_tree exp) that the return value is no longer an lvalue. */ tree -decay_conversion (tree exp) +decay_conversion (tree exp, tsubst_flags_t complain) { tree type; enum tree_code code; @@ -1832,7 +1832,8 @@ tree exp = resolve_nondeduced_context (exp); if (type_unknown_p (exp)) { - cxx_incomplete_type_error (exp, TREE_TYPE (exp)); + if (complain tf_error) + cxx_incomplete_type_error (exp, TREE_TYPE (exp)); return error_mark_node; } @@ -1851,13 +1852,14 @@ tree code = TREE_CODE (type); if (code == VOID_TYPE) { - error (void value not ignored as it ought to be); + if (complain tf_error) + error (void value not ignored as it ought to be); return error_mark_node; } - if (invalid_nonstatic_memfn_p (exp, tf_warning_or_error)) + if (invalid_nonstatic_memfn_p (exp, complain)) return
[C++ Patch] PR 52422 (new patch)
Hi Jason, I have a new patch for this issue, another SFINAE issue noticed by Daniel. Compared to the last version, I extended the complain-ization ;) to a few more functions in typeck.c (I think the set is more consistent now) and thoroughly double checked that the return values of all the functions which now get a tsubst_flags_t argument are checked for error_mark_node and in case early return back error_mark_node itself, as you requested last time. As usual, tested x86_64-linux. Ok for mainline? Thanks, Paolo. / /cp 2012-04-17 Paolo Carlini paolo.carl...@oracle.com PR c++/52422 * cp-tree.h (build_addr_func, decay_conversion, get_member_function_from_ptrfunc, build_m_component_ref, convert_member_func_to_ptr): Add tsubst_flags_t parameter. * typeck.c (cp_default_conversion): Add. (decay_conversion, default_conversion, get_member_function_from_ptrfunc, convert_member_func_to_ptr): Add tsubst_flags_t parameter and use it throughout. (cp_build_indirect_ref, cp_build_array_ref, cp_build_function_call_vec, convert_arguments, build_x_binary_op, cp_build_binary_op, cp_build_unary_op, build_reinterpret_cast_1, build_const_cast_1, expand_ptrmemfunc_cst, convert_for_initialization): Adjust. * init.c (build_vec_init): Adjust. * decl.c (grok_reference_init, get_atexit_node): Likewise. * rtti.c (build_dynamic_cast_1, tinfo_base_init): Likewise. * except.c (build_throw): Likewise. * typeck2.c (build_x_arrow): Likewise. (build_m_component_ref): Add tsubst_flags_t parameter and use it throughout. * pt.c (convert_nontype_argument): Adjust. * semantics.c (finish_asm_stmt, maybe_add_lambda_conv_op): Likewise. * decl2.c (build_offset_ref_call_from_tree): Likewise. * call.c (build_addr_func): Add tsubst_flags_t parameter and use it throughout. (build_call_a, build_conditional_expr_1, build_new_op_1, convert_like_real, convert_arg_to_ellipsis, build_over_call, build_special_member_call): Adjust. * cvt.c (cp_convert_to_pointer, force_rvalue, build_expr_type_conversion): Likewise. /testsuite 2012-04-17 Paolo Carlini paolo.carl...@oracle.com PR c++/52422 * g++.dg/cpp0x/sfinae33.C: New. * g++.dg/cpp0x/sfinae34.C: Likewise. Index: testsuite/g++.dg/cpp0x/sfinae33.C === --- testsuite/g++.dg/cpp0x/sfinae33.C (revision 0) +++ testsuite/g++.dg/cpp0x/sfinae33.C (revision 0) @@ -0,0 +1,27 @@ +// PR c++/52422 +// { dg-options -std=c++11 } + +templateclass T +struct add_rval_ref +{ + typedef T type; +}; + +template +struct add_rval_refvoid +{ + typedef void type; +}; + +templateclass T +typename add_rval_refT::type create(); + +templateclass T, + class = decltype(createT()()) + +auto f(int) - char()[1]; + +templateclass +auto f(...) - char()[2]; + +static_assert(sizeof(fvoid(0)) != 1, ); Index: testsuite/g++.dg/cpp0x/sfinae34.C === --- testsuite/g++.dg/cpp0x/sfinae34.C (revision 0) +++ testsuite/g++.dg/cpp0x/sfinae34.C (revision 0) @@ -0,0 +1,27 @@ +// PR c++/52422 +// { dg-options -std=c++11 } + +templateclass T +struct add_rval_ref +{ + typedef T type; +}; + +template +struct add_rval_refvoid +{ + typedef void type; +}; + +templateclass T +typename add_rval_refT::type create(); + +templateclass T, class U, + class = decltype( (createT().*createU())() ) + +auto f(int) - char()[1]; + +templateclass, class +auto f(...) - char()[2]; + +static_assert(sizeof(fvoid, void(0)) != 1, ); Index: cp/typeck.c === --- cp/typeck.c (revision 186552) +++ cp/typeck.c (working copy) @@ -1818,7 +1818,7 @@ unlowered_expr_type (const_tree exp) that the return value is no longer an lvalue. */ tree -decay_conversion (tree exp) +decay_conversion (tree exp, tsubst_flags_t complain) { tree type; enum tree_code code; @@ -1832,7 +1832,8 @@ tree exp = resolve_nondeduced_context (exp); if (type_unknown_p (exp)) { - cxx_incomplete_type_error (exp, TREE_TYPE (exp)); + if (complain tf_error) + cxx_incomplete_type_error (exp, TREE_TYPE (exp)); return error_mark_node; } @@ -1851,13 +1852,14 @@ tree code = TREE_CODE (type); if (code == VOID_TYPE) { - error (void value not ignored as it ought to be); + if (complain tf_error) + error (void value not ignored as it ought to be); return error_mark_node; } - if (invalid_nonstatic_memfn_p (exp, tf_warning_or_error)) + if (invalid_nonstatic_memfn_p (exp, complain)) return error_mark_node; if (code == FUNCTION_TYPE || is_overloaded_fn (exp)) -return cp_build_addr_expr (exp, tf_warning_or_error); +return