From 7717e0f19e46c0accd55b48b67d0408f037b4a7a Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 21 Aug 2015 14:33:07 -0400 Subject: [PATCH] re PR c++/67240 ([concepts] Implicit conversion constraints are not respected) PR c++/67240 * constraint.cc (satisfy_implicit_conversion_constraint): Also check for NULL_TREE. From-SVN: r227081 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/constraint.cc | 2 +- gcc/testsuite/g++.dg/concepts/iconv1.C | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/concepts/iconv1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bc613f088e1..c2a1206c66d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-08-21 Jason Merrill + + PR c++/67240 + * constraint.cc (satisfy_implicit_conversion_constraint): Also + check for NULL_TREE. + 2015-08-21 Paolo Carlini * decl.c (grokvardecl): Simplify the latter. diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index c981212271d..cb82535af49 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 = 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 00000000000..c4dd38fe5b4 --- /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 +concept bool C1 = requires (T x) { + {foo(x)} -> int&; +}; + +template +concept bool C2 = requires (T x) { + {foo(x)} -> void; +}; + +static_assert( C1 ); // { dg-error "assert" } +static_assert( C2 ); // { dg-error "assert" } -- 2.30.2