* [PATCH] c++: Fix ICE diagnosing incomplete type of overloaded function set [PR98356]
@ 2024-03-04 23:30 Nathaniel Shead
2024-03-07 1:58 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Nathaniel Shead @ 2024-03-04 23:30 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill, Nathan Sidwell
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 <nathanieloshead@gmail.com>
---
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 <template <typename> class T> struct S {
+ using A = T<int>;
+ using A::foo;
+ void foo ();
+ void bar () {foo.} // { dg-error "invalid use of member function" }
+};
--
2.43.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++: Fix ICE diagnosing incomplete type of overloaded function set [PR98356]
2024-03-04 23:30 [PATCH] c++: Fix ICE diagnosing incomplete type of overloaded function set [PR98356] Nathaniel Shead
@ 2024-03-07 1:58 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2024-03-07 1:58 UTC (permalink / raw)
To: Nathaniel Shead, gcc-patches; +Cc: Nathan Sidwell
On 3/4/24 18:30, Nathaniel Shead wrote:
> Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk?
OK.
> -- >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 <nathanieloshead@gmail.com>
> ---
> 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 <template <typename> class T> struct S {
> + using A = T<int>;
> + using A::foo;
> + void foo ();
> + void bar () {foo.} // { dg-error "invalid use of member function" }
> +};
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-07 1:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-04 23:30 [PATCH] c++: Fix ICE diagnosing incomplete type of overloaded function set [PR98356] Nathaniel Shead
2024-03-07 1:58 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).