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.
Reviewed-by: Jason Merrill <jason@redhat.com>
}
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);
{
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>);
}