From patchwork Tue Feb 6 02:29:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1895471 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jUlLwNF5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TTRzV3cpSz23g7 for ; Tue, 6 Feb 2024 13:29:58 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05CD53858D35 for ; Tue, 6 Feb 2024 02:29:55 +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 6844A3858D33 for ; Tue, 6 Feb 2024 02:29:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6844A3858D33 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 6844A3858D33 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=1707186571; cv=none; b=L4vfMO+QZNJhG3UelxJ/LN1QkueYPD4WqOTaPUx78dV2MPKI7iVKncheh3X4SmNfYDsCzlEAklJCKHbfvGQ7L9qgZZxyXHHeqmNvSl9TPW2Wo7wzkoy4iAjY2mEmWbyJs5sKSN1KuPIOCarr+Y+5iWJzaJFzF6hMCmA9W8CjwE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707186571; c=relaxed/simple; bh=oaAyEjMu+NkoSJAZBDbqiSQS1Eps07O870MumU1uHmU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aOCh3v8n3MeAgVkUagOKitKtU0Ta4zduUG6ufnXrJTY2tTJren6KG0mlaz6NcE2sQoaPezyIrekkEnk+rnZiKPFZ5QVca1zn7k6AP/pe8gWENtpLB5XruUNFjiJFtDC9Rg6ybil1fpQSzE53HpQOVFtqmP+JuFvGSfF/BwHcDII= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707186570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tfmHqxq6n1KOZi4cJ+Uu3ZK3xTEovZaf1vC5n5jScOs=; b=jUlLwNF5lmbS0buyGXAiXmnMvJC5ttAycXYVEgq513nOQ5kEEP8Kphc5aogelbHIoMSmRm bRRzoH9iE4aVpWvVPY5jX6Qfhkwd2LjSSpggLwUOQM4rtgP5F/A/TSaOyTeeSq/C5dVF2m d9dXbK7Cwc+enGDkFEfpCK0ZeDP8rJw= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-330-3A67y_0ZMf62J41Kcv03Fg-1; Mon, 05 Feb 2024 21:29:28 -0500 X-MC-Unique: 3A67y_0ZMf62J41Kcv03Fg-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-42ab8a525aaso50775851cf.3 for ; Mon, 05 Feb 2024 18:29:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707186567; x=1707791367; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tfmHqxq6n1KOZi4cJ+Uu3ZK3xTEovZaf1vC5n5jScOs=; b=EQhks8yKKRnmjC0HJxLgMv9wGRuAfN8OTywJMN7YirMYy3uvcD1buYitdZ7g2KUIPJ GBdgFuKUCa6p9G8QaNscYsx6HGOcONLjk4LJp7LojH9Hmtf+jjWhYJq4TsBR9lz1LYJJ 2GGoZMAWoIMFXf70CA1Hi+/TJa99OdL8jqQfvmhkYIpJ+gX8CcuXlkqh9Uo2lma7MwE/ s+BXe4ehHCe31FNjyo1FzmwKtvgQN/FWtDOYryvusTykpuJr4CYvzso0ZoqkVrNSfQgx LoEbEx72o604ZY8xc6D5tZvE4o6CC+ZSwbR7dERPAHGkbg8HpN6j+xp88FISRSKuKqnl ZqLQ== X-Gm-Message-State: AOJu0Yz5438a8jG52GohzO0XDsZOarpshBzotMNAKwUkGvKByoL41WlT pI42HxcO/RdogAK+Kc/7ExidRPUMZ+WxcvaphP+gHxmKtz0E+aPYiEWnNcc2Z8IYvxq3rwFieod Wt2cpzOOcSTIiw0XhwIdERcwuA5dy2+Hn5WVYOqduHv/mSCHpsZMXuZsplmMIyzJWxd541tCELW 7Ng7s4RK6RjdEP+6szUvV7aWfsYW0yDJ/lDIQ= X-Received: by 2002:ac8:134d:0:b0:42b:ef35:650c with SMTP id f13-20020ac8134d000000b0042bef35650cmr1218060qtj.31.1707186567708; Mon, 05 Feb 2024 18:29:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFyYehtf26H1Ds+lF4HKNvK+piSZZOWqtNCE7GNK6QXTjlaSy0nWLp3Qg9G2ar6MK9cYlzVA== X-Received: by 2002:ac8:134d:0:b0:42b:ef35:650c with SMTP id f13-20020ac8134d000000b0042bef35650cmr1218048qtj.31.1707186567344; Mon, 05 Feb 2024 18:29:27 -0800 (PST) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id h10-20020ac8584a000000b0042c2320e6d7sm493998qth.16.2024.02.05.18.29.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 18:29:26 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: defaulted op== for incomplete class [PR107291] Date: Mon, 5 Feb 2024 21:29:08 -0500 Message-ID: <20240206022925.850651-1-jason@redhat.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.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_H5, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- After complaining about lack of friendship, we should not try to go on and define the defaulted comparison operator anyway. PR c++/107291 gcc/cp/ChangeLog: * method.cc (early_check_defaulted_comparison): Fail if not friend. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/spaceship-eq17.C: New test. --- gcc/cp/method.cc | 6 +++++- gcc/testsuite/g++.dg/cpp2a/spaceship-eq17.C | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/spaceship-eq17.C base-commit: d49780c08aade447953bfe4e877d386f5757f165 diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc index d49e5a565e8..3b8dc75d198 100644 --- a/gcc/cp/method.cc +++ b/gcc/cp/method.cc @@ -1228,7 +1228,11 @@ early_check_defaulted_comparison (tree fn) /* Defaulted outside the class body. */ ctx = TYPE_MAIN_VARIANT (parmtype); if (!is_friend (ctx, fn)) - error_at (loc, "defaulted %qD is not a friend of %qT", fn, ctx); + { + error_at (loc, "defaulted %qD is not a friend of %qT", fn, ctx); + inform (location_of (ctx), "declared here"); + ok = false; + } } else if (!same_type_ignoring_top_level_qualifiers_p (parmtype, ctx)) saw_bad = true; diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-eq17.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-eq17.C new file mode 100644 index 00000000000..039bfac387c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-eq17.C @@ -0,0 +1,5 @@ +// PR c++/107291 +// { dg-do compile { target c++20 } } + +struct S4; // { dg-message "declared here" } +bool operator==(S4 const &, S4 const &) = default; // { dg-error "not a friend" }