aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constraint.cc
diff options
context:
space:
mode:
authorAndrew Sutton <asutton@lock3software.com>2019-11-27 15:23:02 +0000
committerAndrew Sutton <asutton@gcc.gnu.org>2019-11-27 15:23:02 +0000
commit861d4af8d82819a857e360949545651adf33a264 (patch)
tree231f0fe9b111f132f4b47a343e458ff6be85c9f3 /gcc/cp/constraint.cc
parent50e0c6e429e7cc664f6fcea59db22826f005ca19 (diff)
downloadgcc-861d4af8d82819a857e360949545651adf33a264.zip
gcc-861d4af8d82819a857e360949545651adf33a264.tar.gz
gcc-861d4af8d82819a857e360949545651adf33a264.tar.bz2
re PR c++/92236 ([concepts] Explain non-satisfaction in static_assert)
2019-11-27 Andrew Sutton <asutton@lock3software.com> PR c++/92236 Defer evaluation of concept checks so that static assertions can emit more detailed diagnostics. gcc/cp/ * constexpr.c (cxx_eval_call_expression): Handle concept checks. (cxx_eval_constant_expression): Diagnose misuse of function concepts as template-id expressions. Follow the usual return path for results. (cxx_eval_outermost_constant_expr): Avoid calling cp_get_callee_fndecl_nofold for function concepts. * constraint.cc (build_function_check): Fully type the concept check so that we don't ICE in conversions. * cp-gimplify.c (cp_genericize_r) [CALL_EXPR]: Handle concept checks. [TEMPLATE_ID_EXPR] Likewise. * cvt.c (convert_to_void): Always evaluate concept checks so we don't accidentally ignore them. Substitution during satisfaction can make a program ill-formed (example in g++.dg/cpp2a/concepts6.C). * pt.c (tsubst_copy_and_build): [CALL_EXPR]: Don't evaluate concepts. [TEMPLATE_ID_EXPR]: Likewise. * semantics.c (finish_call_expr): Don't evaluate concepts. (finish_id_expression_1): Likewise. (finish_static_assert): Preserve the original condition so we can diagnose concept errors when a check returns false. gcc/testsuite/ * g++.dg/cpp2a/concepts-iconv1.C: Update diagnostics. * g++.dg/cpp2a/concepts-requires5.C: Likewise. * g++.dg/cpp2a/concepts6.C: New test. From-SVN: r278775
Diffstat (limited to 'gcc/cp/constraint.cc')
-rw-r--r--gcc/cp/constraint.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 9967b1e..fadbe7c 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -1263,6 +1263,7 @@ build_function_check (tree tmpl, tree args, tsubst_flags_t /*complain*/)
++processing_template_decl;
vec<tree, va_gc> *fargs = make_tree_vector ();
tree call = build_min_nt_call_vec (id, fargs);
+ TREE_TYPE (call) = boolean_type_node;
release_tree_vector (fargs);
--processing_template_decl;
@@ -1397,6 +1398,7 @@ build_constrained_parameter (tree cnc, tree proto, tree args)
Note that the constraints are neither reduced nor decomposed. That is
done only after the requires clause has been parsed (or not). */
+
tree
finish_shorthand_constraint (tree decl, tree constr)
{