From a0c0e716fa4fbdda4ee6c864de1eda284f1547ce Mon Sep 17 00:00:00 2001 From: Ryan Burn Date: Wed, 25 Nov 2015 22:13:23 +0000 Subject: [PATCH] re PR c++/68434 ([concepts] function tsubst sets TYPE_CANONICAL before setting a type's PLACEHOLDER_TYPE_CONSTRAINTS) PR c++/68434 * pt.c (tsubst): Set PLACEHOLDER_TYPE_CONSTRAINTS before calling canonical_type_parameter. From-SVN: r230909 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 12 ++++++------ gcc/testsuite/g++.dg/concepts/pr68434.C | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/concepts/pr68434.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 900d8649934..52ca12f77f9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-11-25 Ryan Burn + + PR c++/68434 + * pt.c (tsubst): Set PLACEHOLDER_TYPE_CONSTRAINTS before + calling canonical_type_parameter. + 2015-11-25 Jason Merrill * lambda.c (maybe_add_lambda_conv_op): Only set diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5868be2e7f2..24322837326 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12977,6 +12977,12 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) TYPE_POINTER_TO (r) = NULL_TREE; TYPE_REFERENCE_TO (r) = NULL_TREE; + /* Propagate constraints on placeholders. */ + if (TREE_CODE (t) == TEMPLATE_TYPE_PARM) + if (tree constr = PLACEHOLDER_TYPE_CONSTRAINTS (t)) + PLACEHOLDER_TYPE_CONSTRAINTS (r) + = tsubst_constraint (constr, args, complain, in_decl); + if (TREE_CODE (r) == TEMPLATE_TEMPLATE_PARM) /* We have reduced the level of the template template parameter, but not the levels of its @@ -12991,12 +12997,6 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) else TYPE_CANONICAL (r) = canonical_type_parameter (r); - /* Propagate constraints on placeholders. */ - if (TREE_CODE (t) == TEMPLATE_TYPE_PARM) - if (tree constr = PLACEHOLDER_TYPE_CONSTRAINTS (t)) - PLACEHOLDER_TYPE_CONSTRAINTS (r) - = tsubst_constraint (constr, args, complain, in_decl); - if (code == BOUND_TEMPLATE_TEMPLATE_PARM) { tree argvec = tsubst (TYPE_TI_ARGS (t), args, diff --git a/gcc/testsuite/g++.dg/concepts/pr68434.C b/gcc/testsuite/g++.dg/concepts/pr68434.C new file mode 100644 index 00000000000..d5f901ac3c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/pr68434.C @@ -0,0 +1,21 @@ +// { dg-options "-std=c++1z" } + +template +concept bool C1 () { + return true; +} + +template +concept bool C2 () { + return true; +} + +template +concept bool C3 () { + return requires (Expr expr) { + {expr}->C1; + {expr}->C2; + }; +} + +auto f (C3); -- 2.30.2