c++: CONSTRUCTORs are non-deduced contexts [PR104291]
authorPatrick Palka <ppalka@redhat.com>
Mon, 31 Jan 2022 19:15:01 +0000 (14:15 -0500)
committerPatrick Palka <ppalka@redhat.com>
Mon, 31 Jan 2022 19:15:01 +0000 (14:15 -0500)
PR c++/104291

gcc/cp/ChangeLog:

* pt.cc (for_each_template_parm_r) <case CONSTRUCTOR>: Clear
walk_subtrees if !include_nondeduced_p.  Simplify given that
cp_walk_subtrees already walks TYPE_PTRMEMFUNC_FN_TYPE_RAW.

gcc/testsuite/ChangeLog:

* g++.dg/template/partial20.C: New test.

gcc/cp/pt.cc
gcc/testsuite/g++.dg/template/partial20.C [new file with mode: 0644]

index f46a7ad..84d63f9 100644 (file)
@@ -10525,12 +10525,6 @@ for_each_template_parm_r (tree *tp, int *walk_subtrees, void *d)
       *walk_subtrees = 0;
       break;
 
-    case CONSTRUCTOR:
-      if (TREE_TYPE (t) && TYPE_PTRMEMFUNC_P (TREE_TYPE (t))
-         && pfd->include_nondeduced_p)
-       WALK_SUBTREE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (t)));
-      break;
-
     case INDIRECT_REF:
     case COMPONENT_REF:
       /* If there's no type, then this thing must be some expression
@@ -10539,6 +10533,7 @@ for_each_template_parm_r (tree *tp, int *walk_subtrees, void *d)
        return error_mark_node;
       break;
 
+    case CONSTRUCTOR:
     case TRAIT_EXPR:
     case PLUS_EXPR:
     case MULT_EXPR:
diff --git a/gcc/testsuite/g++.dg/template/partial20.C b/gcc/testsuite/g++.dg/template/partial20.C
new file mode 100644 (file)
index 0000000..b29e099
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/104291
+// { dg-do compile { target c++20 } }
+
+struct A { int x; };
+
+template<auto> struct B;
+template<int N> struct B<A{N}> { }; // { dg-error "not deducible" }