From patchwork Tue Apr 21 13:55:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1274274 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=YODvUpHP; 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 4964ps2Hd9z9sSW for ; Tue, 21 Apr 2020 23:56:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5C48A386F425; Tue, 21 Apr 2020 13:56:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C48A386F425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587477361; bh=m5pBoL9dUrvEntBpqN0fYND2ttMU/Ostrh7qAP0upAg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=YODvUpHPoiHU7jmTv/ouQIBj5kG185gUOL/BOVRLGq/1Yb9cLccUlO3BI1g/RH6GO q0YO9NdMJf8HbeyDD56AIQwTv0cFp0FHdKE1rC1bDJ6w2Z3mhHqd6jZvzWs+uHYxZt ppMb3EWT0ZAGTF9K7r/fPnNhFIAauTwp1CxwnZkk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id DB85D384B0C1 for ; Tue, 21 Apr 2020 13:55:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DB85D384B0C1 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-383-d7cpRVRkOLOiCdrJ778Nzg-1; Tue, 21 Apr 2020 09:55:56 -0400 X-MC-Unique: d7cpRVRkOLOiCdrJ778Nzg-1 Received: by mail-qv1-f72.google.com with SMTP id f9so13976481qvt.14 for ; Tue, 21 Apr 2020 06:55:56 -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=9H56dd/aOD18WQp3r60v6BRfnBh3MYOpTB7L9mSJ2k4=; b=Qc2Qz0Ss2XBx8uXTY8vXhPAE6Lt9BcqWeTLQrYuQQQQbPzMOnqFt53w8Nx7f41+dx5 4S1bP/5WUmsecKj6pQt82GeA8oqj8q0os3+wiAf3+YgAGPX60x+i6Jw2w9Mcbs/776cT JhHF9tXrZn75cBVvVmN0nnDCFaJr8HuqHJMP8NJg511fCQ9YINsA3kI8tq8TkjDNh1eN DhvAaZHDbX8xJfQltiluDBfds/Nykq9zvBDZS5HuPdIBcWS4VM0h0mvqL47NLKwhHuKh SMNMx7mgQHzwdlto7QDvlAIxPxVOas6SOwM/MOnfqDDfvTW3INM6LEukYcVWv2xQejNz g/Kg== X-Gm-Message-State: AGi0Puajwmnt3QBtg+ZzeZqm22kllvQwoz4BZeZgnSFNVJPPf0YA6d8F H9mEkql/ijjUuO7OYTeQgF0OYlrJUH+69om7AO+dgMbZMiGkekaWh75RW+fRf2vZHlCQFwzHCsv DSaLsS9MyJVw7JiwZPw== X-Received: by 2002:a0c:e850:: with SMTP id l16mr1990169qvo.117.1587477355691; Tue, 21 Apr 2020 06:55:55 -0700 (PDT) X-Google-Smtp-Source: APiQypKBm6+KEAmDLWqxeM+vYcxSgT81rmY2yeM/dR9VqK0jpJkN1C8MjJ0Z8qtAhLwC7tdVShp4Tg== X-Received: by 2002:a0c:e850:: with SMTP id l16mr1990154qvo.117.1587477355416; Tue, 21 Apr 2020 06:55:55 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id w10sm1844731qka.19.2020.04.21.06.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:55:54 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Dependent conversion operator in concept [PR94597] Date: Tue, 21 Apr 2020 09:55:52 -0400 Message-Id: <20200421135552.1818433-1-ppalka@redhat.com> X-Mailer: git-send-email 2.26.2.108.g048abe1751 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-28.5 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" When building the parameter mapping for an atomic constraint, find_template_parameters does not spot the template parameter within the conversion-type-id of a dependent conversion operator, which later leads to an ICE during substitution when looking up the missing template argument for this unnoticed template parameter. (The below testcase is a modification of the reduced testcase in the PR, adding parens to the requirement 'e.operator c;' as a workaround for PR94645.) Boostrapped and regtested on x86_64-pc-linux-gnu, does this look OK to commit? gcc/cp/ChangeLog: PR c++/94597 * pt.c (any_template_parm_r) : New case. If this is a conversion operator, visit its TREE_TYPE. gcc/testsuite/ChangeLog: PR c++/94597 * g++.dg/cpp2a/concepts-conv2.C: New test. --- gcc/cp/pt.c | 6 ++++++ gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cd6392aca22..2111f031d9e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10529,6 +10529,12 @@ any_template_parm_r (tree t, void *data) } break; + case IDENTIFIER_NODE: + if (IDENTIFIER_CONV_OP_P (t)) + /* The conversion-type-id of a conversion operator may be dependent. */ + WALK_SUBTREE (TREE_TYPE (t)); + break; + default: break; } diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C b/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C new file mode 100644 index 00000000000..abe68187cce --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C @@ -0,0 +1,19 @@ +// PR c++/94597 +// { dg-do compile { target c++2a } } + +template concept d = requires(b e) { e.operator c(); }; + +template requires(d) bool equal(f, g); + +template struct i { + i(h); + operator h(); +}; + +static_assert(d, float>); +static_assert(!d, int>); + +bool fun() { + i a(2.0f); + return equal(a, 3.0f); +}