public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-5] c++: partial ordering and dependent operator expr [PR105425]
Date: Thu, 28 Apr 2022 17:11:12 +0000 (GMT)	[thread overview]
Message-ID: <20220428171112.4798D385742C@sourceware.org> (raw)

https://gcc.gnu.org/g:509fd16da8528444dccc98cef57a18a295c3f1b4

commit r13-5-g509fd16da8528444dccc98cef57a18a295c3f1b4
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Apr 28 13:10:56 2022 -0400

    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) <case TEMPLATE_PARM_INDEX>: Treat
            DEPENDENT_OPERATOR_TYPE like an empty type.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/template/partial-specialization13.C: New test.

Diff:
---
 gcc/cp/pt.cc                                             |  3 ++-
 gcc/testsuite/g++.dg/template/partial-specialization13.C | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index e785c5db142..81f7ef5c42b 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 00000000000..b0903f0d60a
--- /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<bool> struct when;
+template<class, class> struct A;
+template<class T, bool K> struct A<T, when<K>>;            // #1
+template<class T>         struct A<T, when<T(2) == 1>> {}; // #2
+A<int, when<true>> a1; // { dg-error "incomplete" }
+A<int, when<false>> a2;
+A<bool, when<true>> a3;
+A<bool, when<false>> a4; // { dg-error "incomplete" }


                 reply	other threads:[~2022-04-28 17:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220428171112.4798D385742C@sourceware.org \
    --to=ppalka@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).