Hi,

a rather straightforward SFINAE issue. Isn't a regression but should be safe for the branch too.

Tested x86_64-linux. Ok?

Thanks,
Paolo.

////////////////////////
/cp
2013-04-11  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/56913
        * typeck2.c (build_m_component_ref): Protect error calls with
        (complain & tf_error).

/testsuite
2013-04-11  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/56913
        * g++.dg/cpp0x/sfinae44.C: New.
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<typename T>
+T &&declval();
+
+template<typename T, typename U,
+         typename = decltype((declval<T>().*declval<U>())())>
+constexpr bool test(int)
+{
+  return true;
+}
+
+template<typename T, typename U>
+constexpr bool test(...)
+{
+  return false;
+}
+
+struct S
+{};
+
+static_assert(!test<S, void (S::*)() &>(0), "");
+static_assert(test<S, void (S::*)() &&>(0), "");
+static_assert(test<S &, void (S::*)() &>(0), "");
+static_assert(!test<S &, void (S::*)() &&>(0), "");

Reply via email to