Message ID | 20240206022925.850651-1-jason@redhat.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1278838dyb; Mon, 5 Feb 2024 18:30:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IExpLe6tCkqobFLWzgw8RDEpKAtdzFIShjTh74CDJ0OZUj/js38wkb14Av4t7M/5aKXOsEO X-Received: by 2002:ac8:5812:0:b0:42c:3335:941c with SMTP id g18-20020ac85812000000b0042c3335941cmr1518453qtg.5.1707186620281; Mon, 05 Feb 2024 18:30:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707186620; cv=pass; d=google.com; s=arc-20160816; b=yT3ZwByPO3yR11F1r8q/FOV9LfesiMXriq6lNRzOBcz2vrLcKndKXMg+smaIW1OpG4 dsH22tpBROIDB+zu3OoWVoV3cf3ZGLLLQdMYtwwgEonSfC0B6QEUBKclLaF8tsv004LH 5bNVvvpj1DzydBZWagPpHoYCQoPl3aWjjb1PwACA4buBQGq5/HBdcOHQeVGyPu6OD0uy Dz/+rNnozUfKACDnMGvKBQiaZws5x7W8PjsnQBy6Tlw6v5K5sIlah3OJy0duZXnT9uLd 7IsnWytM182w42woq0NfiU6UINsnulz5BazLAhSgnvQROMuobkt1MCKy5D2eTFKLR5qG ADhg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=tfmHqxq6n1KOZi4cJ+Uu3ZK3xTEovZaf1vC5n5jScOs=; fh=5KdjkmoVVZAgV5IBUhahOc953myg9LE4zstlW/Uwgg8=; b=doShJ8Fd3IINvvXD5gGQDefB7n1kC1HC3GgoBhiFrKXU6HgVgp1sjZgzfxLmNcfUtb n393kAOgW8N3/637xnU6UjFPxhq3W4DOghzxedXP+EZzXf0/gM5k5Vt7oayU0QUKh3T9 bbFsrJchWRuVM3hhpsJBmtmG3OPl9IMclZgEqFYaSCVSSHwtqB35mUW7FfOIRMKZ1ifm bgsYKOLjMVJe8Zl/9BYy5q56OtdlVmYjuuA4wmgI9ZZmDDAhVIro4AeU0TarLsE3xhsi 6WXyfpmPJek2PYJ7T3LdKmNMNKY0yKqje3ZffE+hDWwc+gg13SlptImlV2F/di5XxGcW l61w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jUlLwNF5; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCXMsdRB/LKHh5quZvAU9guQd4I9XJoMEqts2dvZ1GjFCkK9FqyGOv7EQWVGL/ZqkTj0TDkpCRGNTLtXEvIBhVio+WTjdA== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p14-20020a05622a13ce00b0042c078b9ba4si1309083qtk.423.2024.02.05.18.30.20 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 18:30:20 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jUlLwNF5; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F1C3D3858D38 for <ouuuleilei@gmail.com>; Tue, 6 Feb 2024 02:30:19 +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 <gcc-patches@gcc.gnu.org>; 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 <gcc-patches@gcc.gnu.org>; 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-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 <gcc-patches@gcc.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 18:29:26 -0800 (PST) From: Jason Merrill <jason@redhat.com> 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790114917450021285 X-GMAIL-MSGID: 1790114917450021285 |
Series |
[pushed] c++: defaulted op== for incomplete class [PR107291]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Jason Merrill
Feb. 6, 2024, 2:29 a.m. UTC
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
Comments
On Mon, Feb 05, 2024 at 09:29:08PM -0500, Jason Merrill wrote: > 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 > > 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; Can I push this? gcc/cp/ChangeLog: * method.cc (early_check_defaulted_comparison): Add auto_diagnostic_group. --- gcc/cp/method.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc index 3b8dc75d198..957496d3e18 100644 --- a/gcc/cp/method.cc +++ b/gcc/cp/method.cc @@ -1229,6 +1229,7 @@ early_check_defaulted_comparison (tree fn) ctx = TYPE_MAIN_VARIANT (parmtype); if (!is_friend (ctx, fn)) { + auto_diagnostic_group d; error_at (loc, "defaulted %qD is not a friend of %qT", fn, ctx); inform (location_of (ctx), "declared here"); ok = false; base-commit: c5d34912ad576be1ef19be92f7eabde54b9089eb
On 2/5/24 21:55, Marek Polacek wrote: > On Mon, Feb 05, 2024 at 09:29:08PM -0500, Jason Merrill wrote: >> 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 >> >> 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; > > Can I push this? > > gcc/cp/ChangeLog: > > * method.cc (early_check_defaulted_comparison): Add > auto_diagnostic_group. Oops, yes, please. In the future, adding missing auto_diagnostic_group can be pushed as obvious. > --- > gcc/cp/method.cc | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc > index 3b8dc75d198..957496d3e18 100644 > --- a/gcc/cp/method.cc > +++ b/gcc/cp/method.cc > @@ -1229,6 +1229,7 @@ early_check_defaulted_comparison (tree fn) > ctx = TYPE_MAIN_VARIANT (parmtype); > if (!is_friend (ctx, fn)) > { > + auto_diagnostic_group d; > error_at (loc, "defaulted %qD is not a friend of %qT", fn, ctx); > inform (location_of (ctx), "declared here"); > ok = false; > > base-commit: c5d34912ad576be1ef19be92f7eabde54b9089eb
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" }