Fix decltype(id) for pointer-to-data-member access expressions
Fixes an issue where `decltype` incorrectly deduced the type of pointer-to-data-member access expressions, yielding `const int*` instead of `int`.
This commit fixes a bug where decltype incorrectly deduced the type of pointer-to-data-member access expressions. The finish_decltype_type function incorrectly stripped the outermost INDIRECT_REF, assuming it was an implicit dereference of a reference, but it was actually an explicit pointer dereference. This resulted in decltype yielding const int* instead of the expected int. This commit affect template meta-programming that relies on accurate type deduction with decltype.
In Details
Addresses PR c++/124978, where finish_decltype_type in semantics.cc incorrectly strips an INDIRECT_REF during decltype processing of pointer-to-data-member access expressions. The fix checks REFERENCE_REF_P instead of INDIRECT_REF_P to ensure the dereferenced object has reference type. Interaction with PR115314 (unnecessary const) is noted.
For Context
In C++, decltype is used to determine the type of an expression. This commit fixes a bug related to how decltype works with pointers to members of a class. Specifically, when decltype was used on an expression that accesses a member of a class through a pointer, it would sometimes incorrectly deduce the type, adding an unnecessary const. This correction ensures that decltype accurately reflects the type of such expressions.