]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: dump-lang-raw with obj_type_ref fields
authoranetczuk <anetczuk@o2.pl>
Tue, 14 Jan 2025 19:35:44 +0000 (20:35 +0100)
committerJason Merrill <jason@redhat.com>
Tue, 14 Jan 2025 20:24:17 +0000 (15:24 -0500)
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.

gcc/testsuite/g++.dg/diagnostic/lang-dump-1.C [new file with mode: 0644]
gcc/tree-dump.cc

diff --git a/gcc/testsuite/g++.dg/diagnostic/lang-dump-1.C b/gcc/testsuite/g++.dg/diagnostic/lang-dump-1.C
new file mode 100644 (file)
index 0000000..4176894
--- /dev/null
@@ -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 } }
index c234d1ccaf3762628f7e812dfb5befff337007ab..bec36b41ea570cfab5eccf62bcf46978e9daf9b6 100644 (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;