From patchwork Tue Sep 28 19:15:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 45519 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 986423858412 for ; Tue, 28 Sep 2021 19:17:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 986423858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632856646; bh=UnhBrgS08zQXGKRx+756k3q6haoUIuZ3mS4lHamI6Bc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fG2nOungxWRO5kXuMxo36dmhzpR2BFZFJAFqiA0mVPtOcjhyWb/Eo5MSQwzRIgZrH AY26f/rgkfcrrJhvTYTwvsJXyHrlsOoJl2ME6jtU003aoUVKV0YY+xcxDlpU52k7yQ 0YQX/7FZzBBZtoOEox/vcdXmlP5Glq7se8s8fOJI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 612923858411 for ; Tue, 28 Sep 2021 19:15:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 612923858411 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-392-qsEtYecaMGCJLX8xi4Ll0w-1; Tue, 28 Sep 2021 15:15:46 -0400 X-MC-Unique: qsEtYecaMGCJLX8xi4Ll0w-1 Received: by mail-qt1-f199.google.com with SMTP id o6-20020a05622a008600b002a6c2fbc853so88518097qtw.16 for ; Tue, 28 Sep 2021 12:15:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UnhBrgS08zQXGKRx+756k3q6haoUIuZ3mS4lHamI6Bc=; b=eSgXv4X54xmHedzIqp/5EGSzKqelvRA0XuK4RXrq71vv+0bxtI+92Pi4sXn67nRkO7 YFjZ5CMDfJzuegMQZMp7X6AnT0GGnR7RDHb9BcQYqlpTxEblzpNfE0b+yzkaOURNmkoe pM3dSuEX2nlIuY69SOCn7llpQgB/PS5zz4pAbzfqOrRrtkBAithl2r3Q/5GO3jD7kcaD NWLfk8Q/0znD9gvhz8hBp7ugB/qZPZGjiNZTBZlGrCM9nr0XEngQhzU3V9w4H9QFi+33 PUDBKCgW4QsoGvxdpsmZRTJ75OAqK5yjWZiyueM51D/vP6T1tJ63puheR/NqhBoMitSC bt+g== X-Gm-Message-State: AOAM532e3EKUHmVYObq2LG10eIw/aqVId+/8rTWM49Squv+3GaKwEVLG UoHnCAmptyoBxavC7tgRNjMTPJd4a60n/o7Lrcqv2ScXqCISvjveyhE7MZLR+pscbAdbb4ukHpi NceFPDNaolI1jPA753dxVT4ZYdNRZ1l+mQKYKy+FFGnDkN/3klOXfczohGi+kbNIhvcM= X-Received: by 2002:a05:6214:126d:: with SMTP id r13mr7478403qvv.62.1632856545105; Tue, 28 Sep 2021 12:15:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPJBi1y6Dc+DhS8Z9EL3zWfEZgDqhGUJJeoKhL+uYHhER5Ya+RJDJPyGM02Jm9alfkhOTT8w== X-Received: by 2002:a05:6214:126d:: with SMTP id r13mr7478379qvv.62.1632856544829; Tue, 28 Sep 2021 12:15:44 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id v3sm15666479qkf.131.2021.09.28.12.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 12:15:44 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: ttp matching with constrained auto parm [PR99909] Date: Tue, 28 Sep 2021 15:15:41 -0400 Message-Id: <20210928191541.3143405-1-ppalka@redhat.com> X-Mailer: git-send-email 2.33.0.591.gddb1055343 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Here, when unifying TT with S, processing_template_decl is unset, and this foils the dependence checks in do_auto_deduction for avoiding checking constraints on an auto when the initializer is dependent. This patch fixes this issue by making sure processing_template_decl is set during the call to unify from coerce_template_template_parms; this seems sensible because we're unifying one set of template parameters with another, so we're dealing with templated trees throughout. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? PR c++/99909 gcc/cp/ChangeLog: * pt.c (coerce_template_template_parms): Keep processing_template_decl set during the call to unify as well. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-ttp3.C: New test. --- gcc/cp/pt.c | 4 ++-- gcc/testsuite/g++.dg/cpp2a/concepts-ttp3.C | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-ttp3.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 41fa7ed5e43..1dcdffe322a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7994,12 +7994,12 @@ coerce_template_template_parms (tree parm_parms, /* So coerce P's args to apply to A's parms, and then deduce between A's args and the converted args. If that succeeds, A is at least as specialized as P, so they match.*/ + processing_template_decl_sentinel ptds (/*reset*/false); + ++processing_template_decl; tree pargs = template_parms_level_to_args (parm_parms); pargs = add_outermost_template_args (outer_args, pargs); - ++processing_template_decl; pargs = coerce_template_parms (arg_parms, pargs, NULL_TREE, tf_none, /*require_all*/true, /*use_default*/true); - --processing_template_decl; if (pargs != error_mark_node) { tree targs = make_tree_vec (nargs); diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-ttp3.C b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp3.C new file mode 100644 index 00000000000..898524e0dfa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp3.C @@ -0,0 +1,11 @@ +// PR c++/99909 +// { dg-do compile { target c++20 } } + +template constexpr bool always_true = true; +template concept C = always_true; + +template struct S { }; + +template class TT> void f() { } + +template void f();