Patchwork [C++] Fix ia64 bootstrap (PR c++/45635)

login
register
mail settings
Submitter Jakub Jelinek
Date Sept. 15, 2010, 7:58 a.m.
Message ID <20100915075814.GI1269@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/64793/
State New
Headers show

Comments

Jakub Jelinek - Sept. 15, 2010, 7:58 a.m.
Hi!

Honza's recent change to properly convert vtbl fn pointers
broke TARGET_VTABLE_USES_DESCRIPTORS, because init is no longer
always an ADDR_EXPR as the code building FDESC_EXPR expects.  It wants
to extract the FUNCTION_DECL from it, so it is IMHO much easier just
to use fn instead which contains the correct FUNCTION_DECL already.

And, the first two hunks in the patch (not strictly necessary) just
avoid creating the useless NOP_EXPR/ADDR_EXPR trees on
TARGET_VTABLE_USES_DESCRIPTORS targets altogether.

Tested by H.J. on ia64-linux, ok for trunk?

2010-09-15  Jakub Jelinek  <jakub@redhat.com>

	PR c++/45635
	* class.c (build_vtbl_initializer): Use fn instead of init's operand
	as first argument to FDESC_EXPR.


	Jakub
Jason Merrill - Sept. 15, 2010, 1:55 p.m.
OK.

Jason

Patch

--- gcc/cp/class.c.jj	2010-09-14 15:24:34.000000000 +0200
+++ gcc/cp/class.c	2010-09-14 16:41:50.000000000 +0200
@@ -7796,9 +7796,14 @@  build_vtbl_initializer (tree binfo,
 	  if (DECL_PURE_VIRTUAL_P (fn_original))
 	    {
 	      fn = abort_fndecl;
-	      if (abort_fndecl_addr == NULL)
-		abort_fndecl_addr = fold_convert (vfunc_ptr_type_node, build_fold_addr_expr (fn));
-	      init = abort_fndecl_addr;
+	      if (!TARGET_VTABLE_USES_DESCRIPTORS)
+		{
+		  if (abort_fndecl_addr == NULL)
+		    abort_fndecl_addr
+		      = fold_convert (vfunc_ptr_type_node,
+				      build_fold_addr_expr (fn));
+		  init = abort_fndecl_addr;
+		}
 	    }
 	  else
 	    {
@@ -7810,7 +7815,9 @@  build_vtbl_initializer (tree binfo,
 		}
 	      /* Take the address of the function, considering it to be of an
 		 appropriate generic type.  */
-	      init = fold_convert (vfunc_ptr_type_node, build_fold_addr_expr (fn));
+	      if (!TARGET_VTABLE_USES_DESCRIPTORS)
+		init = fold_convert (vfunc_ptr_type_node,
+				     build_fold_addr_expr (fn));
 	    }
 	}
 
@@ -7825,8 +7832,7 @@  build_vtbl_initializer (tree binfo,
 	    for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i)
 	      {
 		tree fdesc = build2 (FDESC_EXPR, vfunc_ptr_type_node,
-				     TREE_OPERAND (init, 0),
-				     build_int_cst (NULL_TREE, i));
+				     fn, build_int_cst (NULL_TREE, i));
 		TREE_CONSTANT (fdesc) = 1;
 
 		CONSTRUCTOR_APPEND_ELT (*inits, NULL_TREE, fdesc);