c++: dump-lang-raw with obj_type_ref fields

Raw dump of lang tree was missing information about virtual method call.
The information is provided in "tok" field of obj_type_ref.

gcc/ChangeLog:

	* tree-dump.cc (dequeue_and_dump): Handle OBJ_TYPE_REF.

gcc/testsuite/ChangeLog:

	* g++.dg/diagnostic/lang-dump-1.C: New test.
This commit is contained in:
anetczuk 2025-01-14 20:35:44 +01:00 committed by Jason Merrill
parent c8894b6811
commit 6e0b048fb5
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,22 @@
// { dg-do compile }
// { dg-additional-options "-fdump-lang-raw" }
// Check if dump file contains OBJ_TYPE_REF with additional fields (information about called virtual method).
class VExample {
public:
virtual void methodV1() {}
virtual void methodV2() {}
};
void funcA() {
VExample objA;
VExample *ptrA = &objA;
ptrA->methodV2();
ptrA->methodV1();
}
// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*type:} 2 raw } }
// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*expr:} 2 raw } }
// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*obj :} 2 raw } }
// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*\n[^\n]*tok :} 2 raw } }

View file

@ -697,6 +697,13 @@ dequeue_and_dump (dump_info_p di)
dump_child ("op: ", OMP_CLAUSE_OPERAND (t, i));
}
break;
case OBJ_TYPE_REF:
dump_child ("expr", OBJ_TYPE_REF_EXPR (t));
dump_child ("obj", OBJ_TYPE_REF_OBJECT (t));
dump_child ("tok", OBJ_TYPE_REF_TOKEN (t));
break;
default:
/* There are no additional fields to print. */
break;