diff options
author | Sandra Loosemore <sandra@codesourcery.com> | 2007-02-15 18:50:49 -0500 |
---|---|---|
committer | Sandra Loosemore <sandra@gcc.gnu.org> | 2007-02-15 18:50:49 -0500 |
commit | 5039610b9630459799b24f64fb9ffdd810b8eee9 (patch) | |
tree | 4c9dae557e2aa52bff7b845dd7b1270c19be7a2f /gcc/cp | |
parent | dc90f45b24a668f465d50a4db2253c7b84cd1c2d (diff) | |
download | gcc-5039610b9630459799b24f64fb9ffdd810b8eee9.zip gcc-5039610b9630459799b24f64fb9ffdd810b8eee9.tar.gz gcc-5039610b9630459799b24f64fb9ffdd810b8eee9.tar.bz2 |
tree.h (enum tree_code_class): Add tcc_vl_exp.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* tree.h (enum tree_code_class): Add tcc_vl_exp.
(VL_EXP_CLASS_P): New.
(TREE_OPERAND_CHECK): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(TREE_OPERAND_CHECK_CODE): Likewise.
(GIMPLE_STMT_OPERAND_CHECK): Likewise.
(TREE_RTL_OPERAND_CHECK): Likewise.
(tree_operand_check_failed): Make second parameter the whole tree
instead of its code. Fixed callers.
(VL_EXP_CHECK): New.
(TREE_OPERAND_LENGTH): New.
(VL_EXP_OPERAND_LENGTH): New.
(CALL_EXPR_FN): New.
(CALL_EXPR_STATIC_CHAIN): New.
(CALL_EXPR_ARGS): New.
(CALL_EXPR_ARG): New.
(call_expr_nargs): New.
(CALL_EXPR_ARGP): New.
(build_nt_call_list): Declare.
(build_vl_exp_stat): Declare.
(build_vl_exp): New.
(build_call_list): Declare.
(build_call_nary): Declare.
(build_call_valist): Declare.
(build_call_array): Declare.
(call_expr_arg): Declare.
(call_expr_argp): Declare.
(call_expr_arglist): Declare.
(fold_build_call_list): Declare.
(fold_build_call_list_initializer): Declare.
(fold_call_expr): Declare to replace fold_builtin.
(fold_builtin_fputs): Update to agree with modified definition.
(fold_builtin_strcpy): Likewise.
(fold_builtin_strncpy): Likewise.
(fold_builtin_memory_chk): Likewise.
(fold_builtin_stxcpy_chk): Likewise.
(fold_builtin_strncpy_chk): Likewise.
(fold_builtin_next_arg): Likewise.
(fold_build_call_expr): Declare.
(fold_builtin_call_list): Declare.
(fold_builtin_call_valist): Declare.
(build_call_expr): Declare.
(validate_arglist): Update to agree with modified definition.
(tree_operand_length): New.
(call_expr_arg_iterator): New.
(init_call_expr_arg_iterator): New.
(next_call_expr_arg): New.
(first_call_expr_arg): New.
(more_call_expr_args_p): New.
(FOR_EACH_CALL_EXPR_ARG): New.
* tree.c (tree_code_class_string): Add entries for tcc_vl_exp
and tcc_gimple_stmt.
(tree_code_size): Update documentation. Use sizeof (tree) rather
than sizeof (char *).
(tree_size): Likewise. Add case for tcc_vl_exp.
(tree_node_structure): Add case for tcc_vl_exp.
(contains_placeholder_p): Likewise.
(substitute_in_expr): Likewise.
(substitute_placeholder_in_expr): Likewise.
(stabilize_reference_1): Likewise.
(build3_stat): Remove logic for CALL_EXPRs. Replace with assertion
to diagnose breakage of this interface for constructing CALL_EXPRs.
(build_nt): Add similar assertion here.
(build_nt_call_list): New.
(simple_cst_equal) <CALL_EXPR>: Rewrite to use new accessors.
(iterative_hash_expr): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(get_callee_fndecl): Use new CALL_EXPR accessors.
(tree_operand_check_failed): Change parameters to pass entire node
instead of its code, so that we can call TREE_OPERAND_LENGTH on it.
(process_call_operands): New.
(build_vl_exp_stat): New.
(build_call_list): New.
(build_call_nary): New.
(build_call_valist): New.
(build_call_array): New.
(walk_tree): Use TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(call_expr_arglist): New.
* tree.def (CALL_EXPR): Change representation of CALL_EXPRs to use
tcc_vl_exp instead of a fixed-size tcc_expression.
* doc/c-tree.texi (CALL_EXPR): Document new representation and
accessors for CALL_EXPRs.
(AGGR_INIT_EXPR): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* builtins.c (c_strlen): Return NULL_TREE instead of 0.
(expand_builtin_nonlocal_goto): Change parameter to be entire
CALL_EXPR instead of an arglist. Use new CALL_EXPR accessors.
(expand_builtin_prefetch): Likewise.
(expand_builtin_classify_type): Likewise.
(mathfn_built_in): Return NULL_TREE instead of 0.
(expand_errno_check): Use new CALL_EXPR accessors.
(expand_builtin_mathfn): Use new CALL_EXPR accessors and constructors.
Return NULL_RTX instead of 0.
(expand_builtin_mathfn_2): Likewise.
(expand_builtin_mathfn_3): Likewise.
(expand_builtin_interclass_mathfn): Likewise.
(expand_builtin_sincos): Likewise.
(expand_builtin_cexpi): Likewise.
(expand_builtin_int_roundingfn): Likewise.
(expand_builtin_int_roundingfn_2): Likewise.
(expand_builtin_pow): Likewise.
(expand_builtin_powi): Likewise.
(expand_builtin_strlen): Pass entire CALL_EXPR as parameter instead
of arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_RTX instead of 0.
(expand_builtin_strstr): Likewise.
(expand_builtin_strchr): Likewise.
(expand_builtin_strrchr): Likewise.
(expand_builtin_strpbrk): Likewise.
(expand_builtin_memcpy): Likewise.
(expand_builtin_mempcpy): Likewise.
(expand_builtin_mempcpy_args): New.
(expand_builtin_memmove): Similarly to expand_builtin_mempcpy.
(expand_builtin_memmove_args): New.
(expand_builtin_bcopy): Similarly to expand_builtin_mempcpy.
(expand_movstr): Likewise.
(expand_builtin_strcpy): Likewise.
(expand_builtin_strcpy_args): New.
(expand_builtin_stpcpy): Similarly to expand_builtin_strcpy.
(expand_builtin_strncpy): Likewise.
(expand_builtin_memset): Likewise.
(expand_builtin_memset_args): New.
(expand_builtin_bzero): Similarly to expand_builtin_memset.
(expand_builtin_memcmp): Likewise.
(expand_builtin_strcmp): Likewise.
(expand_builtin_strncmp): Likewise.
(expand_builtin_strcat): Likewise.
(expand_builtin_strncat): Likewise.
(expand_builtin_strspn): Likewise.
(expand_builtin_strcspn): Likewise.
(expand_builtin_args_info): Likewise.
(expand_builtin_va_start): Likewise.
(gimplify_va_arg_expr): Likewise.
(expand_builtin_va_end): Likewise.
(expand_builtin_va_copy): Likewise.
(expand_builtin_frame_address): Likewise.
(expand_builtin_alloca): Likewise.
(expand_builtin_bswap): Likewise.
(expand_builtin_unop): Likewise.
(expand_builtin_fputs): Likewise.
(expand_builtin_expect): Likewise.
(expand_builtin_fabs): Likewise.
(expand_builtin_copysign): Likewise.
(expand_builtin_printf): Likewise.
(expand_builtin_fprintf): Likewise.
(expand_builtin_sprintf): Likewise.
(expand_builtin_init_trampoline): Likewise.
(expand_builtin_signbit): Likewise.
(expand_builtin_fork_or_exec): Likewise.
(expand_builtin_sync_operation): Likewise.
(expand_builtin_compare_and_swap): Likewise.
(expand_builtin_lock_test_and_set): Likewise.
(expand_builtin_lock_release): Likewise.
(expand_builtin): Likewise.
(builtin_mathfn_code): Likewise.
(fold_builtin_constant_p): Pass call arguments individually instead
of as an arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_TREE instead of 0.
(fold_builtin_expect): Likewise.
(fold_builtin_classify_type): Likewise.
(fold_builtin_strlen): Likewise.
(fold_builtin_nan): Likewise.
(integer_valued_real_p): Likewise.
(fold_trunc_transparent_mathfn): Likewise.
(fold_fixed_mathfn): Likewise.
(fold_builtin_cabs): Likewise.
(fold_builtin_sqrt): Likewise.
(fold_builtin_cbrt): Likewise.
(fold_builtin_cos): Likewise.
(fold_builtin_cosh): Likewise.
(fold_builtin_tan): Likewise.
(fold_builtin_sincos): Likewise.
(fold_builtin_cexp): Likewise.
(fold_builtin_trunc): Likewise.
(fold_builtin_floor): Likewise.
(fold_builtin_ceil): Likewise.
(fold_builtin_round): Likewise.
(fold_builtin_int_roundingfn): Likewise.
(fold_builtin_bitop): Likewise.
(fold_builtin_bswap): Likewise.
(fold_builtin_logarithm): Likewise.
(fold_builtin_hypot): Likewise.
(fold_builtin_pow): Likewise.
(fold_builtin_powi): Likewise.
(fold_builtin_exponent): Likewise.
(fold_builtin_memset): Likewise.
(fold_builtin_bzero): Likewise.
(fold_builtin_memory_op): Likewise.
(fold_builtin_bcopy): Deleted; call site changed to invoke
fold_builtin_memory_op directly.
(fold_builtin_strcpy): Similarly as for fold_builtin_memory_op.
(fold_builtin_strncpy): Likewise.
(fold_builtin_memcmp): Likewise.
(fold_builtin_strcmp): Likewise.
(fold_builtin_strncmp): Likewise.
(fold_builtin_signbit): Likewise.
(fold_builtin_copysign): Likewise.
(fold_builtin_isascii): Likewise.
(fold_builtin_toascii): Likewise.
(fold_builtin_isdigit): Likewise.
(fold_builtin_fabs): Likewise.
(fold_builtin_abs): Likewise.
(fold_builtin_fmin_fmax): Likewise.
(fold_builtin_carg): Likewise.
(fold_builtin_classify): Likewise.
(fold_builtin_unordered_cmp): Likewise.
(fold_builtin_0, fold_builtin_2, fold_builtin_3, fold_builtin_4):
New functions split out from fold_builtin_1.
(fold_builtin_n): New.
(fold_builtin_varargs): New.
(fold_builtin): Deleted. Most callers changed to use fold_call_expr
instead.
(fold_call_expr): New.
(build_function_call_expr): Rewrite to use new helper function.
(fold_builtin_call_list): New.
(build_call_expr): New.
(fold_builtin_call_valist): New.
(rewrite_call_expr): New.
(validate_arg): New.
(validate_arglist): Change parameter to be entire CALL_EXPR instead
of an arglist. Change return type to bool. Use new CALL_EXPR
accessors.
(fold_builtin_strstr): Pass call arguments individually instead
of as an arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_TREE instead of 0.
(fold_builtin_strchr): Likewise.
(fold_builtin_strrchr): Likewise.
(fold_builtin_strpbrk): Likewise.
(fold_builtin_strcat): Likewise.
(fold_builtin_strncat): Likewise.
(fold_builtin_strspn): Likewise.
(fold_builtin_strcspn): Likewise.
(fold_builtin_fputs): Likewise.
(fold_builtin_next_arg): Likewise.
(fold_builtin_sprintf): Likewise.
(expand_builtin_object_size): Use new CALL_EXPR accessors. Use
NULL_RTX instead of 0.
(expand_builtin_memory_chk): Likewise.
(maybe_emit_chk_warning): Likewise.
(maybe_emit_sprintf_chk_warning): Likewise.
(fold_builtin_object_size): Pass call arguments individually instead
of as an arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_TREE instead of 0.
(fold_builtin_memory_chk): Likewise.
(fold_builtin_stxcpy_chk): Likewise.
(fold_builtin_strncpy_chk): Likewise.
(fold_builtin_strcat_chk): Likewise.
(fold_builtin_strcat_chk): Likewise.
(fold_builtin_strncat_chk): Likewise.
(fold_builtin_sprintf_chk): Likewise.
(fold_builtin_snprintf_chk): Likewise.
(fold_builtin_printf): Likewise.
(fold_builtin_vprintf): Likewise.
* fold-const.c (negate_expr_p): Use new CALL_EXPR accessors and
constructors.
(operand_equal_p): Add separate tcc_vl_exp/CALL_EXPR case.
(make_range): Use TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(extract_muldiv_1): Add VL_EXP_CLASS_P case.
(fold_mathfn_compare): Use new CALL_EXPR accessors and constructors.
(fold_unary): Likewise.
(fold_binary): Likewise.
(fold_ternary): Remove CALL_EXPR case, since they are no longer
ternary expressions.
(fold): Add logic for tcc_vl_exp.
(fold_checksum_tree): Make it know about tcc_vl_exp. Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(fold_build3_stat): Add assertion to flag broken interface for
constructing CALL_EXPRs.
(fold_build_call_list): New.
(fold_build_call_list_initializer): New.
(tree_expr_nonnegative_p): Use new CALL_EXPR accessors and
constructors.
(fold_strip_sign_ops): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* tree-dump.c (dequeue_and_dump) <CALL_EXPR>: Use new CALL_EXPR
accessors and dump arguments explicitly.
* tree-pretty-print.c (do_niy): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(dump_generic_node): Use new CALL_EXPR accessors and walk arguments
explicitly.
(print_call_name): Use new CALL_EXPR accessors.
* print-tree.c (print_node): Add case tcc_vl_exp. Print
CALL_EXPR arguments explicitly instead of as a list. Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
* tree-vrp.c (stmt_interesting_for_vrp): Use new CALL_EXPR accessors.
(vrp_visit_stmt): Likewise.
* tree-ssa-loop-im.c (outermost_invariant_loop_expr): Make it
know about tcc_vl_exp. Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(force_move_till_expr): Likewise.
* targhooks.c (default_external_stack_protect_fail): Use
build_call_expr instead of build_function_call_expr.
(default_hidden_stack_protect_fail): Likewise.
* tree-complex.c (expand_complex_libcall): Use build_call_expr to
build the call.
* cgraphbuild.c (build_cgraph_edges): Use new CALL_EXPR accessors
and walk arguments explicitly.
* tree-ssa-loop-niter.c (simplify_replace_tree): Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(expand_simple_operations): Likewise.
(infer_loop_bounds_from_array): Use new CALL_EXPR accessors.
* gengtype.c (adjust_field_tree_exp): Use TREE_OPERAND_LENGTH instead
of TREE_CODE_LENGTH.
(walk_type): Tweak walking of arrays not to blow up on CALL_EXPRs.
* optabs.c (expand_widen_pattern-expr): Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
* value_prof.c (tree_ic): Use new CALL_EXPR accessors.
(tree_ic_transform): Likewise.
(interesting_stringop_to_profile_p): Pass entire CALL_EXPR as
parameter instead of arglist. Fix callers.
(tree_stringop_fixed_value): Use new CALL_EXPR accessors.
(tree_stringops_transform): Likewise.
(tree_indirect_call_to_profile): Likewise.
(tree_stringops_values_to_profile): Likewise.
* tree-tailcall.c (find_tail_calls): Use new CALL_EXPR iterator.
(eliminate_tail_call): Likewise.
* ipa-cp.c (ipcp_update_callgraph): Use new CALL_EXPR accessors.
* tree-scalar-evolution.c (chrec_contains_symbols_defined_in_loop):
Use TREE_OPERAND_LENGTH and generalize to handle any number of
operands.
(instantiate_parameters_1): Can't handle tcc_vl_exp here.
* omp-low.c (build_omp_barrier): Use build_call_expr.
(lower_rec_input_clauses): Likewise.
(lower_reduction_clauses): Likewise.
(expand_parallel_call): Likewise.
(maybe_catch_exception): Likewise.
(expand_omp_for_generic): Likewise.
(expand_omp_for_static_nochunk): Likewise.
(expand_omp_sections): Likewise.
(lower_omp_single_simple): Likewise.
(lower_omp_single_copy): Likewise.
(lower_omp_master): Likewise.
(lower_omp_ordered): Likewise.
(lower_omp_critical): Likewise.
* ipa-reference.c (check-call): Use new CALL_EXPR iterator.
(scan_for_static_refs): Create tcc_vl_exp case for CALL_EXPR.
* tree-gimple.c (is_gimple_call_addr): Fix doc.
(recalculate_side_effects): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH. Add tcc_vl_exp case.
* tree-chrec.c (chrec_contains_symbols): Use TREE_OPERAND_LENGTH
and generalize to handle any number of operands.
(chrec_contains_undetermined): Likewise.
(tree_contains_chrecs): Likewise.
(evolution_function_is_invariant_rec_p): Use TREE_OPERAND_LENGTH.
* cgraphunit.c (update_call_expr): Use new CALL_EXPR accessors.
* tree-ssa-ccp.c (ccp_fold): Use new CALL_EXPR accessors. Use
fold_call_expr instead of fold_builtin.
(ccp_fold_builtin): Likewise. Update calls into builtins.c to
match declarations there.
(fold_stmt): Use new CALL_EXPR constructor and accessors. Doc
updates.
* tree-ssa-loop-ivopts.c (expr_invariant_in_loop_p): Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
* ipa-pure-const.c (check_call): Use new CALL_EXPR accessors.
(scan_function): Add case tcc_vl_exp for CALL_EXPR.
* tree-stdarg.c (execute_optimize_stdarg): Use new CALL_EXPR
accessors.
* tree-ssa-math-opts.c (execute_cse_sincos_1): Use build_call_expr.
(execute_cse_sincos): Use new CALL_EXPR accessors.
* tree-ssa-alias.c (find_used_portions): Use new CALL_EXPR iterator.
* gimple-low.c (lower_function_body): Use build_call_expr.
(lower_builtin_setjmp): Likewise.
* expr.c (emit_block_move_via_libcall): Use build_call_expr.
(set_storage_via_libcall): Likewise.
(safe_from_p): Add tcc_vl_exp case. Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
(expand_expr_real_1): Use new CALL_EXPR accessors.
* tree-browser.c (store_child_info): Use TREE_OPERAND_LENGTH and
generalize to handle any number of operands.
(TB_parent_eq): Likewise.
* predict.c (expr_expected_value): Use new CALL_EXPR accessors.
(strip_builtin_expect): Likewise.
* function.c (gimplify_parameters): Use build_call_expr.
* tree-vectorizer.c (vect_is_simple_reduction): Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
* ipa-type-escape.c (check_call): Use new CALL_EXPR iterators.
(scan_for_refs): Add case tcc_vl_exp for CALL_EXPR.
* tree-data-ref.c (get_references_in_stmt): Use new CALL_EXPR
iterators.
* gimplify.c (build_stack_save_restore): Use build_call_expr.
(gimplify_decl_expr): Likewise.
(gimplify_call_expr): Use fold_call_expr instead of fold_builtin.
Use new CALL_EXPR iterators.
(gimplify_modify_expr_to_memcpy): Use build_call_expr.
(gimplify_modify_expr_to_memset): Likewise.
(gimplify_variable_sized_compare): Likewise.
(gimplify_omp_atomic_fetch_op): Likewise.
(gimplify_omp_atomic_pipeline): Likewise.
(gimplify_omp_atomic_mutex): Likewise.
(gimplify_function_tree): Likewise.
* calls.c (alloca_call_p): Use new CALL_EXPR accessors.
(call_expr_flags): Likewise.
(expand_call): Likewise.
* except.c (expand_builtin_eh_return_data_regno): Pass entire
CALL_EXPR as parameter instead of arglist. Use new CALL_EXPR
accessors.
* coverage.c (create_coverage): Use build_call_expr.
* tree-ssa-pre.c (expression_node_pool, list_node_pool): Delete.
(temp_call_expr_obstack): New.
(pool_copy_list): Delete.
(temp_copy_call_expr): New.
(phi_translate): Add case tcc_vl_exp for CALL_EXPR. Use new
CALL_EXPR accessors. Get rid of special goo for copying argument
lists and use temp_copy_call_expr instead.
(valid_in_sets): Add case tcc_vl_exp for CALL_EXPR. Use new
CALL_EXPR accessors.
(create_expression_by_pieces): Likewise. Use build_call_array
to construct the result instead of fold_build3.
(create_value_expr_from): Add tcc_vl_exp. Delete special goo for
dealing with argument lists.
(init_pre): Remove references to expression_node_pool and
list_node_pool. Init temp_call_expr_obstack instead.
(fini_pre): Remove references to expression_node_pool and
list_node_pool.
* tree-sra.c (sra_walk_call_expr): Use new CALL_EXPR accessors
and walk arguments explicitly instead of as a list.
* tree-mudflap.c (mf_build_check_statement_for): Use build_call_expr.
(mx_register_decls): Likewise.
(mudflap_register_call): Likewise.
(mudflap_finish_file): Likewise.
* ipa-prop.c (ipa_callsite_compute_count): Use new CALL_EXPR accessors.
(ipa_callsite_compute_param): Likewise.
* tree-vect-patterns.c (vect_recog_pow_pattern): Use new CALL_EXPR
accessors and constructor.
* tree-nested.c (convert_nl_goto_reference): Use new CALL_EXPR
accessors and constructor.
(convert_tramp_reference): Likewise.
(convert_call_expr): Likewise.
(finalize_nesting_tree_1): Likewise.
* tree-ssa.c (tree_ssa_useless_type_conversion): Use new CALL_EXPR
accessors.
* tree-ssa-loop-prefetch.c (issue_prefetch_ref): Use build_call_expr.
* tree-inline.c (initialize_inlined_parameters): Pass entire
CALL_EXPR as parameter instead of arglist. Use new CALL_EXPR
accessors.
(estimate_num_insns_1): Use new CALL_EXPR accessors.
(expand_call_inline): Tidy up call to initialize_inlined_parameters.
* tree-vect-transform.c (vect_create_epilog_for_reduction): Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(vectorizable_reduction): Likewise.
(vectorizable_call): Use new CALL_EXPR iterators.
(vectorizable_conversion): Use build_call_expr.
(vectorizable_operation): Use TREE_OPERAND_LENGTH.
(vect_gen_widened_results_half): Use build_call_expr.
(vect_setup_realignment): Likewise.
(vectorizable_live_operation): Use TREE_OPERAND_LENGTH.
* tree-object-size.c (alloc_object_size): Use new CALL_EXPR accessors.
(pass_through_call): Likewise.
(compute_object_sizes): Likewise. Use fold_call_expr instead of
fold_builtin.
* tree-profile.c (tree_gen_interval_profiler): Use build_call_expr.
(tree_gen_pow2_profiler): Likewise.
(tree_gen_one_value_profiler): Likewise.
(tree_gen_ic_func_profiler): Likewise.
(tree_gen_average_profiler): Likewise.
(tree_gen_ior_profiler): Likewise.
* tree-ssa-structalias.c (get_constraint_for): Add case tcc_vl_exp.
(find_func_aliases): Use new CALL_EXPR accessors. Add case
tcc_vl_exp. Use TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
* tree-ssa-reassoc.c (get_rank): Use TREE_OPERAND_LENGTH instead
of TREE_CODE_LENGTH.
* stmt.c (warn_if_unused_value): Use TREE_OPERAND_LENGTH instead
of TREE_CODE_LENGTH.
* convert.c (convert_to_real): Use new CALL_EXPR accessors and
constructor.
(convert_to_integer): Likewise.
* tree-ssa-operands.c (get_call_expr_operands): Use new CALL_EXPR
accessors.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* config/alpha/alpha.c (alpha_expand_builtin): Use new CALL_EXPR
accessors.
* config/frv/frv.c (frv_expand_builtin): Likewise.
* config/s390/s390.c (s390_expand_builtin): Likewise.
* config/sparc/sparc.c (sparc_gimplify_va_arg): Use build_call_expr.
(sparc_expand_builtin): Use new CALL_EXPR accessors.
* config/i386/i386.c (ix86_function_ok_for_sibcall): Likewise.
(ix86_expand_binop_builtin): Pass entire CALL_EXPR as parameter
instead of arglist. Use new CALL_EXPR accessors on it. Fix callers.
(ix86_expand_store_builtin): Likewise.
(ix86_expand_unop_builtin): Likewise.
(ix86_expand_unop1_builtin): Likewise.
(ix86_expand_sse_compare): Likewise.
(ix86_expand_sse_comi): Likewise.
(ix86_expand_vec_init_builtin): Likewise.
(ix86_expand_vec_ext_builtin): Likewise.
(ix86_expand_vec_set_builtin): Likewise.
(ix86_expand_builtin): Use new CALL_EXPR accessors.
* config/sh/sh.c (sh_expand_builtin): Use new CALL_EXPR accessors.
* config/c4x/c4x.c (c4x_expand_builtin): Likewise.
* config/iq2000/iq2000.c (expand_one_builtin): Pass entire CALL_EXPR
instead of arglist. Use new CALL_EXPR accessors. Fix callers.
(iq2000_expand_builtin): Use new CALL_EXPR accessors.
* config/rs6000/rs6000-c.c (altivec_build_resolved_builtin): Use
build_call_expr.
* config/rs6000/rs6000.c (rs6000_gimplify_va_arg): Likewise.
(rs6000_expand_unop_builtin): Pass entire CALL_EXPR instead of
arglist. Use new CALL_EXPR accessors. Fix callers.
(altivec_expand_abs_builtin): Likewise.
(rs6000_expand_binop_builtin): Likewise.
(altivec_expand_predicate_builtin): Likewise.
(altivec_expand_lv_builtin): Likewise.
(spe_expand_stv_builtin): Likewise.
(altivec_expand_stv_builtin): Likewise.
(rs6000_expand_ternop_builtin): Likewise.
(altivec_expand_ld_builtin): Use new CALL_EXPR accessors.
(altivec_expand_st_builtin): Likewise.
(altivec_expand_dst_builtin): Likewise.
(altivec_expand_vec_init_builtin): Pass entire CALL_EXPR instead of
arglist. Use new CALL_EXPR accessors. Fix callers.
(altivec_expand_vec_set_builtin): Likewise.
(altivec_expand_vec_ext_builtin): Likewise.
(altivec_expand_builtin): Use new CALL_EXPR accessors.
(spe_expand_builtin): Likewise.
(spe_expand_predicate_builtin): Pass entire CALL_EXPR instead of
arglist. Use new CALL_EXPR accessors. Fix callers.
(spe_expand_evsel_builtin): Likewise.
(rs6000_expand_builtin): Use new CALL_EXPR accessors. VCFUX and
FCFSX cases must construct whole new CALL_EXPR, not just arglist.
* config/arm/arm.c (arm_expand_binop_builtin): Pass entire CALL_EXPR
instead of arglist. Use new CALL_EXPR accessors. Fix callers.
(arm_expand_unop_builtin): Likewise.
(arm_expand_builtin): Use new CALL_EXPR accessors.
* config/mips/mips.c (mips_expand_builtin): Use new CALL_EXPR
accessors.
* config/bfin/bfin.c (bfin_expand_binop_builtin): Pass entire CALL_EXPR
instead of arglist. Use new CALL_EXPR accessors. Fix callers.
(bfin_expand_unop_builtin): Likewise.
(bfin_expand_builtin): Use new CALL_EXPR accessors.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* c-semantics.c (build_stmt): Add internal diagnostic check.
* c-pretty-print.c (pp_c_postfix_expression): Use new CALL_EXPR
accessors. Print arguments explicitly instead of as a list.
* c-typeck.c (build_function_call): Use new CALL_EXPR constructors.
* c-omp.c (c_finish_omp_barrier): Use build_call_expr.
(c_finish_omp_flish): Likewise.
* c-common.c (verify_tree): Use new CALL_EXPR accessors. Traverse
arguments explicitly instead of as a list. Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
(check_function_arguments_recurse): Use new CALL_EXPR accessors.
(c_warn_unused_result): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* cp-tree.def (AGGR_INIT_EXPR): Adjust documentation.
Change class to tcc_vl_exp.
* call.c (build_call): Use build_call_list instead
of build3.
(build_over_call): Likewise.
(build_new_method_call): Use build_min_non_dep_call_list
instead of build_min_non_dep.
* error.c (dump_call_expr_args): New function.
(dump_aggr_init_expr_args): New function.
(dump_expr) <AGGR_INIT_EXPR, CALL_EXPR, INDIRECT_REF>: Use them.
Update to use new CALL_EXPR and AGGR_INIT_EXPR accessor macros.
* cvt.c (convert_to_void): Use build_call_array instead
of build3; use new AGGR_INIT_EXPR accessor macros.
* mangle.c (write_expression): Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
* dump.c (cp_dump_tree) <AGGR_INIT_EXPR>: Update to use new
AGGR_INIT_EXPR accessor macros.
* cp-gimplify.c (cp_gimplify_init_expr): Use
AGGR_INIT_EXPR_SLOT to set the slot operand.
* cp-tree.h (AGGR_INIT_EXPR_FN): New macro.
(AGGR_INIT_EXPR_SLOT): New macro.
(AGGR_INIT_EXPR_ARG): New macro.
(aggr_init_expr_nargs): New macro.
(AGGR_INIT_EXPR_ARGP): New macro.
(aggr_init_expr_arg_iterator): New.
(init_aggr_init_expr_arg_iterator): New.
(next_aggr_init_expr_arg): New.
(first_aggr_init_expr_arg): New.
(more_aggr_init_expr_args_p): New.
(FOR_EACH_AGGR_INIT_EXPR_ARG): New.
(stabilize_aggr_init): New declaration.
(build_min_non_dep_call_list): Likewise.
* tree.c (process_aggr_init_operands): New function.
(build_aggr_init_array) New function.
(build_cplus_new): Update to use new CALL_EXPR and
AGGR_INIT_EXPR accessor macros. Replace use of build3 with
build_aggr_init_array.
(build_min_non_dep_call_list) New function.
(build_min_nt): Assert input code parameter is not a variable
length expression class.
(build_min, build_min_non_dep): Likewise.
(cp_tree_equal) <CALL_EXPR>: Iterate through the arguments
to check for equality instead of recursing. Handle tcc_vl_exp
tree code classes.
(stabilize_call): Update to only handle CALL_EXPRs, not
AGGR_INIT_EXPRs; use new CALL_EXPR accessor macros.
(stabilize_aggr_init): New function.
(stabilize_init): Use it.
* cxx-pretty-print.c (pp_cxx_postfix_expression)
<AGGR_INIT_EXPR, CALL_EXPR>: Update to use new CALL_EXPR and
AGGR_INIT_EXPR accessor macros and argument iterators.
* pt.c (tsubst_copy) <CALL_EXPR>: Replace build_nt with
build_vl_exp. Iterate through the operands, recursively
processing each one.
(tsubst_copy_and_build) <CALL_EXPR>: Update to use new
CALL_EXPR accessor macros.
(value_dependent_expression_p) <default>: Handle tcc_vl_exp
tree code classes. Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
* semantics.c (finish_call_expr): Use build_nt_call_list
instead of build_nt.
(simplify_aggr_init_expr): Update to use new AGGR_INIT_EXPR
accessor macros. Use build_call_array to construct the
CALL_EXPR node instead of build3
* decl2.c (build_offset_ref_call_from_tree): Use
build_nt_call_list and build_min_non_dep_call_list instead
of build_min_nt and build_min_non_dep.
* parser.c (cp_parser_postfix_expression) <CPP_OPEN_PAREN>:
Use build_nt_call_list instead of build_min_nt.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* java-tree.h (BUILD_MONITOR_ENTER): Use build_call_nary instead
of build3.
(BUILD_MONITOR_EXIT): Likewise.
* java-gimplify.c (java_gimplify_component_ref): Use build_call_expr.
(java_gimplify_modify_expr): Likewise.
* class.c (cache_this_class_ref): Use build_call_expr.
(build_static_field_ref): Likewise.
(emit_indirect_register_classes): Likewise.
(emit_register_classes): Likewise.
* resource.c (write_resource_constructor): Use build_call_expr.
* builtins.c (builtin_creator_function): Change interpretation of
the second parameter to be the whole CALL_EXPR instead of the arglist.
(max_builtin): Tweak parameter list. Use new CALL_EXPR accessors.
(min_builtin): Likewise.
(abs_builtin): Likewise.
(java_build_function_call_expr): Likewise.
(convert_real): Likewise.
(UNMARSHAL3): Likewise.
(UNMARSHAL4): Likewise.
(UNMARSHAL5): Likewise.
(build_arglist_for_builtin): Delete. Fix callers to use
build_call_expr instead.
(putObject_builtin): Tweak parameter list. Use new CALL_EXPR
accessors.
(compareAndSwapInt_builtin): Likewise.
(compareAndSwapLong_builtin): Likewise.
(compareAndSwapObject_builtin): Likewise.
(putVolatile_builtin): Likewise.
(getVolatile_builtin): Likewise.
(VMSupportsCS8_builtin): Likewise.
(check_for_builtin): Pass entire CALL_EXPR to builtin expander
instead of arglist.
* expr.c (build_java_athrow): Use build_call_nary instead of build3.
(build_java_throw_out_of_bounds_exception): Likewise.
(java_check_reference): Likewise.
(build_java_arraystore_check): Likewise.
(build_newarray): Likewise.
(build_anewarray): Likewise.
(expand_java_multinewarray): Use build_call_list instead of build3.
(build_java_monitor): Use build_call_nary instead of build3.
(java_create_object): Likewise.
(expand_java_NEW): Likewise.
(build_instanceof): Likewise.
(expand_java_CHECKCAST): Likewise.
(build_java_soft_divmod): Likewise.
(build_java_binop): Likewise.
(build_field_ref): Likewise.
(build_class_init): Likewise.
(rewrite_arglist_getcaller): Use build_call_expr.
(build_invokeinterface): Use build_call_nary instead of build3.
(expand_invoke): Use build_call_list instead of build3.
(build_jni_stub): Use build_call_nary, build_call_list, or
build_call_expr instead of build3.
(expand_java_field_op): Use build_call_expr instead of build3.
(force_evaluation_order): Use new CALL_EXPR accessors.
* lang.c (java_get_callee_fndecl): Use new CALL_EXPR accessors.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* objc-act.c (receiver_is_class_object): Use new CALL_EXPR accessors.
(objc_get_callee_fndecl): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* trans-expr.c (gfc_conv_power_op): Use build_call_expr.
(gfc_conv_string_tmp): Likewise.
(gfc_conv_concat_op): Likewise.
(gfc_build_compare_string): Likewise.
(gfc_conv_function_call): Use build_call_list instead of build3.
* trans-array.c (gfc_trans_allocate_array_storage): Use
build_call_expr.
(gfc_grow_array): Likewise.
(gfc_trans_array_ctor_element): Likewise.
(gfc_trans_array_constructor_value): Likewise.
(gfc_array_allocate): Likewise.
(gfc_array_deallocate): Likewise.
(gfc_trans_auto_array_allocation): Likewise.
(gfc_trans_dummy_array_bias): Likewise.
(gfc_conv_array_parameter): Likewise.
(gfc_trans_dealloc_allocated): Likewise.
(gfc_duplicate_allocatable): Likewise.
* trans-openmp.c (gfc_trans_omp_barrier): Use build_call_expr.
(gfc_trans_omp_flush): Likewise.
* trans-stmt.c (gfc_conv_elementel_dependencies): Use build_call_expr.
(gfc_trans_pause): Likewise.
(gfc_trans_stop): Likewise.
(gfc_trans_character_select): Likewise.
(gfc_do_allocate): Likewise.
(gfc_trans_assign_need_temp): Likewise.
(gfc_trans_pointer_assign_need_temp): Likewise.
(gfc_trans_forall_1): Likewise.
(gfc_trans_where_2): Likewise.
(gfc_trans_allocate): Likewise.
(gfc_trans_deallocate): Likewise.
* trans.c (gfc_trans_runtime_check): Use build_call_expr.
* trans-io.c (gfc_trans_open): Use build_call_expr.
(gfc_trans_close): Likewise.
(build_filepos): Likewise.
(gfc_trans_inquire): Likewise.
(NML_FIRST_ARG): Delete.
(NML_ADD_ARG): Delete.
(transfer_namelist_element): Use build_call_expr.
(build_dt): Likewise.
(gfc_trans_dt_end): Likewise.
(transfer_expr): Likewise.
(transfer_array-desc): Likewise.
* trans-decl.c (gfc_generate_function_code): Use build_call_expr.
(gfc_generate_constructors): Likewise.
* trans-intrinsic.c (gfc_conv_intrinsic_ctime): Use build_call_expr.
(gfc_conv_intrinsic_fdate): Likewise.
(gfc_conv_intrinsic_ttynam): Likewise.
(gfc_conv_intrinsic_array_transfer): Likewise.
(gfc_conv_associated): Likewise.
(gfc_conv_intrinsic_si_kind): Likewise.
(gfc_conv_intrinsic_trim): Likewise.
(gfc_conv_intrinsic_repeat: Likewise.
(gfc_conv_intrinsic_iargc): Likewise.
Co-Authored-By: Brooks Moses <brooks.moses@codesourcery.com>
Co-Authored-By: Lee Millward <lee.millward@codesourcery.com>
From-SVN: r122018
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 87 | ||||
-rw-r--r-- | gcc/cp/call.c | 12 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.def | 10 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 81 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 8 | ||||
-rw-r--r-- | gcc/cp/cxx-pretty-print.c | 51 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 4 | ||||
-rw-r--r-- | gcc/cp/dump.c | 19 | ||||
-rw-r--r-- | gcc/cp/error.c | 80 | ||||
-rw-r--r-- | gcc/cp/mangle.c | 2 | ||||
-rw-r--r-- | gcc/cp/parser.c | 3 | ||||
-rw-r--r-- | gcc/cp/pt.c | 23 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 31 | ||||
-rw-r--r-- | gcc/cp/tree.c | 172 |
15 files changed, 486 insertions, 99 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fd068e4..16df0f7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,90 @@ +2007-02-15 Sandra Loosemore <sandra@codesourcery.com> + Brooks Moses <brooks.moses@codesourcery.com> + Lee Millward <lee.millward@codesourcery.com> + + * cp-tree.def (AGGR_INIT_EXPR): Adjust documentation. + Change class to tcc_vl_exp. + + * call.c (build_call): Use build_call_list instead + of build3. + (build_over_call): Likewise. + (build_new_method_call): Use build_min_non_dep_call_list + instead of build_min_non_dep. + + * error.c (dump_call_expr_args): New function. + (dump_aggr_init_expr_args): New function. + (dump_expr) <AGGR_INIT_EXPR, CALL_EXPR, INDIRECT_REF>: Use them. + Update to use new CALL_EXPR and AGGR_INIT_EXPR accessor macros. + + * cvt.c (convert_to_void): Use build_call_array instead + of build3; use new AGGR_INIT_EXPR accessor macros. + + * mangle.c (write_expression): Use TREE_OPERAND_LENGTH + instead of TREE_CODE_LENGTH. + + * dump.c (cp_dump_tree) <AGGR_INIT_EXPR>: Update to use new + AGGR_INIT_EXPR accessor macros. + + * cp-gimplify.c (cp_gimplify_init_expr): Use + AGGR_INIT_EXPR_SLOT to set the slot operand. + + * cp-tree.h (AGGR_INIT_EXPR_FN): New macro. + (AGGR_INIT_EXPR_SLOT): New macro. + (AGGR_INIT_EXPR_ARG): New macro. + (aggr_init_expr_nargs): New macro. + (AGGR_INIT_EXPR_ARGP): New macro. + (aggr_init_expr_arg_iterator): New. + (init_aggr_init_expr_arg_iterator): New. + (next_aggr_init_expr_arg): New. + (first_aggr_init_expr_arg): New. + (more_aggr_init_expr_args_p): New. + (FOR_EACH_AGGR_INIT_EXPR_ARG): New. + (stabilize_aggr_init): New declaration. + (build_min_non_dep_call_list): Likewise. + + * tree.c (process_aggr_init_operands): New function. + (build_aggr_init_array) New function. + (build_cplus_new): Update to use new CALL_EXPR and + AGGR_INIT_EXPR accessor macros. Replace use of build3 with + build_aggr_init_array. + (build_min_non_dep_call_list) New function. + (build_min_nt): Assert input code parameter is not a variable + length expression class. + (build_min, build_min_non_dep): Likewise. + (cp_tree_equal) <CALL_EXPR>: Iterate through the arguments + to check for equality instead of recursing. Handle tcc_vl_exp + tree code classes. + (stabilize_call): Update to only handle CALL_EXPRs, not + AGGR_INIT_EXPRs; use new CALL_EXPR accessor macros. + (stabilize_aggr_init): New function. + (stabilize_init): Use it. + + * cxx-pretty-print.c (pp_cxx_postfix_expression) + <AGGR_INIT_EXPR, CALL_EXPR>: Update to use new CALL_EXPR and + AGGR_INIT_EXPR accessor macros and argument iterators. + + * pt.c (tsubst_copy) <CALL_EXPR>: Replace build_nt with + build_vl_exp. Iterate through the operands, recursively + processing each one. + (tsubst_copy_and_build) <CALL_EXPR>: Update to use new + CALL_EXPR accessor macros. + (value_dependent_expression_p) <default>: Handle tcc_vl_exp + tree code classes. Use TREE_OPERAND_LENGTH instead of + TREE_CODE_LENGTH. + + * semantics.c (finish_call_expr): Use build_nt_call_list + instead of build_nt. + (simplify_aggr_init_expr): Update to use new AGGR_INIT_EXPR + accessor macros. Use build_call_array to construct the + CALL_EXPR node instead of build3 + + * decl2.c (build_offset_ref_call_from_tree): Use + build_nt_call_list and build_min_non_dep_call_list instead + of build_min_nt and build_min_non_dep. + + * parser.c (cp_parser_postfix_expression) <CPP_OPEN_PAREN>: + Use build_nt_call_list instead of build_min_nt. + 2007-02-15 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR c++/28943 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 6690fa2..b1b5a8e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -336,7 +336,7 @@ build_call (tree function, tree parms) TREE_VALUE (tmp), t); } - function = build3 (CALL_EXPR, result_type, function, parms, NULL_TREE); + function = build_call_list (result_type, function, parms); TREE_HAS_CONSTRUCTOR (function) = is_constructor; TREE_NOTHROW (function) = nothrow; @@ -4740,7 +4740,7 @@ build_over_call (struct z_candidate *cand, int flags) tree expr; tree return_type; return_type = TREE_TYPE (TREE_TYPE (fn)); - expr = build3 (CALL_EXPR, return_type, fn, args, NULL_TREE); + expr = build_call_list (return_type, fn, args); if (TREE_THIS_VOLATILE (fn) && cfun) current_function_returns_abnormally = 1; if (!VOID_TYPE_P (return_type)) @@ -5122,7 +5122,7 @@ build_java_interface_fn_ref (tree fn, tree instance) lookup_fn = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (java_iface_lookup_fn)), java_iface_lookup_fn); - return build3 (CALL_EXPR, ptr_type_node, lookup_fn, lookup_args, NULL_TREE); + return build_call_list (ptr_type_node, lookup_fn, lookup_args); } /* Returns the value to use for the in-charge parameter when making a @@ -5533,10 +5533,10 @@ build_new_method_call (tree instance, tree fns, tree args, } if (processing_template_decl && call != error_mark_node) - call = (build_min_non_dep - (CALL_EXPR, call, + call = (build_min_non_dep_call_list + (call, build_min_nt (COMPONENT_REF, orig_instance, orig_fns, NULL_TREE), - orig_args, NULL_TREE)); + orig_args)); /* Free all the conversions we allocated. */ obstack_free (&conversion_obstack, p); diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 6a427c6..aa1b0ed 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -410,7 +410,7 @@ cp_gimplify_init_expr (tree *expr_p, tree *pre_p, tree *post_p) if (TREE_CODE (sub) == AGGR_INIT_EXPR) { gimplify_expr (&to, pre_p, post_p, is_gimple_lvalue, fb_lvalue); - TREE_OPERAND (sub, 2) = to; + AGGR_INIT_EXPR_SLOT (sub) = to; *expr_p = from; /* The initialization is now a side-effect, so the container can diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 090f91f..bcc6b54 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -74,10 +74,12 @@ DEFTREECODE (MEMBER_REF, "member_ref", tcc_reference, 2) operator converts to. Operand is expression to be converted. */ DEFTREECODE (TYPE_EXPR, "type_expr", tcc_expression, 1) -/* For AGGR_INIT_EXPR, operand 0 is function which performs initialization, - operand 1 is argument list to initialization function, - and operand 2 is the slot which was allocated for this expression. */ -DEFTREECODE (AGGR_INIT_EXPR, "aggr_init_expr", tcc_expression, 3) +/* AGGR_INIT_EXPRs have a variably-sized representation similar to + that of CALL_EXPRs. Operand 0 is an INTEGER_CST node containing the + operand count, operand 1 is the function which performs initialization, + operand 2 is the slot which was allocated for this expression, and + the remaining operands are the arguments to the initialization function. */ +DEFTREECODE (AGGR_INIT_EXPR, "aggr_init_expr", tcc_vl_exp, 3) /* A throw expression. operand 0 is the expression, if there was one, else it is NULL_TREE. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 4de73ff..b385781 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2331,6 +2331,85 @@ extern void decl_shadowed_for_var_insert (tree, tree); #define AGGR_INIT_VIA_CTOR_P(NODE) \ TREE_LANG_FLAG_0 (AGGR_INIT_EXPR_CHECK (NODE)) +/* AGGR_INIT_EXPR accessors. These are equivalent to the CALL_EXPR + accessors, except for AGGR_INIT_EXPR_SLOT (which takes the place of + CALL_EXPR_STATIC_CHAIN). */ + +#define AGGR_INIT_EXPR_FN(NODE) TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 1) +#define AGGR_INIT_EXPR_SLOT(NODE) \ + TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 2) +#define AGGR_INIT_EXPR_ARG(NODE, I) \ + TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), (I) + 3) +#define aggr_init_expr_nargs(NODE) (VL_EXP_OPERAND_LENGTH(NODE) - 3) + +/* AGGR_INIT_EXPR_ARGP returns a pointer to the argument vector for NODE. + We can't use &AGGR_INIT_EXPR_ARG (NODE, 0) because that will complain if + the argument count is zero when checking is enabled. Instead, do + the pointer arithmetic to advance past the 3 fixed operands in a + AGGR_INIT_EXPR. That produces a valid pointer to just past the end of + the operand array, even if it's not valid to dereference it. */ +#define AGGR_INIT_EXPR_ARGP(NODE) \ + (&(TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 0)) + 3) + +/* Abstract iterators for AGGR_INIT_EXPRs. */ + +/* Structure containing iterator state. */ +typedef struct aggr_init_expr_arg_iterator_d GTY (()) +{ + tree t; /* the aggr_init_expr */ + int n; /* argument count */ + int i; /* next argument index */ +} aggr_init_expr_arg_iterator; + +/* Initialize the abstract argument list iterator object ITER with the + arguments from AGGR_INIT_EXPR node EXP. */ +static inline void +init_aggr_init_expr_arg_iterator (tree exp, + aggr_init_expr_arg_iterator *iter) +{ + iter->t = exp; + iter->n = aggr_init_expr_nargs (exp); + iter->i = 0; +} + +/* Return the next argument from abstract argument list iterator object ITER, + and advance its state. Return NULL_TREE if there are no more arguments. */ +static inline tree +next_aggr_init_expr_arg (aggr_init_expr_arg_iterator *iter) +{ + tree result; + if (iter->i >= iter->n) + return NULL_TREE; + result = AGGR_INIT_EXPR_ARG (iter->t, iter->i); + iter->i++; + return result; +} + +/* Initialize the abstract argument list iterator object ITER, then advance + past and return the first argument. Useful in for expressions, e.g. + for (arg = first_aggr_init_expr_arg (exp, &iter); arg; + arg = next_aggr_init_expr_arg (&iter)) */ +static inline tree +first_aggr_init_expr_arg (tree exp, aggr_init_expr_arg_iterator *iter) +{ + init_aggr_init_expr_arg_iterator (exp, iter); + return next_aggr_init_expr_arg (iter); +} + +/* Test whether there are more arguments in abstract argument list iterator + ITER, without changing its state. */ +static inline bool +more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) +{ + return (iter->i < iter->n); +} + +/* Iterate through each argument ARG of AGGR_INIT_EXPR CALL, using variable + ITER (of type aggr_init_expr_arg_iterator) to hold the iteration state. */ +#define FOR_EACH_AGGR_INIT_EXPR_ARG(arg, iter, call) \ + for ((arg) = first_aggr_init_expr_arg ((call), &(iter)); (arg); \ + (arg) = next_aggr_init_expr_arg (&(iter))) + /* The TYPE_MAIN_DECL for a class template type is a TYPE_DECL, not a TEMPLATE_DECL. This macro determines whether or not a given class type is really a template type, as opposed to an instantiation or @@ -4375,6 +4454,7 @@ extern void lang_check_failed (const char *, int, const char *) ATTRIBUTE_NORETURN; extern tree stabilize_expr (tree, tree *); extern void stabilize_call (tree, tree *); +extern void stabilize_aggr_init (tree, tree *); extern bool stabilize_init (tree, tree *); extern tree add_stmt_to_compound (tree, tree); extern tree cxx_maybe_build_cleanup (tree); @@ -4390,6 +4470,7 @@ extern bool builtin_valid_in_constant_expr_p (tree); extern tree build_min (enum tree_code, tree, ...); extern tree build_min_nt (enum tree_code, ...); extern tree build_min_non_dep (enum tree_code, tree, ...); +extern tree build_min_non_dep_call_list (tree, tree, tree); extern tree build_cplus_new (tree, tree); extern tree get_target_expr (tree); extern tree build_cplus_array_type (tree, tree); diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 220eddd..497179b 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -902,9 +902,11 @@ convert_to_void (tree expr, const char *implicit) if (TREE_CODE (init) == AGGR_INIT_EXPR && !AGGR_INIT_VIA_CTOR_P (init)) { - tree fn = TREE_OPERAND (init, 0); - expr = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), - fn, TREE_OPERAND (init, 1), NULL_TREE); + tree fn = AGGR_INIT_EXPR_FN (init); + expr = build_call_array (TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), + fn, + aggr_init_expr_nargs (init), + AGGR_INIT_EXPR_ARGP (init)); } } break; diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 4f2bf86..5c13362 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -412,9 +412,11 @@ pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t) case AGGR_INIT_EXPR: case CALL_EXPR: { - tree fun = TREE_OPERAND (t, 0); - tree args = TREE_OPERAND (t, 1); + tree fun = (code == AGGR_INIT_EXPR ? AGGR_INIT_EXPR_FN (t) + : CALL_EXPR_FN (t)); tree saved_scope = pp->enclosing_scope; + bool skipfirst = false; + tree arg; if (TREE_CODE (fun) == ADDR_EXPR) fun = TREE_OPERAND (fun, 0); @@ -427,9 +429,11 @@ pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t) ; else if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fun)) { - tree object = code == AGGR_INIT_EXPR && AGGR_INIT_VIA_CTOR_P (t) - ? TREE_OPERAND (t, 2) - : TREE_VALUE (args); + tree object = (code == AGGR_INIT_EXPR + ? (AGGR_INIT_VIA_CTOR_P (t) + ? AGGR_INIT_EXPR_SLOT (t) + : AGGR_INIT_EXPR_ARG (t, 0)) + : CALL_EXPR_ARG (t, 0)); while (TREE_CODE (object) == NOP_EXPR) object = TREE_OPERAND (object, 0); @@ -447,18 +451,49 @@ pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t) pp_cxx_postfix_expression (pp, object); pp_cxx_arrow (pp); } - args = TREE_CHAIN (args); + skipfirst = true; pp->enclosing_scope = strip_pointer_operator (TREE_TYPE (object)); } pp_cxx_postfix_expression (pp, fun); pp->enclosing_scope = saved_scope; - pp_cxx_call_argument_list (pp, args); + pp_cxx_left_paren (pp); + if (code == AGGR_INIT_EXPR) + { + aggr_init_expr_arg_iterator iter; + FOR_EACH_AGGR_INIT_EXPR_ARG (arg, iter, t) + { + if (skipfirst) + skipfirst = false; + else + { + pp_cxx_expression (pp, arg); + if (more_aggr_init_expr_args_p (&iter)) + pp_cxx_separate_with (pp, ','); + } + } + } + else + { + call_expr_arg_iterator iter; + FOR_EACH_CALL_EXPR_ARG (arg, iter, t) + { + if (skipfirst) + skipfirst = false; + else + { + pp_cxx_expression (pp, arg); + if (more_call_expr_args_p (&iter)) + pp_cxx_separate_with (pp, ','); + } + } + } + pp_cxx_right_paren (pp); } if (code == AGGR_INIT_EXPR && AGGR_INIT_VIA_CTOR_P (t)) { pp_cxx_separate_with (pp, ','); - pp_cxx_postfix_expression (pp, TREE_OPERAND (t, 2)); + pp_cxx_postfix_expression (pp, AGGR_INIT_EXPR_SLOT (t)); } break; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 4e4f6a5..68917b6 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3401,7 +3401,7 @@ build_offset_ref_call_from_tree (tree fn, tree args) || TREE_CODE (fn) == MEMBER_REF); if (type_dependent_expression_p (fn) || any_type_dependent_arguments_p (args)) - return build_min_nt (CALL_EXPR, fn, args, NULL_TREE); + return build_nt_call_list (fn, args); /* Transform the arguments and add the implicit "this" parameter. That must be done before the FN is transformed @@ -3431,7 +3431,7 @@ build_offset_ref_call_from_tree (tree fn, tree args) expr = build_function_call (fn, args); if (processing_template_decl && expr != error_mark_node) - return build_min_non_dep (CALL_EXPR, expr, orig_fn, orig_args, NULL_TREE); + return build_min_non_dep_call_list (expr, orig_fn, orig_args); return expr; } diff --git a/gcc/cp/dump.c b/gcc/cp/dump.c index c63cfe2..de569f2 100644 --- a/gcc/cp/dump.c +++ b/gcc/cp/dump.c @@ -388,10 +388,21 @@ cp_dump_tree (void* dump_info, tree t) break; case AGGR_INIT_EXPR: - dump_int (di, "ctor", AGGR_INIT_VIA_CTOR_P (t)); - dump_child ("fn", TREE_OPERAND (t, 0)); - dump_child ("args", TREE_OPERAND (t, 1)); - dump_child ("decl", TREE_OPERAND (t, 2)); + { + int i = 0; + tree arg; + aggr_init_expr_arg_iterator iter; + dump_int (di, "ctor", AGGR_INIT_VIA_CTOR_P (t)); + dump_child ("fn", AGGR_INIT_EXPR_FN (t)); + FOR_EACH_AGGR_INIT_EXPR_ARG (arg, iter, t) + { + char buffer[32]; + sprintf (buffer, "%u", i); + dump_child (buffer, arg); + i++; + } + dump_child ("decl", AGGR_INIT_EXPR_SLOT (t)); + } break; case HANDLER: diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 00f0767..6a0eed5 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -66,6 +66,8 @@ static void dump_aggr_type (tree, int); static void dump_type_prefix (tree, int); static void dump_type_suffix (tree, int); static void dump_function_name (tree, int); +static void dump_call_expr_args (tree, int, bool); +static void dump_aggr_init_expr_args (tree, int, bool); static void dump_expr_list (tree, int); static void dump_global_iord (tree); static void dump_parameters (tree, int); @@ -1265,6 +1267,55 @@ dump_template_parms (tree info, int primary, int flags) pp_cxx_end_template_argument_list (cxx_pp); } +/* Print out the arguments of CALL_EXPR T as a parenthesized list using + flags FLAGS. Skip over the first argument if SKIPFIRST is true. */ + +static void +dump_call_expr_args (tree t, int flags, bool skipfirst) +{ + tree arg; + call_expr_arg_iterator iter; + + pp_cxx_left_paren (cxx_pp); + FOR_EACH_CALL_EXPR_ARG (arg, iter, t) + { + if (skipfirst) + skipfirst = false; + else + { + dump_expr (arg, flags | TFF_EXPR_IN_PARENS); + if (more_call_expr_args_p (&iter)) + pp_separate_with_comma (cxx_pp); + } + } + pp_cxx_right_paren (cxx_pp); +} + +/* Print out the arguments of AGGR_INIT_EXPR T as a parenthesized list + using flags FLAGS. Skip over the first argument if SKIPFIRST is + true. */ + +static void +dump_aggr_init_expr_args (tree t, int flags, bool skipfirst) +{ + tree arg; + aggr_init_expr_arg_iterator iter; + + pp_cxx_left_paren (cxx_pp); + FOR_EACH_AGGR_INIT_EXPR_ARG (arg, iter, t) + { + if (skipfirst) + skipfirst = false; + else + { + dump_expr (arg, flags | TFF_EXPR_IN_PARENS); + if (more_aggr_init_expr_args_p (&iter)) + pp_separate_with_comma (cxx_pp); + } + } + pp_cxx_right_paren (cxx_pp); +} + /* Print out a list of initializers (subr of dump_expr). */ static void @@ -1387,8 +1438,8 @@ dump_expr (tree t, int flags) { tree fn = NULL_TREE; - if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR) - fn = TREE_OPERAND (TREE_OPERAND (t, 0), 0); + if (TREE_CODE (AGGR_INIT_EXPR_FN (t)) == ADDR_EXPR) + fn = TREE_OPERAND (AGGR_INIT_EXPR_FN (t), 0); if (fn && TREE_CODE (fn) == FUNCTION_DECL) { @@ -1398,18 +1449,15 @@ dump_expr (tree t, int flags) dump_decl (fn, 0); } else - dump_expr (TREE_OPERAND (t, 0), 0); + dump_expr (AGGR_INIT_EXPR_FN (t), 0); } - pp_cxx_left_paren (cxx_pp); - if (TREE_OPERAND (t, 1)) - dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags); - pp_cxx_right_paren (cxx_pp); + dump_aggr_init_expr_args (t, flags, false); break; case CALL_EXPR: { - tree fn = TREE_OPERAND (t, 0); - tree args = TREE_OPERAND (t, 1); + tree fn = CALL_EXPR_FN (t); + bool skipfirst = false; if (TREE_CODE (fn) == ADDR_EXPR) fn = TREE_OPERAND (fn, 0); @@ -1420,7 +1468,7 @@ dump_expr (tree t, int flags) if (TREE_TYPE (fn) != NULL_TREE && NEXT_CODE (fn) == METHOD_TYPE) { - tree ob = TREE_VALUE (args); + tree ob = CALL_EXPR_ARG (t, 0); if (TREE_CODE (ob) == ADDR_EXPR) { dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS); @@ -1432,12 +1480,10 @@ dump_expr (tree t, int flags) dump_expr (ob, flags | TFF_EXPR_IN_PARENS); pp_arrow (cxx_pp); } - args = TREE_CHAIN (args); + skipfirst = true; } dump_expr (fn, flags | TFF_EXPR_IN_PARENS); - pp_cxx_left_paren (cxx_pp); - dump_expr_list (args, flags); - pp_cxx_right_paren (cxx_pp); + dump_call_expr_args (t, flags, skipfirst); } break; @@ -1581,10 +1627,8 @@ dump_expr (tree t, int flags) { t = TREE_OPERAND (t, 0); gcc_assert (TREE_CODE (t) == CALL_EXPR); - dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); - pp_cxx_left_paren (cxx_pp); - dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags); - pp_cxx_right_paren (cxx_pp); + dump_expr (CALL_EXPR_FN (t), flags | TFF_EXPR_IN_PARENS); + dump_call_expr_args (t, flags, true); } else { diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 5b8d338..94d7ed5 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -2206,7 +2206,7 @@ write_expression (tree expr) break; default: - for (i = 0; i < TREE_CODE_LENGTH (code); ++i) + for (i = 0; i < TREE_OPERAND_LENGTH (expr); ++i) { tree operand = TREE_OPERAND (expr, i); /* As a GNU extension, the middle operand of a diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 328add2..b8af4d2 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -4443,8 +4443,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p) || any_type_dependent_arguments_p (args))) { postfix_expression - = build_min_nt (CALL_EXPR, postfix_expression, - args, NULL_TREE); + = build_nt_call_list (postfix_expression, args); break; } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ee8db6d..31ad46c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8350,12 +8350,15 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) NULL_TREE, NULL_TREE); case CALL_EXPR: - return build_nt (code, - tsubst_copy (TREE_OPERAND (t, 0), args, - complain, in_decl), - tsubst_copy (TREE_OPERAND (t, 1), args, complain, - in_decl), - NULL_TREE); + { + int n = VL_EXP_OPERAND_LENGTH (t); + tree result = build_vl_exp (CALL_EXPR, n); + int i; + for (i = 0; i < n; i++) + TREE_OPERAND (t, i) = tsubst_copy (TREE_OPERAND (t, i), args, + complain, in_decl); + return result; + } case COND_EXPR: case MODOP_EXPR: @@ -9271,7 +9274,7 @@ tsubst_copy_and_build (tree t, bool qualified_p; bool koenig_p; - function = TREE_OPERAND (t, 0); + function = CALL_EXPR_FN (t); /* When we parsed the expression, we determined whether or not Koenig lookup should be performed. */ koenig_p = KOENIG_LOOKUP_P (t); @@ -9304,7 +9307,8 @@ tsubst_copy_and_build (tree t, qualified_p = true; } - call_args = RECUR (TREE_OPERAND (t, 1)); + /* FIXME: Rewrite this so as not to construct an arglist. */ + call_args = RECUR (CALL_EXPR_ARGS (t)); /* We do not perform argument-dependent lookup if normal lookup finds a non-function, in accordance with the @@ -13064,9 +13068,10 @@ value_dependent_expression_p (tree expression) (TREE_OPERAND (expression, 1)))); case tcc_expression: + case tcc_vl_exp: { int i; - for (i = 0; i < TREE_CODE_LENGTH (TREE_CODE (expression)); ++i) + for (i = 0; i < TREE_OPERAND_LENGTH (expression); ++i) /* In some cases, some of the operands may be missing. (For example, in the case of PREDECREMENT_EXPR, the amount to increment by may be missing.) That doesn't diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 326bcfb..3df045e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1789,7 +1789,7 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p) if (type_dependent_expression_p (fn) || any_type_dependent_arguments_p (args)) { - result = build_nt (CALL_EXPR, fn, args, NULL_TREE); + result = build_nt_call_list (fn, args); KOENIG_LOOKUP_P (result) = koenig_p; return result; } @@ -1846,7 +1846,7 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p) if (processing_template_decl) { if (type_dependent_expression_p (object)) - return build_nt (CALL_EXPR, orig_fn, orig_args, NULL_TREE); + return build_nt_call_list (orig_fn, orig_args); object = build_non_dependent_expr (object); } @@ -1890,8 +1890,7 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p) if (processing_template_decl) { - result = build3 (CALL_EXPR, TREE_TYPE (result), orig_fn, - orig_args, NULL_TREE); + result = build_call_list (TREE_TYPE (result), orig_fn, orig_args); KOENIG_LOOKUP_P (result) = koenig_p; } return result; @@ -2975,9 +2974,8 @@ simplify_aggr_init_expr (tree *tp) tree aggr_init_expr = *tp; /* Form an appropriate CALL_EXPR. */ - tree fn = TREE_OPERAND (aggr_init_expr, 0); - tree args = TREE_OPERAND (aggr_init_expr, 1); - tree slot = TREE_OPERAND (aggr_init_expr, 2); + tree fn = AGGR_INIT_EXPR_FN (aggr_init_expr); + tree slot = AGGR_INIT_EXPR_SLOT (aggr_init_expr); tree type = TREE_TYPE (slot); tree call_expr; @@ -2995,23 +2993,20 @@ simplify_aggr_init_expr (tree *tp) style = arg; } + call_expr = build_call_array (TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), + fn, + aggr_init_expr_nargs (aggr_init_expr), + AGGR_INIT_EXPR_ARGP (aggr_init_expr)); + if (style == ctor) { /* Replace the first argument to the ctor with the address of the slot. */ - tree addr; - - args = TREE_CHAIN (args); cxx_mark_addressable (slot); - addr = build1 (ADDR_EXPR, build_pointer_type (type), slot); - args = tree_cons (NULL_TREE, addr, args); + CALL_EXPR_ARG (call_expr, 0) = + build1 (ADDR_EXPR, build_pointer_type (type), slot); } - - call_expr = build3 (CALL_EXPR, - TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), - fn, args, NULL_TREE); - - if (style == arg) + else if (style == arg) { /* Just mark it addressable here, and leave the rest to expand_call{,_inline}. */ diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index a3d11a3..7c5a4dc 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -261,8 +261,55 @@ build_local_temp (tree type) return slot; } -/* INIT is a CALL_EXPR which needs info about its target. - TYPE is the type that this initialization should appear to have. +/* Set various status flags when building an AGGR_INIT_EXPR object T. */ + +static void +process_aggr_init_operands (tree t) +{ + bool side_effects; + + side_effects = TREE_SIDE_EFFECTS (t); + if (!side_effects) + { + int i, n; + n = TREE_OPERAND_LENGTH (t); + for (i = 1; i < n; i++) + { + tree op = TREE_OPERAND (t, i); + if (op && TREE_SIDE_EFFECTS (op)) + { + side_effects = 1; + break; + } + } + } + TREE_SIDE_EFFECTS (t) = side_effects; +} + +/* Build an AGGR_INIT_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE, + FN, and SLOT. NARGS is the number of call arguments which are specified + as a tree array ARGS. */ + +static tree +build_aggr_init_array (tree return_type, tree fn, tree slot, int nargs, + tree *args) +{ + tree t; + int i; + + t = build_vl_exp (AGGR_INIT_EXPR, nargs + 3); + TREE_TYPE (t) = return_type; + AGGR_INIT_EXPR_FN (t) = fn; + AGGR_INIT_EXPR_SLOT (t) = slot; + for (i = 0; i < nargs; i++) + AGGR_INIT_EXPR_ARG (t, i) = args[i]; + process_aggr_init_operands (t); + return t; +} + +/* INIT is a CALL_EXPR or AGGR_INIT_EXPR which needs info about its + target. TYPE is the type that this initialization should appear to + have. Build an encapsulation of the initialization to perform and return it so that it can be processed by language-independent @@ -280,10 +327,13 @@ build_cplus_new (tree type, tree init) abstract class. */ abstract_virtuals_error (NULL_TREE, type); - if (TREE_CODE (init) != CALL_EXPR && TREE_CODE (init) != AGGR_INIT_EXPR) + if (TREE_CODE (init) == CALL_EXPR) + fn = CALL_EXPR_FN (init); + else if (TREE_CODE (init) == AGGR_INIT_EXPR) + fn = AGGR_INIT_EXPR_FN (init); + else return convert (type, init); - fn = TREE_OPERAND (init, 0); is_ctor = (TREE_CODE (fn) == ADDR_EXPR && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL && DECL_CONSTRUCTOR_P (TREE_OPERAND (fn, 0))); @@ -303,8 +353,14 @@ build_cplus_new (tree type, tree init) type, don't mess with AGGR_INIT_EXPR. */ if (is_ctor || TREE_ADDRESSABLE (type)) { - rval = build3 (AGGR_INIT_EXPR, void_type_node, fn, - TREE_OPERAND (init, 1), slot); + if (TREE_CODE(init) == CALL_EXPR) + rval = build_aggr_init_array (void_type_node, fn, slot, + call_expr_nargs (init), + CALL_EXPR_ARGP (init)); + else + rval = build_aggr_init_array (void_type_node, fn, slot, + aggr_init_expr_nargs (init), + AGGR_INIT_EXPR_ARGP (init)); TREE_SIDE_EFFECTS (rval) = 1; AGGR_INIT_VIA_CTOR_P (rval) = is_ctor; } @@ -1420,6 +1476,8 @@ build_min_nt (enum tree_code code, ...) int i; va_list p; + gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp); + va_start (p, code); t = make_node (code); @@ -1435,6 +1493,7 @@ build_min_nt (enum tree_code code, ...) return t; } + /* Similar to `build', but for template definitions. */ tree @@ -1445,6 +1504,8 @@ build_min (enum tree_code code, tree tt, ...) int i; va_list p; + gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp); + va_start (p, tt); t = make_node (code); @@ -1475,6 +1536,8 @@ build_min_non_dep (enum tree_code code, tree non_dep, ...) int i; va_list p; + gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp); + va_start (p, non_dep); t = make_node (code); @@ -1497,6 +1560,19 @@ build_min_non_dep (enum tree_code code, tree non_dep, ...) return t; } +/* Similar to `build_call_list', but for template definitions of non-dependent + expressions. NON_DEP is the non-dependent expression that has been + built. */ + +tree +build_min_non_dep_call_list (tree non_dep, tree fn, tree arglist) +{ + tree t = build_nt_call_list (fn, arglist); + TREE_TYPE (t) = TREE_TYPE (non_dep); + TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (non_dep); + return t; +} + tree get_type_decl (tree t) { @@ -1615,9 +1691,20 @@ cp_tree_equal (tree t1, tree t2) return cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)); case CALL_EXPR: - if (!cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0))) - return false; - return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)); + { + tree arg1, arg2; + call_expr_arg_iterator iter1, iter2; + if (!cp_tree_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2))) + return false; + for (arg1 = first_call_expr_arg (t1, &iter1), + arg2 = first_call_expr_arg (t2, &iter2); + arg1 && arg2; + arg1 = next_call_expr_arg (&iter1), + arg2 = next_call_expr_arg (&iter2)) + if (!cp_tree_equal (arg1, arg2)) + return false; + return (arg1 || arg2); + } case TARGET_EXPR: { @@ -1747,12 +1834,18 @@ cp_tree_equal (tree t1, tree t2) case tcc_binary: case tcc_comparison: case tcc_expression: + case tcc_vl_exp: case tcc_reference: case tcc_statement: { - int i; + int i, n; + + n = TREE_OPERAND_LENGTH (t1); + if (TREE_CODE_CLASS (code1) == tcc_vl_exp + && n != TREE_OPERAND_LENGTH (t2)) + return false; - for (i = 0; i < TREE_CODE_LENGTH (code1); ++i) + for (i = 0; i < n; ++i) if (!cp_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i))) return false; @@ -2438,21 +2531,49 @@ void stabilize_call (tree call, tree *initp) { tree inits = NULL_TREE; - tree t; + int i; + int nargs = call_expr_nargs (call); if (call == error_mark_node) return; - gcc_assert (TREE_CODE (call) == CALL_EXPR - || TREE_CODE (call) == AGGR_INIT_EXPR); + gcc_assert (TREE_CODE (call) == CALL_EXPR); - for (t = TREE_OPERAND (call, 1); t; t = TREE_CHAIN (t)) - if (TREE_SIDE_EFFECTS (TREE_VALUE (t))) - { - tree init; - TREE_VALUE (t) = stabilize_expr (TREE_VALUE (t), &init); - inits = add_stmt_to_compound (inits, init); - } + for (i = 0; i < nargs; i++) + { + tree init; + CALL_EXPR_ARG (call, i) = + stabilize_expr (CALL_EXPR_ARG (call, i), &init); + inits = add_stmt_to_compound (inits, init); + } + + *initp = inits; +} + +/* Like stabilize_expr, but for an AGGR_INIT_EXPR whose arguments we want + to pre-evaluate. CALL is modified in place to use the pre-evaluated + arguments, while, upon return, *INITP contains an expression to + compute the arguments. */ + +void +stabilize_aggr_init (tree call, tree *initp) +{ + tree inits = NULL_TREE; + int i; + int nargs = aggr_init_expr_nargs (call); + + if (call == error_mark_node) + return; + + gcc_assert (TREE_CODE (call) == AGGR_INIT_EXPR); + + for (i = 0; i < nargs; i++) + { + tree init; + AGGR_INIT_EXPR_ARG (call, i) = + stabilize_expr (AGGR_INIT_EXPR_ARG (call, i), &init); + inits = add_stmt_to_compound (inits, init); + } *initp = inits; } @@ -2499,13 +2620,18 @@ stabilize_init (tree init, tree *initp) if (TREE_CODE (t) == COND_EXPR) return false; - if (TREE_CODE (t) == CALL_EXPR - || TREE_CODE (t) == AGGR_INIT_EXPR) + if (TREE_CODE (t) == CALL_EXPR) { stabilize_call (t, initp); return true; } + if (TREE_CODE (t) == AGGR_INIT_EXPR) + { + stabilize_aggr_init (t, initp); + return true; + } + /* The initialization is being performed via a bitwise copy -- and the item copied may have side effects. */ return TREE_SIDE_EFFECTS (init); |