From patchwork Fri Jul 24 13:49:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1335736 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=8.43.85.97; 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=Gk16fR6G; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4BCrDb0F0Yz9sTF for ; Fri, 24 Jul 2020 23:50:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 52FB838930E6; Fri, 24 Jul 2020 13:50:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52FB838930E6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1595598604; bh=Daj/NBz7n7zuicnwX4/HcEv/w3WTsZS1fG7Su3r9xBQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Gk16fR6GyLEGgL8JHMtGfHBsrmFEFv/lmOpAZwwcVaHE8FUlzXw4mHi6U8MJpVo29 g02opm6ArRs/SoabEIvLW9JxtwxRaRKaFyMadVVqq5pKzJISubrq/cWR9zrptioUpI pEevjWE3fi3dYskml58dHA9QUE+0aX1dZLWVf33M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 1F45C389246A for ; Fri, 24 Jul 2020 13:50:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1F45C389246A Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-491-uVsLzJP1P0ageycFy70a3g-1; Fri, 24 Jul 2020 09:50:00 -0400 X-MC-Unique: uVsLzJP1P0ageycFy70a3g-1 Received: by mail-qt1-f198.google.com with SMTP id w22so5881278qto.20 for ; Fri, 24 Jul 2020 06:50:00 -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=Daj/NBz7n7zuicnwX4/HcEv/w3WTsZS1fG7Su3r9xBQ=; b=dgdvAd4d3t7GN+DQ/7YVWZCwhHRB0rue66YhuRTjylORhFUF9m+ErNGm/zvhcfgKNR FMnLGvRbmSW7Lyl9i+wt6A/c//gWC66SLl6OVXvnvlsqycvd39foJ597JwSbncQ+pgUk 7bX3rteRhBEaIiNNzBFAmKLOm8qw3IUiKHIH5ADASJ3UsQ17hcTvYT1ysj+5F37Vg/ON m+5kT4JPbC2cJx+PL3vHZApcAX8I3C+MLvSAFVaC8g1nYyOV2pdZgHQMEw9W4P1YHbcM 3rhb1Rkc8886FXUwAWKWQr1dnNIDFOJi8Hh90veLx9t5ivifF9UX5jf3vzMvekWCMw/o A9lA== X-Gm-Message-State: AOAM533fOpaNYCPmNQ1cGu7XIEdn4TD4Qo+MXJHheottOUcnQ/h7eziT 1w7Pog+iiztWV3IB41QlEa3uK5M53keAq1Jx1Mro1wvicIny2AxrXbiLn1219GGTeFn8GrzxaRq 1YjNIa73OC72oTsVArQ== X-Received: by 2002:ac8:2f23:: with SMTP id j32mr9531761qta.222.1595598599458; Fri, 24 Jul 2020 06:49:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzELI9Iw9g5NR/wqNEexG7yTDaZaNVpXzqY0a/TZt+AOjvwoodUtYT1dJ06/prEST36NCdfjw== X-Received: by 2002:ac8:2f23:: with SMTP id j32mr9531737qta.222.1595598599214; Fri, 24 Jul 2020 06:49:59 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id l1sm1339358qtk.18.2020.07.24.06.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 06:49:58 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: alias_ctad_tweaks and constrained dguide [PR95486] Date: Fri, 24 Jul 2020 09:49:55 -0400 Message-Id: <20200724134955.3681531-1-ppalka@redhat.com> X-Mailer: git-send-email 2.28.0.rc1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-16.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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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" In the below testcase, we're ICEing from alias_ctad_tweaks ultimately because the implied deduction guide for X's user-defined constructor already has constraints associated with it. We then carry over these constraints to 'fprime', the overlying deduction guide for the alias template Y, via tsubst_decl from alias_ctad_tweaks. Later in alias_ctad_tweaks we call get_constraints followed by set_constraints on this overlying deduction guide without doing remove_constraints in between, which triggers the !found assert in set_constraints. This patch fixes this issue by adding an intervening call to remove_constraints. And for consistency, it changes the call to get_constraints to go through fprime instead of f. Since the DECL_TEMPLATE_RESULT of fprime is f, this consistency change makes no functional difference. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK commit? gcc/cp/ChangeLog: PR c++/95486 * pt.c (alias_ctad_tweaks): Obtain the associated constraints through fprime instead of through f. Call remove_constraints before calling set_constraints. gcc/testsuite/ChangeLog: PR c++/95486 * g++.dg/cpp2a/class-deduction-alias3.C: New test. --- gcc/cp/pt.c | 7 +++++-- gcc/testsuite/g++.dg/cpp2a/class-deduction-alias3.C | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-alias3.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b6df87a8a2e..4d955c555dc 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -28598,7 +28598,7 @@ alias_ctad_tweaks (tree tmpl, tree uguides) DECL_PRIMARY_TEMPLATE (fprime) = fprime; /* Substitute the associated constraints. */ - tree ci = get_constraints (f); + tree ci = get_constraints (fprime); if (ci) ci = tsubst_constraint_info (ci, targs, complain, in_decl); if (ci == error_mark_node) @@ -28616,7 +28616,10 @@ alias_ctad_tweaks (tree tmpl, tree uguides) } if (ci) - set_constraints (fprime, ci); + { + remove_constraints (fprime); + set_constraints (fprime, ci); + } } else { diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias3.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias3.C new file mode 100644 index 00000000000..318d4c942ce --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias3.C @@ -0,0 +1,11 @@ +// PR c++/95486 +// { dg-do compile { target c++20 } } + +template +struct X { X(U) requires __is_same(U, int) {} }; + +template +using Y = X; + +Y y{1}; +Y z{'a'}; // { dg-error "failed|no match" }