This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/67240 (implicit conversion constraint)


perform_direct_initialization_if_possible returns NULL_TREE if no conversion is possible.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit d25eb4518d272d25dbd63d0d4802102be0a2ca08
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Aug 21 12:14:48 2015 -0400

    	PR c++/67240
    	* constraint.cc (satisfy_implicit_conversion_constraint): Also
    	check for NULL_TREE.

diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index c981212..cb82535 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -1775,7 +1775,7 @@ satisfy_implicit_conversion_constraint (tree t, tree args,
      of the form TYPE <unspecified> = EXPR.  */
   tree conv =
     perform_direct_initialization_if_possible (type, expr, false, complain);
-  if (conv == error_mark_node)
+  if (conv == NULL_TREE || conv == error_mark_node)
     return boolean_false_node;
   else
     return boolean_true_node;
diff --git a/gcc/testsuite/g++.dg/concepts/iconv1.C b/gcc/testsuite/g++.dg/concepts/iconv1.C
new file mode 100644
index 0000000..c4dd38f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/iconv1.C
@@ -0,0 +1,20 @@
+// PR c++/67240
+// { dg-options -std=c++1z }
+
+int foo(int x)
+{
+    return x;
+}
+ 
+template <typename T>
+concept bool C1 = requires (T x) {
+    {foo(x)} -> int&;
+};
+
+template <typename T>
+concept bool C2 = requires (T x) {
+    {foo(x)} -> void;
+};
+ 
+static_assert( C1<int> );	// { dg-error "assert" }
+static_assert( C2<int> );	// { dg-error "assert" }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]