From patchwork Mon Feb 19 14:39:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 85991 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 DC7B93858C52 for ; Mon, 19 Feb 2024 14:40:23 +0000 (GMT) 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 ESMTPS id 246453858D35 for ; Mon, 19 Feb 2024 14:39:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 246453858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 246453858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708353590; cv=none; b=xzF7kRzRfoSaz8ePUBRAJEp9uYAX6jWahMzNtWKEzj64SVV29qCbDk2PzQtqoIRXEENrarXA/q8lIpdcTBGz3Sy8EqMHznnI6RP2XDwvI3Ozin1+mYI33NSBzSt0ptQzniXqkvqMwKXnMasaMrUThlVu8R8o5frb0Zhqgo8hsRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708353590; c=relaxed/simple; bh=3krQbVk3Qs+zDMs/7tmmXWcYuRbM2y9r4vAdsQ9Zu4w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xNAUVm8q26ggfOXwS/E2xC9bEAFISc3LJIq32fUhsyNKDk5mrleoBEfUdAUK+7VWQsLQe9MOmLj0sDi6bU1Bak0bsbC7rSa1zJwu7p4tqH3K6gPwF6SdHVYZ0g+1lnWXcxk5zFi4lbbbWgINK11u31F2DFlNyBOHL2MBjZ3B5Bw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708353588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9ijfBCw0hWJzxfWAasiozC+TLbfiSQ4uantIijQm8v8=; b=MUcCem8jnHNe4ZFDnnY6MK5urG0d1TeMnnx6PFBPTdxHvZTQgc+LFvgxnXkCoYV/3skhWR 0cufUVKtB+t9HP27DWaUS7K5TZp53VzWQKk7YviNT7+XXHhfm5sNU5XDivHR0Em1EdDs7d 2mguMDYN7SB4m9sT/kuLwxX8DirCxvw= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-DAq3eddGPMqsu4WgHP-qHg-1; Mon, 19 Feb 2024 09:39:47 -0500 X-MC-Unique: DAq3eddGPMqsu4WgHP-qHg-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3c15074df25so2036272b6e.0 for ; Mon, 19 Feb 2024 06:39:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708353586; x=1708958386; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9ijfBCw0hWJzxfWAasiozC+TLbfiSQ4uantIijQm8v8=; b=LMFeFgnz311XE7bbEVlgFRVbQ4uIS8TS7i0LxxTlTz6xgYypSeIqdDmZx/7spuyczg dJ7lIyVoiSkT6kgxIrq9gSTr4G1GWlbHLRn/2NB2e48yhHA/lC4L48flvlqsjUUJrlzP El1zrMRQS9WRRNGdRi7tCNqZfZYaMfpj8tB/FCP1zsTAaQjiFUI3ooaqQF+bkW+MTL4U V6Cml1EAE3W3ckcTWKys5OoskS4k7yrCCHoyJd6haOx/PnqATeZ1udpBjGVKXsX2rCrP 5KfxvruUnRJvmSUBQ6nkjr6H9MY6RGvLe3YQp+iuCjyZaYQmtWuYg0qLGsO14l6FmotK ivdQ== X-Gm-Message-State: AOJu0Yw4F9TzG5Fcw9NmIErJC6iDsCKa7xUljJQu5LD2T+ewDvC3oH2K H98tmCVpvrR++0lLWO0lpz0fns1zOl18SgwIDIxh3QoNJG0tra012ZXDBIbfJIc8q5P4fwm1j/Y pqGscPe+wRwa6o0yX61FRg/cLJ8I4pFhqmQSpetSrst8mPunTQDkWh+XQJ6KgvagL2N6TZ4CkXP 1g89aF2ROws0uAwY/12tHQ+G3vursSrcvrfM4o X-Received: by 2002:a05:6808:1186:b0:3bf:fb34:c7b0 with SMTP id j6-20020a056808118600b003bffb34c7b0mr13510405oil.29.1708353585765; Mon, 19 Feb 2024 06:39:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQsX3oB4h0LTNqA2W9mw1AYOKYlauKDD8lY18dGNSxOQPmyVOxZ6sjNC4UjC5EmR8iE2KOLw== X-Received: by 2002:a05:6808:1186:b0:3bf:fb34:c7b0 with SMTP id j6-20020a056808118600b003bffb34c7b0mr13510350oil.29.1708353584817; Mon, 19 Feb 2024 06:39:44 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id ow5-20020a0562143f8500b0068f4b06588dsm2697493qvb.7.2024.02.19.06.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 06:39:43 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: compound-requirement partial substitution [PR113966] Date: Mon, 19 Feb 2024 09:39:42 -0500 Message-ID: <20240219143942.680773-1-ppalka@redhat.com> X-Mailer: git-send-email 2.44.0.rc1.15.g4fc51f00ef MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.6 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_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? -- >8 -- When partially substituting a requires-expr, we don't want to perform any additional checks beyond the substitution itself, so as to minimize checking requirements out of order. So when partially substituting a compound-requirement don't check its return-type-requirement. Don't check the noexcept condition either since we can't do that on templated trees. PR c++/113966 gcc/cp/ChangeLog: * constraint.cc (tsubst_compound_requirement): Don't check the noexcept condition or the return-type-requirement when partially substituting. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-friend17.C: New test. --- gcc/cp/constraint.cc | 5 +++-- gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index d9569013bd3..49de3211d4c 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -2134,7 +2134,8 @@ tsubst_compound_requirement (tree t, tree args, sat_info info) /* Check the noexcept condition. */ bool noexcept_p = COMPOUND_REQ_NOEXCEPT_P (t); - if (noexcept_p && !expr_noexcept_p (expr, quiet.complain)) + if (noexcept_p && !processing_template_decl + && !expr_noexcept_p (expr, quiet.complain)) { if (info.diagnose_unsatisfaction_p ()) inform (loc, "%qE is not %", expr); @@ -2148,7 +2149,7 @@ tsubst_compound_requirement (tree t, tree args, sat_info info) return error_mark_node; /* Check expression against the result type. */ - if (type) + if (type && !processing_template_decl) { if (tree placeholder = type_uses_auto (type)) { diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C b/gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C new file mode 100644 index 00000000000..9b5091f14a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C @@ -0,0 +1,15 @@ +// PR c++/113966 +// { dg-do compile { target c++20 } } + +template concept C = T::value; + +template +struct A { + template requires U::value || requires { { T() } -> C; } + friend void f(A, U) { } + + template requires requires { { g(U()) } noexcept; } + friend void f(A, U, U) { } +}; + +template struct A;