From patchwork Tue Jun 2 21:45:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1302647 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=CYrBE7Di; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49c5Fz1fGTz9sT5 for ; Wed, 3 Jun 2020 07:46:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 32C2D3851C26; Tue, 2 Jun 2020 21:46:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32C2D3851C26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1591134370; bh=D00C4rnCExaGJH7f6KOEMBm6gHyiHwX1Lukh+mgOin4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=CYrBE7Di5no/rhsuIhP2GklykSs7LY7PFxPyI9C8JtGHsVPaCvDuPQKTrDwpsbx0S lN/cH1flhJFtqbh/94CM3QDWWuSOS4damVCC/Zem8mxjQQGhs6E8g95YQ1wB7wUxiH opYECNQqKKAGs0sL0+09zNVyNg8eJjO6TC5ADUVc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 7A06B385DC00 for ; Tue, 2 Jun 2020 21:46:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7A06B385DC00 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-24-e04xfPm0MeSlsPgl84UBUQ-1; Tue, 02 Jun 2020 17:45:53 -0400 X-MC-Unique: e04xfPm0MeSlsPgl84UBUQ-1 Received: by mail-qv1-f72.google.com with SMTP id t20so4906596qvy.16 for ; Tue, 02 Jun 2020 14:45:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=D00C4rnCExaGJH7f6KOEMBm6gHyiHwX1Lukh+mgOin4=; b=C4StvmztqtRe3lRTyFiqnL957O9VhoV+CgPR06thhomJsGz8VJYLi0ey3tDZBjFC1q YoGL9r1zt8In9Wgr0JUDRksC8dL9hgvWBXYRvi6+rnlzYUAViunnKLPD4XeL9o/ghh49 IA+WyYcC9q2LtaqrqiK8Md9ulvMwjqElo3krtZ2JKjNvrvEWuYlLm0u4cfjOKnQGf8VW U9pYf/dxS1Ff5wRr8eBhBtZUb6eeWcbJrcRYOZRjI1Ul4uJ4B/JoED8QucKHC73ehlO/ 8WxpUOygZ1l2NyU2TzLrKd5n1h0oA0s0pah0X+RXZQrtrZp8ZPQZEvLpG9jg4sKwrgpr ig5w== X-Gm-Message-State: AOAM531J914a/8kDER8fAgAnW1Co1IwzvYJtdc7U+I/vfIKvLcbnu5qu Ws8W/+Z0UEED78OfMwOjtXY+RWax92cFbHpr+hYZ8semtHkwxqp/BITmHUPXd5+/9I3s2e+CGrc GrDmo3cKJBB7tQ0z0Tw== X-Received: by 2002:a37:8187:: with SMTP id c129mr26658963qkd.211.1591134352465; Tue, 02 Jun 2020 14:45:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8cU18mOHjRl6ZX8ADRJRIMNczbLfjkc3jULulWL40YgQEEI3zKmUIfLzIiA2AmiLehjrLzA== X-Received: by 2002:a37:8187:: with SMTP id c129mr26658943qkd.211.1591134352193; Tue, 02 Jun 2020 14:45:52 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id x186sm2947919qkd.125.2020.06.02.14.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 14:45:51 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: more constrained nested partial specialization Date: Tue, 2 Jun 2020 17:45:50 -0400 Message-Id: <20200602214550.981432-1-ppalka@redhat.com> X-Mailer: git-send-email 2.27.0.rc1.5.gae92ac8ae3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-18.3 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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@gcc.gnu.org Sender: "Gcc-patches" When checking that a constrained partial specialization is more constrained than the primary template, we pass only the innermost level of generic template arguments to strictly_subsumes. This leads to us doing a nonsensical substitution from normalize_concept_check if the full set of template arguments has multiple levels, and it causes strictly_subsumes to sometimes erroneously return false as in the testcase below. Passes 'make check-c++' and also tested by building the testsuites of cmcstl2 and range-v3. Does this look OK to commit to mainline and to the 10 branch after a full bootstrap and regtest? (We shouldn't need to do any substitution from strictly_subsumes here, since processing_template_decl would always be non-zero and so substituting in the complete set of generic template arguments should always be a no-op I think. I can propose this as a subsequent patch for mainline.) gcc/cp/ChangeLog: * pt.c (process_partial_specialization): Pass the full set of generic template arguments to strictly_subsumes. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-partial-spec8.C: New test. --- gcc/cp/pt.c | 2 +- .../g++.dg/cpp2a/concepts-partial-spec8.C | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec8.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index df92f5584cf..d7f61289621 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5062,7 +5062,7 @@ process_partial_specialization (tree decl) if (comp_template_args (inner_args, INNERMOST_TEMPLATE_ARGS (main_args)) && (!flag_concepts || !strictly_subsumes (current_template_constraints (), - inner_args, maintmpl))) + main_args, maintmpl))) { if (!flag_concepts) error ("partial specialization %q+D does not specialize " diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec8.C b/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec8.C new file mode 100644 index 00000000000..873cf44e407 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec8.C @@ -0,0 +1,14 @@ +// { dg-do compile { target c++20 } } + +template +concept equal = M == N; + +template +struct traits +{ + template requires equal + struct foo {}; + + template requires equal && (M >= 0) // { dg-bogus "not more constrained" } + struct foo {}; +};