dg.exp passes on x86_64-pc-linux-gnu, ok for trunk?
-- >8 --
Here the assert was wrongly failing with
'void (struct F::)(int)' is not the same as 'void(int)'
but as per [dcl.fct]/1 the type of fType should not include the class F.
PR c++/123934
gcc/cp/ChangeLog:
* reflect.cc (type_of): For FUNCTION_DECLs, use static_fn_type.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/type_of2.C: Uncomment an assert.
---
gcc/cp/reflect.cc | 2 ++
gcc/testsuite/g++.dg/reflect/type_of2.C | 4 +---
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc
index 624414e2346..4557560779e 100644
--- a/gcc/cp/reflect.cc
+++ b/gcc/cp/reflect.cc
@@ -2465,6 +2465,8 @@ type_of (tree r, reflect_kind kind)
}
else if (TREE_CODE (r) == FIELD_DECL && DECL_BIT_FIELD_TYPE (r))
r = DECL_BIT_FIELD_TYPE (r);
+ else if (TREE_CODE (r) == FUNCTION_DECL)
+ r = static_fn_type (r);
else
r = TREE_TYPE (r);
return strip_typedefs (r);
diff --git a/gcc/testsuite/g++.dg/reflect/type_of2.C
b/gcc/testsuite/g++.dg/reflect/type_of2.C
index 29567918dc2..982b6202c7b 100644
--- a/gcc/testsuite/g++.dg/reflect/type_of2.C
+++ b/gcc/testsuite/g++.dg/reflect/type_of2.C
@@ -25,7 +25,5 @@ g ()
{
constexpr auto fInfo = foo<F>()[0];
using fType = [:type_of(fInfo):];
- // TODO Should work: non-const non-volatile member functions have ordinary
- // function types.
- //static_assert (std::same_as<fType, auto(int)->void>);
+ static_assert (std::same_as<fType, auto(int)->void>);
}
base-commit: f6838e731633d8b5b11f15ce3e227e18df2fe46e
--
2.52.0