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: 1889318 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=ZLcDi1I3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TJdbp5yJxz23db for ; Tue, 23 Jan 2024 05:12:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A672C385828F for ; Mon, 22 Jan 2024 18:12: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 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-Google-Smtp-Source: AGHT+IGUNPiy5zNQGXBWlcbHPkgxhphBCYbonzMxH6SQ6vXmVLXkBpJAOy88g13z5finQcNpwBxZwA== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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);