re PR c++/67240 ([concepts] Implicit conversion constraints are not respected)
authorJason Merrill <jason@redhat.com>
Fri, 21 Aug 2015 18:33:07 +0000 (14:33 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 21 Aug 2015 18:33:07 +0000 (14:33 -0400)
PR c++/67240
* constraint.cc (satisfy_implicit_conversion_constraint): Also
check for NULL_TREE.

From-SVN: r227081

gcc/cp/ChangeLog
gcc/cp/constraint.cc
gcc/testsuite/g++.dg/concepts/iconv1.C [new file with mode: 0644]

index bc613f088e1dc2af4940770a74843b592595b86e..c2a1206c66d019b008af5dd00961869cc85ec656 100644 (file)
@@ -1,3 +1,9 @@
+2015-08-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/67240
+       * constraint.cc (satisfy_implicit_conversion_constraint): Also
+       check for NULL_TREE.
+
 2015-08-21  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * decl.c (grokvardecl): Simplify the latter.
index c981212271d4649cf2ba70517dbeae008d5ad90b..cb82535af49fe68313b1a4108d66f687afdcf009 100644 (file)
@@ -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 (file)
index 0000000..c4dd38f
--- /dev/null
@@ -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" }