summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@integrable-solutions.net>2005-11-22 17:04:12 +0000
committerGabriel Dos Reis <gdr@gcc.gnu.org>2005-11-22 17:04:12 +0000
commit7f58e7acc1e35e69a4dbb9c6e8318601c163f7b9 (patch)
tree347b5018102e7e2dc755f0e38d4bf0555a1c401f /gcc
parentd5e07b79f448ea911bda0acb00c57795eb96e7fc (diff)
downloadgcc-7f58e7acc1e35e69a4dbb9c6e8318601c163f7b9.tar.gz
re PR c++/22238 (Awful error messages with virtual functions)
PR c++/22238 * error.c (resolve_virtual_fun_from_obj_type_ref): New. (dump_expr): Use it in <case CALL_EXPR>. From-SVN: r107366
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/error.c21
2 files changed, 27 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 87e4598263b..17094dd3f69 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2005-11-21 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ PR c++/22238
+ * error.c (resolve_virtual_fun_from_obj_type_ref): New.
+ (dump_expr): Use it in <case CALL_EXPR>.
+
2005-11-21 Richard Henderson <rth@redhat.com>
* cp-objcp-common.h, name-lookup.c, name-lookup.h: Revert 11-18 patch.
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 674e407055f..be0ee5968ee 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -1278,6 +1278,23 @@ dump_expr_init_vec (VEC(constructor_elt,gc) *v, int flags)
}
+/* We've gotten an indirect REFERENCE (an OBJ_TYPE_REF) to a virtual
+ function. Resolve it to a close relative -- in the sense of static
+ type -- variant being overridden. That is close to what was written in
+ the source code. Subroutine of dump_expr. */
+
+static tree
+resolve_virtual_fun_from_obj_type_ref (tree ref)
+{
+ tree obj_type = TREE_TYPE (OBJ_TYPE_REF_OBJECT (ref));
+ int index = tree_low_cst (OBJ_TYPE_REF_TOKEN (ref), 1);
+ tree fun = BINFO_VIRTUALS (TYPE_BINFO (TREE_TYPE (obj_type)));
+ while (index--)
+ fun = TREE_CHAIN (fun);
+
+ return BV_FN (fun);
+}
+
/* Print out an expression E under control of FLAGS. */
static void
@@ -1386,6 +1403,10 @@ dump_expr (tree t, int flags)
if (TREE_CODE (fn) == ADDR_EXPR)
fn = TREE_OPERAND (fn, 0);
+ /* Nobody is interested in seeing the guts of vcalls. */
+ if (TREE_CODE (fn) == OBJ_TYPE_REF)
+ fn = resolve_virtual_fun_from_obj_type_ref (fn);
+
if (TREE_TYPE (fn) != NULL_TREE && NEXT_CODE (fn) == METHOD_TYPE)
{
tree ob = TREE_VALUE (args);