From patchwork Wed Sep 15 07:58:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [C++] Fix ia64 bootstrap (PR c++/45635) Date: Tue, 14 Sep 2010 21:58:14 -0000 From: Jakub Jelinek X-Patchwork-Id: 64793 Message-Id: <20100915075814.GI1269@tyan-ft48-01.lab.bos.redhat.com> To: Jason Merrill Cc: gcc-patches@gcc.gnu.org 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 PR c++/45635 * class.c (build_vtbl_initializer): Use fn instead of init's operand as first argument to FDESC_EXPR. Jakub --- 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);