This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for PR 22239


Hi, 

this is a partial fix for c++/22239.  It is partial in the sense that
the core issue is not gone, but at least it put us back in
non-regression state.
Committed to mainline.  Will commit to 4.1.x and 4.0.x later.

-- Gaby

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>.

*** error.c  (revision 107345)
--- error.c  (local)
*************** dump_expr_init_vec (VEC(constructor_elt,
*** 1278,1283 ****
--- 1278,1300 ----
  }
  
  
+ /* 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
*************** dump_expr (tree t, int flags)
*** 1386,1391 ****
--- 1403,1412 ----
  	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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]