diff mbox

C++ PATCH for c++/64352 (decltype and SFINAE)

Message ID 54935330.6090602@redhat.com
State New
Headers show

Commit Message

Jason Merrill Dec. 18, 2014, 10:20 p.m. UTC
We were just missing a case where we want to pass complain down to avoid 
a hard error in SFINAE context.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit 83bea8460ce8e14e5b9d1c0dc33a0d22b63b566d
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Dec 18 12:42:34 2014 -0500

    	PR c++/64352
    	* pt.c (tsubst_copy_and_build): Pass complain to mark_used.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 8a663d9..3ddee25 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -15125,7 +15125,7 @@  tsubst_copy_and_build (tree t,
 
 	/* Remember that there was a reference to this entity.  */
 	if (DECL_P (function))
-	  mark_used (function);
+	  mark_used (function, complain);
 
 	/* Put back tf_decltype for the actual call.  */
 	complain |= decltype_flag;
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted9.C b/gcc/testsuite/g++.dg/cpp0x/deleted9.C
new file mode 100644
index 0000000..af97be7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/deleted9.C
@@ -0,0 +1,31 @@ 
+// PR c++/64352
+// { dg-do compile { target c++11 } }
+
+template<bool B> struct bool_type
+{ static constexpr bool value = B; };
+
+using true_type = bool_type<true>;
+using false_type = bool_type<false>;
+
+template<typename T> T&& declval();
+
+template<typename...> struct void_ { using type = void; };
+template<typename... I> using void_t = typename void_<I...>::type;
+
+template<typename _Tp, typename = void>
+struct _Has_addressof_free: false_type { };
+
+template<typename _Tp>
+struct _Has_addressof_free
+<_Tp, void_t<decltype( operator&(declval<const _Tp&>()) )>>
+: true_type { };
+
+struct foo {};
+void operator&(foo) = delete;
+
+int main()
+{
+    static_assert( !_Has_addressof_free<int>::value, "" );
+    // error: use of deleted function 'void operator&(foo)'
+    static_assert( !_Has_addressof_free<foo>::value, "" );
+}