Index: cp/typeck2.c =================================================================== --- cp/typeck2.c (revision 197683) +++ cp/typeck2.c (working copy) @@ -1722,11 +1722,19 @@ build_m_component_ref (tree datum, tree component, { bool lval = real_lvalue_p (datum); if (lval && FUNCTION_RVALUE_QUALIFIED (type)) - error ("pointer-to-member-function type %qT requires an rvalue", - ptrmem_type); + { + if (complain & tf_error) + error ("pointer-to-member-function type %qT requires an rvalue", + ptrmem_type); + return error_mark_node; + } else if (!lval && !FUNCTION_RVALUE_QUALIFIED (type)) - error ("pointer-to-member-function type %qT requires an lvalue", - ptrmem_type); + { + if (complain & tf_error) + error ("pointer-to-member-function type %qT requires an lvalue", + ptrmem_type); + return error_mark_node; + } } return build2 (OFFSET_REF, type, datum, component); } Index: testsuite/g++.dg/cpp0x/sfinae44.C =================================================================== --- testsuite/g++.dg/cpp0x/sfinae44.C (revision 0) +++ testsuite/g++.dg/cpp0x/sfinae44.C (working copy) @@ -0,0 +1,26 @@ +// PR c++/56913 +// { dg-do compile { target c++11 } } + +template +T &&declval(); + +template().*declval())())> +constexpr bool test(int) +{ + return true; +} + +template +constexpr bool test(...) +{ + return false; +} + +struct S +{}; + +static_assert(!test(0), ""); +static_assert(test(0), ""); +static_assert(test(0), ""); +static_assert(!test(0), "");