From patchwork Mon Jan 22 18:11:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 190284 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2748107dyb; Mon, 22 Jan 2024 10:12:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWlxwxDQqkahY1U/5MM8OgtJSBGanGQUa7MjCX3ltg/zeulleJifHB+51bJskdyZ2JDSPK X-Received: by 2002:a05:620a:404b:b0:783:a1e1:cd2f with SMTP id i11-20020a05620a404b00b00783a1e1cd2fmr1721765qko.35.1705947163332; Mon, 22 Jan 2024 10:12:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705947163; cv=pass; d=google.com; s=arc-20160816; b=RQQIFepbfAXwkRdr1eCxw+K94xFmPc3Ll+/AiIpC0huzP0QyBFQkS5rPEFs0k6ZpbS 0h4eA9JEJXpEs2qUBHp/ezZSHavkNUj8v2YRAkvNv6xbHQll1ywwUxJxsym6YNlP81RI nIX5jV0teSILkP3BJ47z6K3piNZAbr/bFgzKNb5wXwOEulpmYeyv0sv5iYIBsIm3XQM7 7Zz0ZQhhouUwJx3AolnbGQ0r95hXvhpFQmac3wDftWoDEHhVnoNxFOsUYHU22MEkb0QN PC5prrOEJlGqDa25L01cZp5jJRSxXbKKtjcovaat66fapLdIAlFJP1kWaXWKhXcOa2lF ffdw== 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:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=z1anieoOv43JupjbJ1rfgzKGe6j5iOJiEvn8EMVZLCw=; fh=1Hi9m88IqcWZGtfSxUrMGG+GBgL26N02X1SANXM6iTs=; b=SVEapQkuRHV/IWXKCMvUIb7yDUA0S96o8SZpBzXsP/D+BslAZVl+Jx8FF9PMrmcTyk NWX6dZLOEK5NFgCPbsONFohO9CwagbR3Z2s9P2rlT/aPqPI9279lm705m6xFAhHlboOR tWVP+IMDil4jSGoiGJCQxYgj2OfJ/4DIz4ge2PWEf8glHYJR8pU/Is17KIQ8hC9FvqLR oHEIASzFK/F2k0JcKDDPzME8g/PNwPfPnD521tstQUY1CdmVRkFVIS6IMfflFWay45HT xG/7ITmKIhbXiL3Rw63HBBnqxNaNH3RoUqChtZiqK29TM5bfwuMaKWTWPw2Yx2OVc8Qo 1Acw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZLcDi1I3; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id pi37-20020a05620a37a500b0078393f45c20si5253813qkn.20.2024.01.22.10.12.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 10:12:43 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZLcDi1I3; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 EC6433858417 for ; Mon, 22 Jan 2024 18:12:42 +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 9D4A73858412 for ; Mon, 22 Jan 2024 18:11:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D4A73858412 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 9D4A73858412 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=1705947121; cv=none; b=x3nuePdhombhsyib6Y8J5FltiNOuZZWZiBEC6CL3DP7Nv9Q8NzOS6ABfiXhoU55bb4y4Us8HuM4VsLT10eJng4yqQ6mc5aQ2jzRivO/jQIYEywItlaeAxHyPTgDOhdRZB6Ls4qFDmfBMVpbfb86o2K2hV0VXn3W7ILsoLHfO1kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705947121; c=relaxed/simple; bh=t+o7t2+l7cTEjBHAWyiT7xHgzLSg1h/HWwuR80R6Rpw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aEklVlfNwJNS9TzFwFoPybleiPlpadWh63YTbQrEDxGXwIt2RMvYDqCBvPXaqFU/YmWdfH5E/y9QZPFfPMvaVRCwjyJd4s7zpDKp+F6J5ttVKGBuZV+C+2Fb7A+3Z9iDP7LmeT3YgMV+BQWdhjFCBIk1f7+sVTHARf1nXPsI0Dg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705947119; 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=z1anieoOv43JupjbJ1rfgzKGe6j5iOJiEvn8EMVZLCw=; b=ZLcDi1I3D4re/R4jOBdu8RvanLL5yg/rhzB+ygH9u/NGKfQI2H3Vje/Ne6ZKsdJBwnkmwQ c2O06P1TXWNZgHmSRJsu0iuTbj28h0oP6PppPURzJVlGDBwr0j5H6T/zXpTVFlgRLpjy3p Y8f8xJEzBEELeDQ+vMXbW8kLzvJHjJE= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-56-w5xTYgiVNxWb8yiW4IQp3Q-1; Mon, 22 Jan 2024 13:11:58 -0500 X-MC-Unique: w5xTYgiVNxWb8yiW4IQp3Q-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3bdb1f7e9d0so2714959b6e.1 for ; Mon, 22 Jan 2024 10:11:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705947116; x=1706551916; 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=z1anieoOv43JupjbJ1rfgzKGe6j5iOJiEvn8EMVZLCw=; b=fsf3vnIW7+DWw0dgAx0UZ81gTLMSLc1v+z4z6o8mc4uuz6QB08Os3DXh0USoAS8Cf8 /gJ21xZ42Xs2u/WzEbqKhi9m9uHN/z3zlhdWtNkBQQhEtYftwR+bkQfNIZxYS/iaiIbi 6C+AMXBo0xy7hiIb5Zx6Ua4kHMrAQOl0WH6Vp2NHRnu+NqGnLsmk6mkzb7qMZ+Am0GlB xByrbtzMX0ImtLagcQ20x6mjT1cqudeGdHbf49YolFHC0beVf8C09b/tIg1fQ7OI3JU/ uVbCM3mYutMUik2nhHIBNaw/AF3MxUrJTbQGDdff90QGVDwbxJYfWep+8U9aEObsK7/R ZNxg== X-Gm-Message-State: AOJu0YypNN0D2usBqJNE6tKuULgGJokAs9rBOMHglU8ndAl7TO55FOLn bZbLea/aslrWTHPkeNgQj5amJxH9G0kSObC5WUpc5C98mU/3yTfwP74mlAJVwfI5fh9YQuABkbI IOZfOImWt6kvKSFTOCPnReQlbPe9dXv5eUjcRQXx/YP/U+d7NVfpuu0pNydlf0ACQcdR3YUrsMJ +xnUu8O+WCRxWvBg0pl1PwJiyHTspJLYJHci9v X-Received: by 2002:a05:6808:31a:b0:3bd:252d:70cc with SMTP id i26-20020a056808031a00b003bd252d70ccmr5625627oie.62.1705947115883; Mon, 22 Jan 2024 10:11:55 -0800 (PST) X-Received: by 2002:a05:6808:31a:b0:3bd:252d:70cc with SMTP id i26-20020a056808031a00b003bd252d70ccmr5625615oie.62.1705947115538; Mon, 22 Jan 2024 10:11:55 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id bx9-20020a05622a090900b0042a460cad28sm501089qtb.91.2024.01.22.10.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 10:11:55 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: ambiguous member lookup for rewritten cands [PR113529] Date: Mon, 22 Jan 2024 13:11:53 -0500 Message-ID: <20240122181153.876572-1-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.386.ge02ecfcc53 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.5 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_H3, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788815253006885346 X-GMAIL-MSGID: 1788815253006885346 Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/13? -- >8 -- Here we handle the operator expression u < v inconsistently: in a SFINAE context (such as a requires-expression) we accept the it, and in a non-SFINAE context we reject it with error: request for member 'operator<=>' is ambiguous as per [class.member.lookup]/6. This inconsistency is ultimately because we neglect to propagate error_mark_node after recursing in add_operator_candidates, fixed like so. PR c++/113529 gcc/cp/ChangeLog: * call.cc (add_operator_candidates): Propagate error_mark_node result after recursing to find rewritten candidates. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/spaceship-sfinae3.C: New test. --- gcc/cp/call.cc | 11 +++++++--- .../g++.dg/cpp2a/spaceship-sfinae3.C | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/spaceship-sfinae3.C diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 1f5ff417c81..183bb8c1348 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -7007,9 +7007,14 @@ add_operator_candidates (z_candidate **candidates, { flags |= LOOKUP_REWRITTEN; if (rewrite_code != code) - /* Add rewritten candidates in same order. */ - add_operator_candidates (candidates, rewrite_code, ERROR_MARK, - arglist, lookups, flags, complain); + { + /* Add rewritten candidates in same order. */ + tree r = add_operator_candidates (candidates, rewrite_code, + ERROR_MARK, arglist, lookups, + flags, complain); + if (r == error_mark_node) + return error_mark_node; + } z_candidate *save_cand = *candidates; diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-sfinae3.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-sfinae3.C new file mode 100644 index 00000000000..ca159260ec7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-sfinae3.C @@ -0,0 +1,22 @@ +// PR c++/113529 +// { dg-do compile { target c++20 } } + +#include + +struct A { + auto operator<=>(const A&) const = default; + bool operator<(const A&) const; +}; +struct B { + auto operator<=>(const B&) const = default; +}; +struct C : A, B { }; + + +template +void f(T u, T v) { + static_assert(!requires { u < v; }); + u < v; // { dg-error "request for member 'operator<=>' is ambiguous" } +} + +template void f(C, C);