From patchwork Tue Apr 28 20:13:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1278698 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=FNwWbvBy; 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 49BXsX6JBfz9sSK for ; Wed, 29 Apr 2020 06:13:51 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CD2E3851C11; Tue, 28 Apr 2020 20:13:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CD2E3851C11 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588104828; bh=E7jVK9JM8v3m37EtSqOjzMBljMF7J6RcdCA0zEWpqiY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=FNwWbvByiH8giW7D1HFvW3ql7wuJcUXVahyLjpjDQiT6tDDvjSTaE1EL4mnh76lN0 QIIPD8sd1QnGKWHuwCIF6tWqmFtntn2gEo9qOij+e7kIiwNwvaEeKReubeEf6WTk1F 7gqLaGLvpbW/ledgU+kfuS7VIvFvV3o+NubOAn5c= 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-2.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id D1DEE385DC32 for ; Tue, 28 Apr 2020 20:13:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D1DEE385DC32 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-vjna2QRAMLSA8FcSuVe86w-1; Tue, 28 Apr 2020 16:13:42 -0400 X-MC-Unique: vjna2QRAMLSA8FcSuVe86w-1 Received: by mail-qt1-f200.google.com with SMTP id j21so25824650qtq.8 for ; Tue, 28 Apr 2020 13:13:42 -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=QfQs4CoxV/36Oi7ONiIMqWYhyE0AJOQmpf6SWOT7uZM=; b=p70kPB8OSEXtKTgd4F9PyE30cBl4K5rA/z5GA5aRXH1Vqnv7ti5cjy8OE6PTTUqiIV L9ApVkNTAMkLeaIKx/zX2/QiMYhgPOScLQv2dm3fQzdIBGboucju5DftWdNszpqHOZyI 8dZzWpnvlh+A0rwITuVjSHw1Unze7Lcn3OjRDJxSd9/UQiuzMFb9uAMsXTJtblT4CKef N+3nmy8bvl9SnjoXPL8w5oehBI4fRErZ9DhI+TOo945+WS2XaLdQl8PZhbht6uL9OtUM kOxG2BUyJal0HgLVv+ySJZWiJZUOYuV+K5HHkGUtF/W7swoXTDsa8kpDQyrYLW+ErMa8 qi7w== X-Gm-Message-State: AGi0PuZ2ePBfV7wfjuB6yrF1f+AA0o7zrZip5gTvqHu4pt8eAsJR+UTK rsmsP2SsQB/SDkvfrcwU6G6vYt1WRY5yBvGLBWkKaKooR69ODjpqrPz4WiORmOoayKzW+h6HcEj 9eu9jvx6nimSjuQRRSQ== X-Received: by 2002:a37:6296:: with SMTP id w144mr29132838qkb.310.1588104821230; Tue, 28 Apr 2020 13:13:41 -0700 (PDT) X-Google-Smtp-Source: APiQypKSJwymQf9OS74p+TGpqpFuJ0f4FRPCg0vlt4SrKC574RooR4RTigX6cyIzAOPsvLmg7Vagvg== X-Received: by 2002:a37:6296:: with SMTP id w144mr29132822qkb.310.1588104820960; Tue, 28 Apr 2020 13:13:40 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id n65sm7526924qka.128.2020.04.28.13.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 13:13:39 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Satisfaction caching of inherited ctor [PR94819] Date: Tue, 28 Apr 2020 16:13:38 -0400 Message-Id: <20200428201338.1651152-1-ppalka@redhat.com> X-Mailer: git-send-email 2.26.2.266.ge870325ee8 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-27.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, 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" As observed in PR94719, an inherited constructor for an instantiation of a constructor template confusingly has as its DECL_INHERITED_CTOR the TEMPLATE_DECL of the constructor template rather than the particular instantiation of the template. This means two inherited constructors for two different instantiations of the same constructor template will have the same DECL_INHERITED_CTOR. And since in satisfy_declaration_constraints our decl satisfaction cache is keyed off of the result of strip_inheriting_ctors, we may end up conflating the satisfaction value of the two inherited constructors' constraints. This patch fixes this issue by using the original tree, not the result of strip_inheriting_ctors, as the key to the decl satisfaction cache. Passes 'make check-c++', does this look OK to commit after a full bootstrap and regtest? gcc/cp/ChangeLog: PR c++/94819 * constraint.cc (satisfy_declaration_constraints): Use saved_t instead of t as the key to decl_satisfied_cache. gcc/testsuite/ChangeLog: PR c++/94819 * g++.dg/cpp2a/concepts-inherit-ctor10.C: New test. * g++.dg/cpp2a/concepts-inherit-ctor11.C: New test. --- gcc/cp/constraint.cc | 4 ++-- .../g++.dg/cpp2a/concepts-inherit-ctor10.C | 18 ++++++++++++++++ .../g++.dg/cpp2a/concepts-inherit-ctor11.C | 21 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor10.C create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor11.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 06161b8c8c4..866b0f51b05 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -2752,7 +2752,7 @@ satisfy_declaration_constraints (tree t, subst_info info) info.in_decl = t; if (info.quiet ()) - if (tree *result = hash_map_safe_get (decl_satisfied_cache, t)) + if (tree *result = hash_map_safe_get (decl_satisfied_cache, saved_t)) return *result; /* Get the normalized constraints. */ @@ -2787,7 +2787,7 @@ satisfy_declaration_constraints (tree t, subst_info info) } if (info.quiet ()) - hash_map_safe_put (decl_satisfied_cache, t, result); + hash_map_safe_put (decl_satisfied_cache, saved_t, result); return result; } diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor10.C b/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor10.C new file mode 100644 index 00000000000..387c07ae6b2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor10.C @@ -0,0 +1,18 @@ +// PR c++/94819 +// { dg-do compile { target concepts } } + +struct dna4 {}; +struct rna4 {}; + +struct alphabet_tuple_base { + template + requires __is_same(component_type, rna4) + alphabet_tuple_base(component_type) {} +}; + +struct structured_rna : alphabet_tuple_base { + using alphabet_tuple_base::alphabet_tuple_base; +}; + +structured_rna t2{dna4{}}; // { dg-error "no match" } +structured_rna t3{rna4{}}; // { dg-bogus "no match" } diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor11.C b/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor11.C new file mode 100644 index 00000000000..947edd84e53 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor11.C @@ -0,0 +1,21 @@ +// PR c++/94819 +// { dg-do compile { target concepts } } + +struct dna4 {}; +struct rna4 {}; + +template +struct alphabet_tuple_base { + template + requires __is_same(component_type, component_types) + alphabet_tuple_base(component_type) {} +}; + +template +struct structured_rna : alphabet_tuple_base { + using base_type = alphabet_tuple_base; + using base_type::base_type; +}; + +structured_rna t2{dna4{}}; // { dg-error "no match" } +structured_rna t3{rna4{}}; // { dg-bogus "no match" }