re PR c++/56913 ([C++11] SFINAE for ill-formed pointer-to-member operators with incom...
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 11 Apr 2013 12:46:10 +0000 (12:46 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 11 Apr 2013 12:46:10 +0000 (12:46 +0000)
/cp
2013-04-11  Paolo Carlini  <paolo.carlini@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.carlini@oracle.com>

PR c++/56913
* g++.dg/cpp0x/sfinae44.C: New.

From-SVN: r197780

gcc/cp/ChangeLog
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/sfinae44.C [new file with mode: 0644]

index 8d0f6c13b1c054b744f44e51d98e9839244494a9..01fc3efc5bed7830a0818e80a537eca5a01cd480 100644 (file)
@@ -1,3 +1,9 @@
+2013-04-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/56913
+       * typeck2.c (build_m_component_ref): Protect error calls with
+       (complain & tf_error).
+
 2013-04-11  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/54216
index 5c2b1b22611ea0cfa61e36cbc69000dcc8967982..a0bc50b2a5e767f9efeca9a3a46e0f3ddc64b4c2 100644 (file)
@@ -1722,11 +1722,19 @@ build_m_component_ref (tree datum, tree component, tsubst_flags_t complain)
        {
          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 02639b1a72f27777f7a08a428e0a4353a206159c..58447dbe1e9880e181fc18b54f11d485a6dcb098 100644 (file)
@@ -1,3 +1,8 @@
+2013-04-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/56913
+       * g++.dg/cpp0x/sfinae44.C: New.
+
 2013-04-11  Arnaud Charlet  <charlet@adacore.com>
 
        * ada/acats/run_all.sh: Remove special handling of -gnat95 switch.
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae44.C b/gcc/testsuite/g++.dg/cpp0x/sfinae44.C
new file mode 100644 (file)
index 0000000..bbcae62
--- /dev/null
@@ -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), "");