From 509fd16da8528444dccc98cef57a18a295c3f1b4 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Thu, 28 Apr 2022 13:10:56 -0400 Subject: [PATCH] c++: partial ordering and dependent operator expr [PR105425] Here ever since r12-6022-gbb2a7f80a98de3 we stopped deeming the partial specialization #2 to be more specialized than #1 ultimately because dependent operator expressions now have a DEPENDENT_OPERATOR_TYPE type instead of an empty type, and this made unify stop deducing T(2) == 1 for K during partial ordering for #1 and #2. This minimal patch fixes this by making the relevant logic in unify treat DEPENDENT_OPERATOR_TYPE like an empty type. PR c++/105425 gcc/cp/ChangeLog: * pt.cc (unify) : Treat DEPENDENT_OPERATOR_TYPE like an empty type. gcc/testsuite/ChangeLog: * g++.dg/template/partial-specialization13.C: New test. --- gcc/cp/pt.cc | 3 ++- .../g++.dg/template/partial-specialization13.C | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/partial-specialization13.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index e785c5db1420..81f7ef5c42b5 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -24276,7 +24276,8 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, } } - if (!TREE_TYPE (arg)) + if (!TREE_TYPE (arg) + || TREE_CODE (TREE_TYPE (arg)) == DEPENDENT_OPERATOR_TYPE) /* Template-parameter dependent expression. Just accept it for now. It will later be processed in convert_template_argument. */ ; diff --git a/gcc/testsuite/g++.dg/template/partial-specialization13.C b/gcc/testsuite/g++.dg/template/partial-specialization13.C new file mode 100644 index 000000000000..b0903f0d60af --- /dev/null +++ b/gcc/testsuite/g++.dg/template/partial-specialization13.C @@ -0,0 +1,11 @@ +// PR c++/105425 +// { dg-do compile { target c++11 } } + +template struct when; +template struct A; +template struct A>; // #1 +template struct A> {}; // #2 +A> a1; // { dg-error "incomplete" } +A> a2; +A> a3; +A> a4; // { dg-error "incomplete" } -- 2.39.2