diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 18 | ||||
-rw-r--r-- | gcc/cp/call.c | 3 | ||||
-rw-r--r-- | gcc/cp/class.c | 21 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 8 | ||||
-rw-r--r-- | gcc/cp/except.c | 6 | ||||
-rw-r--r-- | gcc/cp/init.c | 40 | ||||
-rw-r--r-- | gcc/cp/rtti.c | 7 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 11 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 4 |
9 files changed, 56 insertions, 62 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 58e1ba7d948..f80f7b6916a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,21 @@ +2011-07-19 Richard Guenther <rguenther@suse.de> + + * call.c (build_special_member_call): Use fold_build_pointer_plus. + * class.c (build_base_path): Likewise. + (convert_to_base_statically): Likewise. + (dfs_accumulate_vtbl_inits): Likewise. + * cp-gimplify.c (cxx_omp_clause_apply_fn): Likewise. + * except.c (expand_start_catch_block): Likewise. + * init.c (expand_virtual_init): Likewise. + (build_new_1): Likewise. + (build_vec_delete_1): Likewise. + (build_vec_delete): Likewise. + * rtti.c (build_headof): Likewise. + (tinfo_base_init): Likewise. + * typeck.c (get_member_function_from_ptrfunc): Likewise. + (cp_build_addr_expr_1): Likewise. + * typeck2.c (build_m_component_ref): Likewise. + 2011-07-18 Martin Jambor <mjambor@suse.cz> * parser.c (cp_parser_parameter_declaration_list): Initialize diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 99f9cc3d25a..2eab78266f8 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7062,8 +7062,7 @@ build_special_member_call (tree instance, tree name, VEC(tree,gc) **args, current_vtt_parm, vtt); gcc_assert (BINFO_SUBVTT_INDEX (binfo)); - sub_vtt = build2 (POINTER_PLUS_EXPR, TREE_TYPE (vtt), vtt, - BINFO_SUBVTT_INDEX (binfo)); + sub_vtt = fold_build_pointer_plus (vtt, BINFO_SUBVTT_INDEX (binfo)); if (args == NULL) { diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 61c1380d7b2..26b7abe903d 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -374,8 +374,7 @@ build_base_path (enum tree_code code, tf_warning_or_error), TREE_TYPE (TREE_TYPE (expr))); - v_offset = build2 (POINTER_PLUS_EXPR, TREE_TYPE (v_offset), - v_offset, fold_convert (sizetype, BINFO_VPTR_FIELD (v_binfo))); + v_offset = fold_build_pointer_plus (v_offset, BINFO_VPTR_FIELD (v_binfo)); v_offset = build1 (NOP_EXPR, build_pointer_type (ptrdiff_type_node), v_offset); @@ -413,7 +412,7 @@ build_base_path (enum tree_code code, offset = fold_convert (sizetype, offset); if (code == MINUS_EXPR) offset = fold_build1_loc (input_location, NEGATE_EXPR, sizetype, offset); - expr = build2 (POINTER_PLUS_EXPR, ptr_target_type, expr, offset); + expr = fold_build_pointer_plus (expr, offset); } else null_test = NULL; @@ -540,10 +539,6 @@ convert_to_base_statically (tree expr, tree base) expr_type = TREE_TYPE (expr); if (!SAME_BINFO_TYPE_P (BINFO_TYPE (base), expr_type)) { - tree pointer_type; - - pointer_type = build_pointer_type (expr_type); - /* We use fold_build2 and fold_convert below to simplify the trees provided to the optimizers. It is not safe to call these functions when processing a template because they do not handle C++-specific @@ -551,9 +546,8 @@ convert_to_base_statically (tree expr, tree base) gcc_assert (!processing_template_decl); expr = cp_build_addr_expr (expr, tf_warning_or_error); if (!integer_zerop (BINFO_OFFSET (base))) - expr = fold_build2_loc (input_location, - POINTER_PLUS_EXPR, pointer_type, expr, - fold_convert (sizetype, BINFO_OFFSET (base))); + expr = fold_build_pointer_plus_loc (input_location, + expr, BINFO_OFFSET (base)); expr = fold_convert (build_pointer_type (BINFO_TYPE (base)), expr); expr = build_fold_indirect_ref_loc (input_location, expr); } @@ -7833,13 +7827,10 @@ dfs_accumulate_vtbl_inits (tree binfo, /* Figure out the position to which the VPTR should point. */ vtbl = build1 (ADDR_EXPR, vtbl_ptr_type_node, orig_vtbl); - index = size_binop (PLUS_EXPR, - size_int (non_fn_entries), - size_int (n_inits)); index = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (vtable_entry_type), - index); - vtbl = build2 (POINTER_PLUS_EXPR, TREE_TYPE (vtbl), vtbl, index); + size_int (non_fn_entries + n_inits)); + vtbl = fold_build_pointer_plus (vtbl, index); } if (ctor_vtbl_p) diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index d26c0e0ca51..2b4e70a75ef 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1230,7 +1230,7 @@ cxx_omp_clause_apply_fn (tree fn, tree arg1, tree arg2) start2 = build_fold_addr_expr_loc (input_location, start2); end1 = TYPE_SIZE_UNIT (TREE_TYPE (arg1)); - end1 = build2 (POINTER_PLUS_EXPR, TREE_TYPE (start1), start1, end1); + end1 = fold_build_pointer_plus (start1, end1); p1 = create_tmp_var (TREE_TYPE (start1), NULL); t = build2 (MODIFY_EXPR, TREE_TYPE (p1), p1, start1); @@ -1260,15 +1260,13 @@ cxx_omp_clause_apply_fn (tree fn, tree arg1, tree arg2) t = fold_build_cleanup_point_expr (TREE_TYPE (t), t); append_to_statement_list (t, &ret); - t = TYPE_SIZE_UNIT (inner_type); - t = build2 (POINTER_PLUS_EXPR, TREE_TYPE (p1), p1, t); + t = fold_build_pointer_plus (p1, TYPE_SIZE_UNIT (inner_type)); t = build2 (MODIFY_EXPR, TREE_TYPE (p1), p1, t); append_to_statement_list (t, &ret); if (arg2) { - t = TYPE_SIZE_UNIT (inner_type); - t = build2 (POINTER_PLUS_EXPR, TREE_TYPE (p2), p2, t); + t = fold_build_pointer_plus (p2, TYPE_SIZE_UNIT (inner_type)); t = build2 (MODIFY_EXPR, TREE_TYPE (p2), p2, t); append_to_statement_list (t, &ret); } diff --git a/gcc/cp/except.c b/gcc/cp/except.c index c37815d242d..129d2f43441 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -452,10 +452,10 @@ expand_start_catch_block (tree decl) generic exception header. */ exp = build_exc_ptr (); exp = build1 (NOP_EXPR, build_pointer_type (type), exp); - exp = build2 (POINTER_PLUS_EXPR, TREE_TYPE (exp), exp, + exp = fold_build_pointer_plus (exp, fold_build1_loc (input_location, - NEGATE_EXPR, sizetype, - TYPE_SIZE_UNIT (TREE_TYPE (exp)))); + NEGATE_EXPR, sizetype, + TYPE_SIZE_UNIT (TREE_TYPE (exp)))); exp = cp_build_indirect_ref (exp, RO_NULL, tf_warning_or_error); initialize_handler_parm (decl, exp); return type; diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 7970b9ac476..52b948441f2 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1063,10 +1063,7 @@ expand_virtual_init (tree binfo, tree decl) /* Compute the value to use, when there's a VTT. */ vtt_parm = current_vtt_parm; - vtbl2 = build2 (POINTER_PLUS_EXPR, - TREE_TYPE (vtt_parm), - vtt_parm, - vtt_index); + vtbl2 = fold_build_pointer_plus (vtt_parm, vtt_index); vtbl2 = cp_build_indirect_ref (vtbl2, RO_NULL, tf_warning_or_error); vtbl2 = convert (TREE_TYPE (vtbl), vtbl2); @@ -2310,16 +2307,14 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, tree size_ptr_type; /* Adjust so we're pointing to the start of the object. */ - data_addr = build2 (POINTER_PLUS_EXPR, TREE_TYPE (alloc_node), - alloc_node, cookie_size); + data_addr = fold_build_pointer_plus (alloc_node, cookie_size); /* Store the number of bytes allocated so that we can know how many elements to destroy later. We use the last sizeof (size_t) bytes to store the number of elements. */ cookie_ptr = size_binop (MINUS_EXPR, cookie_size, size_in_bytes (sizetype)); - cookie_ptr = fold_build2_loc (input_location, - POINTER_PLUS_EXPR, TREE_TYPE (alloc_node), - alloc_node, cookie_ptr); + cookie_ptr = fold_build_pointer_plus_loc (input_location, + alloc_node, cookie_ptr); size_ptr_type = build_pointer_type (sizetype); cookie_ptr = fold_convert (size_ptr_type, cookie_ptr); cookie = cp_build_indirect_ref (cookie_ptr, RO_NULL, complain); @@ -2329,10 +2324,10 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, if (targetm.cxx.cookie_has_size ()) { /* Also store the element size. */ - cookie_ptr = build2 (POINTER_PLUS_EXPR, size_ptr_type, cookie_ptr, + cookie_ptr = fold_build_pointer_plus (cookie_ptr, fold_build1_loc (input_location, - NEGATE_EXPR, sizetype, - size_in_bytes (sizetype))); + NEGATE_EXPR, sizetype, + size_in_bytes (sizetype))); cookie = cp_build_indirect_ref (cookie_ptr, RO_NULL, complain); cookie = build2 (MODIFY_EXPR, sizetype, cookie, @@ -2801,12 +2796,13 @@ build_vec_delete_1 (tree base, tree maxindex, tree type, convert (sizetype, maxindex)); tbase = create_temporary_var (ptype); - tbase_init = cp_build_modify_expr (tbase, NOP_EXPR, - fold_build2_loc (input_location, - POINTER_PLUS_EXPR, ptype, - fold_convert (ptype, base), - virtual_size), - complain); + tbase_init + = cp_build_modify_expr (tbase, NOP_EXPR, + fold_build_pointer_plus_loc (input_location, + fold_convert (ptype, + base), + virtual_size), + complain); if (tbase_init == error_mark_node) return error_mark_node; controller = build3 (BIND_EXPR, void_type_node, tbase, @@ -2817,7 +2813,7 @@ build_vec_delete_1 (tree base, tree maxindex, tree type, build2 (EQ_EXPR, boolean_type_node, tbase, fold_convert (ptype, base))); tmp = fold_build1_loc (input_location, NEGATE_EXPR, sizetype, size_exp); - tmp = build2 (POINTER_PLUS_EXPR, ptype, tbase, tmp); + tmp = fold_build_pointer_plus (tbase, tmp); tmp = cp_build_modify_expr (tbase, NOP_EXPR, tmp, complain); if (tmp == error_mark_node) return error_mark_node; @@ -3751,10 +3747,8 @@ build_vec_delete (tree base, tree maxindex, type = strip_array_types (TREE_TYPE (type)); cookie_addr = fold_build1_loc (input_location, NEGATE_EXPR, sizetype, TYPE_SIZE_UNIT (sizetype)); - cookie_addr = build2 (POINTER_PLUS_EXPR, - size_ptr_type, - fold_convert (size_ptr_type, base), - cookie_addr); + cookie_addr = fold_build_pointer_plus (fold_convert (size_ptr_type, base), + cookie_addr); maxindex = cp_build_indirect_ref (cookie_addr, RO_NULL, complain); } else if (TREE_CODE (type) == ARRAY_TYPE) diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 53404b4a62d..434b7725ba8 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -192,8 +192,7 @@ build_headof (tree exp) type = cp_build_qualified_type (ptr_type_node, cp_type_quals (TREE_TYPE (exp))); - return build2 (POINTER_PLUS_EXPR, type, exp, - convert_to_integer (sizetype, offset)); + return fold_build_pointer_plus (exp, offset); } /* Get a bad_cast node for the program to throw... @@ -918,8 +917,8 @@ tinfo_base_init (tinfo_s *ti, tree target) vtable_ptr = cp_build_addr_expr (vtable_ptr, tf_warning_or_error); /* We need to point into the middle of the vtable. */ - vtable_ptr = build2 - (POINTER_PLUS_EXPR, TREE_TYPE (vtable_ptr), vtable_ptr, + vtable_ptr = fold_build_pointer_plus + (vtable_ptr, size_binop (MULT_EXPR, size_int (2 * TARGET_VTABLE_DATA_ENTRY_DISTANCE), TYPE_SIZE_UNIT (vtable_entry_type))); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d87c107ab76..52084e6ae40 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3078,8 +3078,7 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function) return error_mark_node; } /* ...and then the delta in the PMF. */ - instance_ptr = build2 (POINTER_PLUS_EXPR, TREE_TYPE (instance_ptr), - instance_ptr, fold_convert (sizetype, delta)); + instance_ptr = fold_build_pointer_plus (instance_ptr, delta); /* Hand back the adjusted 'this' argument to our caller. */ *instance_ptrptr = instance_ptr; @@ -3094,9 +3093,7 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function) TREE_NO_WARNING (vtbl) = 1; /* Finally, extract the function pointer from the vtable. */ - e2 = fold_build2_loc (input_location, - POINTER_PLUS_EXPR, TREE_TYPE (vtbl), vtbl, - fold_convert (sizetype, idx)); + e2 = fold_build_pointer_plus_loc (input_location, vtbl, idx); e2 = cp_build_indirect_ref (e2, RO_NULL, tf_warning_or_error); TREE_CONSTANT (e2) = 1; @@ -4841,8 +4838,8 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain) { tree type = build_pointer_type (argtype); tree op0 = fold_convert (type, TREE_OPERAND (val, 0)); - tree op1 = fold_convert (sizetype, fold_offsetof (arg, val)); - return fold_build2 (POINTER_PLUS_EXPR, type, op0, op1); + tree op1 = fold_offsetof (arg, val); + return fold_build_pointer_plus (op0, op1); } /* Handle complex lvalues (when permitted) diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index ac4f383ce80..bdd2452ffe1 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1560,9 +1560,7 @@ build_m_component_ref (tree datum, tree component) /* Build an expression for "object + offset" where offset is the value stored in the pointer-to-data-member. */ ptype = build_pointer_type (type); - datum = build2 (POINTER_PLUS_EXPR, ptype, - fold_convert (ptype, datum), - build_nop (sizetype, component)); + datum = fold_build_pointer_plus (fold_convert (ptype, datum), component); datum = cp_build_indirect_ref (datum, RO_NULL, tf_warning_or_error); /* If the object expression was an rvalue, return an rvalue. */ if (!is_lval) |