re PR c++/68434 ([concepts] function tsubst sets TYPE_CANONICAL before setting a...
authorRyan Burn <contact@rnburn.com>
Wed, 25 Nov 2015 22:13:23 +0000 (22:13 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 25 Nov 2015 22:13:23 +0000 (17:13 -0500)
PR c++/68434

* pt.c (tsubst): Set PLACEHOLDER_TYPE_CONSTRAINTS before
calling canonical_type_parameter.

From-SVN: r230909

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/concepts/pr68434.C [new file with mode: 0644]

index 900d8649934e54c874e56cc858746a6dac281326..52ca12f77f9cb64503e39ecec86dfe49c870844f 100644 (file)
@@ -1,3 +1,9 @@
+2015-11-25  Ryan Burn  <contact@rnburn.com>
+
+       PR c++/68434
+       * pt.c (tsubst): Set PLACEHOLDER_TYPE_CONSTRAINTS before
+       calling canonical_type_parameter.
+
 2015-11-25  Jason Merrill  <jason@redhat.com>
 
        * lambda.c (maybe_add_lambda_conv_op): Only set
index 5868be2e7f257975d3c8f8fdf6783f0112518de7..2432283732625b9a905d63ad34f823a4dd00061e 100644 (file)
@@ -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 (file)
index 0000000..d5f901a
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-options "-std=c++1z" }
+
+template <class>
+concept bool C1 () {
+  return true;
+}
+
+template <class>
+concept bool C2 () {
+  return true;
+}
+
+template <class Expr>
+concept bool C3 () {
+  return requires (Expr expr) {
+      {expr}->C1;
+      {expr}->C2;
+  };
+}
+
+auto f (C3);