aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-03-05 01:59:41 +1100
committerNathaniel Shead <nathanieloshead@gmail.com>2024-03-07 21:59:32 +1100
commit940586a63586941a9f2b973491afc8a15a96c98b (patch)
tree0ee9cd379e30cd78ca87beddcf386363bd61b780 /gcc
parent77772f8a3da8ea30066d2201f8148714a8e89da5 (diff)
downloadgcc-940586a63586941a9f2b973491afc8a15a96c98b.zip
gcc-940586a63586941a9f2b973491afc8a15a96c98b.tar.gz
gcc-940586a63586941a9f2b973491afc8a15a96c98b.tar.bz2
c++: Fix ICE diagnosing incomplete type of overloaded function set [PR98356]
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/typeck2.cc11
-rw-r--r--gcc/testsuite/g++.dg/pr98356.C9
2 files changed, 14 insertions, 6 deletions
diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index 9608bdc..31198b2 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 0000000..acea238
--- /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" }
+};