tree fntype = TREE_TYPE (CALL_EXPR_FN (*expr_p));
if (INDIRECT_TYPE_P (fntype))
fntype = TREE_TYPE (fntype);
- if (TREE_CODE (fntype) == METHOD_TYPE)
+ tree decl = cp_get_callee_fndecl_nofold (*expr_p);
+ /* We can't just rely on 'decl' because virtual function callees
+ are expressed as OBJ_TYPE_REF. Though checking for METHOD_TYPE
+ means we'll also sequence PMF calls, which is allowed under
+ "indeterminately sequenced". */
+ if (TREE_CODE (fntype) == METHOD_TYPE
+ || (decl && DECL_LANG_SPECIFIC (decl)
+ && DECL_XOBJ_MEMBER_FUNCTION_P (decl)))
{
int nargs = call_expr_nargs (*expr_p);
bool side_effects = false;
--- /dev/null
+// PR c++/123989
+// { dg-do run { target c++23 } }
+
+struct A {
+ int m = 42;
+
+ void f(this A self, int n) {
+ if (self.m != 42 || n != 43)
+ __builtin_abort();
+ }
+};
+
+int main() {
+ A a;
+ a.f(++a.m);
+}