From patchwork Mon Mar 4 23:30:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 1907934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=FDobhz3v; 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 4TpZgj0wt2z1yX3 for ; Tue, 5 Mar 2024 10:30:39 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CD59B385842A for ; Mon, 4 Mar 2024 23:30:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 3BFE33858C66 for ; Mon, 4 Mar 2024 23:30:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3BFE33858C66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3BFE33858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709595018; cv=none; b=xtiCsQS5KK1SWuqCNRCxhn1jkNYyRhfHqGKC+tKdzmFxvo21r3DrWrT+C0Kl5/+yVBYRcesVT2L05v31g1Gt+/fYI6qOMax5vhYB2Gztqg/jx9e4xn4LTeyt9/0BQN/7hyrRNOAMXAlP/nqpvKW49iX5Kb8QG/ozqfMKmFlsdyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709595018; c=relaxed/simple; bh=K+y1XGtSz21DkivrkWJX5A1ZD+X1T0CPeYYr90KltHc=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=Jdiex6lMJNK6eZV3r67WkgR8vZP5Ft2YigUkU02w6QTWMNhunpU9O0tqlA4qf9cnykEkh1yMB81I0jQ/W+fcHiU02VolQ0sOxDgfLWlHlq4IswHF1wPuxfQUCeXW0VcdREE+63wyKFo4qj9NjZHLvF91kTW+qC6dD59uyd+FfM8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d93edfa76dso45365625ad.1 for ; Mon, 04 Mar 2024 15:30:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709595015; x=1710199815; darn=gcc.gnu.org; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vQwlsYYM6YXuKXErbPwrZE+coEREp36q071j6ZkoADc=; b=FDobhz3vo77k5eRRyf6hPMq5L9U1J/pmN4rF+0mVeIsdKvDUMeInUkFH5Mgg5KpgEl y1F8jWGq//W3z1ko0y6Z+zRUpTsFnT5+3hKy2ak+gVqGzqPQ4D4t91R3RIVR/nD8fZ2b uFAHmznCksMMRdDe6jeqcrOcPb5IOrGwxqmu1ukQqNvxQmw0kX5yCcxOxzN9k8nUZtlf OjNgD2Hjg9orPWq/Tp1Qn3jCAsGBYQJvseukkdi+orTafwxdzIVe2QgeTGu6yXgcE8uQ BN7uVowfMl4ANYgpsmTOYSyNACnr+tWhQqvEeN+Xjh8kivvpxMG7It5/Z8rwz6QgsLKK 0L4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709595015; x=1710199815; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vQwlsYYM6YXuKXErbPwrZE+coEREp36q071j6ZkoADc=; b=qdLUGg4GZnbhRmZVBlMYwEiQsA3dnklwWwgGPArLpjYSkz7tET0W3u0rYbjaJf1SuP x+jhES/O86t1UEk+kYM1OvAeuvbs+BmUz84Y2pDt1wJ32SFxo4qXV3UQv788U8uK/KKv N7hFhHtNvJy0Ys7Nz3z0fbCObkMvdV2WU8MpAXGwvQXoobu/DoXFhaUn07XaClH8IF/O eHCFY6Hq9Y36y2ow5eFhj2YudQ36mDHQNudHqIkjXx9LQFGFtoyVLb/volyBxUsJwASr WRe3Ob7beVV/ckxS/ZMaukjU/Ob0vuaEX3YTQ0wmajU3SNtvDI2aRzVUJOfqgPYa12XX nnGg== X-Gm-Message-State: AOJu0YwMA9ijTwxRT4cURzyIEdAa15/mpYQpkoOX4EhDkW/u2fCj87K9 FgTc3SnoqzRdxVYtauy06EIdqJtgFCkkfEhsZbbHdiso4IF4OxHtLRDdPNpu X-Google-Smtp-Source: AGHT+IFKf995eQbkZrqXUuD367DDvjpUS3zIDrLRyYKLcdhAj/FnHUDaZCNPL7jw8iD5/OIs0OrAbg== X-Received: by 2002:a17:903:24e:b0:1db:8eae:b98e with SMTP id j14-20020a170903024e00b001db8eaeb98emr313105plh.38.1709595014974; Mon, 04 Mar 2024 15:30:14 -0800 (PST) Received: from Thaum. (110-175-172-107.tpgi.com.au. [110.175.172.107]) by smtp.gmail.com with ESMTPSA id u2-20020a170902e80200b001dca813b07csm9087696plg.62.2024.03.04.15.30.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 15:30:14 -0800 (PST) Message-ID: <65e65986.170a0220.bd30c.39c1@mx.google.com> X-Google-Original-Message-ID: Date: Tue, 5 Mar 2024 10:30:10 +1100 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell Subject: [PATCH] c++: Fix ICE diagnosing incomplete type of overloaded function set [PR98356] MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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, OK for trunk? -- >8 -- In the linked PR the result of 'get_first_fn' is a USING_DECL against the template parameter, to be filled in on instantiation. But we don't actually need to get the first set of the member functions: it's enough to know that we have a (possibly overloaded) member function at all. PR c++/98356 gcc/cp/ChangeLog: * typeck2.cc (cxx_incomplete_type_diagnostic): Don't assume 'member' will be a FUNCTION_DECL (or something like it). gcc/testsuite/ChangeLog: * g++.dg/pr98356.C: New test. Signed-off-by: Nathaniel Shead --- gcc/cp/typeck2.cc | 11 +++++------ gcc/testsuite/g++.dg/pr98356.C | 9 +++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr98356.C diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc index 9608bdccd8b..31198b2f9f5 100644 --- a/gcc/cp/typeck2.cc +++ b/gcc/cp/typeck2.cc @@ -350,16 +350,15 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value, bad_member: { tree member = TREE_OPERAND (value, 1); - if (is_overloaded_fn (member)) - member = get_first_fn (member); - - if (DECL_FUNCTION_MEMBER_P (member) - && ! flag_ms_extensions) + if (is_overloaded_fn (member) && !flag_ms_extensions) { gcc_rich_location richloc (loc); /* If "member" has no arguments (other than "this"), then add a fix-it hint. */ - if (type_num_arguments (TREE_TYPE (member)) == 1) + member = MAYBE_BASELINK_FUNCTIONS (member); + if (TREE_CODE (member) == FUNCTION_DECL + && DECL_OBJECT_MEMBER_FUNCTION_P (member) + && type_num_arguments (TREE_TYPE (member)) == 1) richloc.add_fixit_insert_after ("()"); complained = emit_diagnostic (diag_kind, &richloc, 0, "invalid use of member function %qD " diff --git a/gcc/testsuite/g++.dg/pr98356.C b/gcc/testsuite/g++.dg/pr98356.C new file mode 100644 index 00000000000..acea238593b --- /dev/null +++ b/gcc/testsuite/g++.dg/pr98356.C @@ -0,0 +1,9 @@ +// PR c++/98356 +// { dg-do compile { target c++11 } } + +template