aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2009-06-12 22:06:47 +0000
committerAldy Hernandez <aldyh@redhat.com>2009-06-12 22:06:47 +0000
commita0e5a6139d05c3a0bcd1e7506764377dd3915566 (patch)
tree67f495ddc3964a90084152e177995da72e7bce30
parenta4e77de6c21b2ec9daf1b1c113838ed63b56396f (diff)
gcc/java/
* java-gimplify.c (java_gimplify_block): New argument to build_empty_stmt. * expr.c (force_evaluation_order): Same. * typeck.c: Add location to build_decl or PUSH_FIELD calls. * class.c: Same. * decl.c: Same. * jcf-parse.c: Same. * constants.c: Same. * resource.c: Same. * except.c: Same. * builtins.c: Same. * expr.c: Same. * java-tree.h (PUSH_FIELD): Add location field. gcc/objc/ * objc-act.c (finish_var_decl): Pass location to finish_decl. (objc_get_parm_info): Same. (get_super_receiver): Same. * objc-act.c (objc_build_component_ref): Pass location to build_compound_ref. (build_module_initializer_routine): Pass location to c_end_compound_stmt. (objc_generate_static_init_call): Pass location to build_stmt. (build_typed_selector_reference): New location argument. (build_selector_reference): Same. (objc_substitute_decl): Pass location to build_array_ref. (next_sjlj_build_try_catch_finally): Pass location to build_stmt. (objc_begin_catch_clause): Same. (objc_finish_try_stmt): Same. (objc_finish_catch_clause): Pass location to c_end_compound_stmt. (objc_build_throw_stmt): New argument. (generate_shared_structures): Pass location to build_c_cast. (objc_build_message_expr): Use local location. (objc_finish_message_expr): Use input_location. (build_objc_method_call): New argument. (objc_build_selector_expr): Same. (get_super_receiver): Pass location to build_c_cast, build_modify_expr, build_compound_expr. * objc-act.c: Add location to all calls to start_struct, build_decl, finish_struct. gcc/ * tree-pretty-print.c (dump_generic_node): Dump column numbers. * gimple-pretty-print.c (dump_gimple_stmt): Same. * gimplify.c (gimplify_modify_expr): Set location for GIMPLE_ASSIGNs created. * c-parser.c (c_parser_binary_expression): Use current column while building binary operations. * common.opt (fshow-column): Enable by default. * tree-vrp.c (check_array_ref): Use warning_at. (check_array_bounds): Use location from call back if expr has no location. * tree.h: Add location argument to maybe_fold_*. * tree-ssa-ccp.c (ccp_fold): Pass location to maybe_fold_*. (maybe_fold_offset_to_array_ref): Add location argument and use it. (maybe_fold_offset_to_component_ref): Same. (maybe_fold_offset_to_reference): Same. (maybe_fold_offset_to_address): Same. (maybe_fold_stmt_indirect): Same. (maybe_fold_stmt_addition): Same. (fold_stmt_r): Pass location to maybe_fold_*. (fold_gimple_assign): Same. * c-tree.h: Add location argument to finish_decl, default_function_array_conversion, store_init_value. * c-decl.c (define_label): Use error_at. (c_make_fname_decl): Pass location to finish_decl. (finish_decl): New location argument. (build_compound_literal): Pass location to store_init_value. (grokdeclarator): Pass location to finish_decl. (grokfield): Same. * c-typeck.c (array_to_pointer_conversion): New location argument. (function_to_pointer_conversion): Same. (default_function_array_conversion): Same. (parser_build_unary_op): Pass location to overflow_warning. (parser_build_binary_op): Same. Use warning_at. (build_unary_op): Pass location to array_to_pointer_conversion. (build_c_cast): Pass location to digest_init. (build_modify_expr): New location argument. (convert_for_assignment): Same. (store_init_value): Same. (digest_init): Same. (output_init_element): Pass location to digest_init and array_to_pointer_conversion. (c_finish_return): Pass location to convert_for_assignment. * gimplify.c (gimplify_conversion): Pass location to maybe_fold_offset_to_address. * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Pass location to maybe_fold_stmt_addition. * c-omp.c (c_finish_omp_atomic): Pass new location to build_modify_expr. (c_finish_omp_for): Same. * c-common.c (overflow_warning): New argument. * c-common.h: New argument to build_modify_expr, overflow_warning. * c-parser.c (c_parser_declaration_or_fndef): Pass location to finish_decl. (c_parser_initializer): Pass location to default_function_array_conversion. (c_parser_initelt): Same. (c_parser_initval): Same. (c_parser_asm_operands): Same. (c_parser_expr_no_commas): Same. Pass location to build_modify_expr. (c_parser_conditional_expression): Same. (c_parser_binary_expression): Add location info to stack. Use it. (c_parser_unary_expression): Pass location to default_function_array_conversion, parser_build_unary_op, build_indirect_ref, c_parser_postfix_expression_after_primary. (c_parser_postfix_expression_after_primary): New location argument. Use it. (c_parser_expression_conv): Pass location to default_function_array_conversion. (c_parser_expr_list): Same. (c_parser_omp_atomic): Same. (c_parser_omp_for_loop): Same. * c-tree.h: (struct c_declarator): Add comment to id_loc. (build_array_declarator): New argument. * c-decl.c (build_array_declarator): Add location argument. (grokdeclarator): Set id_loc for cdk_array. * c-parser.c (c_parser_direct_declarator_inner): Pass location to build_array_declarator. * tree.c (build_omp_clause): Add location argument. * tree.h (OMP_CLAUSE_HAS_LOCATION): New macro. (OMP_CLAUSE_LOCATION): New macro. (struct tree_omp_clause): Add location field. (build_omp_clause): Add argument. * testsuite/gcc.dg/gomp/for-1.c: Fix column. * cp/pt.c (tsubst_omp_for_iterator): Pass location to build_omp_clause. * cp/parser.c (cp_parser_omp_var_list_no_open): Same. (cp_parser_omp_clause_collapse): Same. (cp_parser_omp_clause_default): Same. (cp_parser_omp_clause_if): Same. (cp_parser_omp_clause_nowait): Same. (cp_parser_omp_clause_num_threads): Same. (cp_parser_omp_clause_ordered): Same. (cp_parser_omp_clause_schedule): Same. (cp_parser_omp_clause_untied): Same. (cp_parser_omp_for_loop): Same. (cp_parser_omp_parallel): Pass location to c_split_parallel_clauses. * c-tree.h (c_start_case): Add location argument. (c_process_expr_stmt): Same. (c_finish_goto_*): Same. * tree-parloops.c (initialize_reductions): Pass location to build_omp_clause. (create_parallel_loop): Same. * fortran/trans-openmp.c (gfc_trans_omp_variable_list): Same. (gfc_trans_omp_reduction_list): Same. (gfc_trans_omp_clauses): Same. (gfc_trans_omp_do): Same. * c-typeck.c (c_finish_goto_label): Same. (c_finish_goto_ptr): New location argument. (c_start_case): Same. (emit_side_effect_warnings): Same. (c_process_expr_stmt): Same. (c_finish_stmt_expr): Same. (c_finish_omp_clauses): Use error_at instead of error. * gimplify.c (gimplify_adjust_omp_clauses_1): Pass location to build_omp_clause. * c-omp.c (c_split_parallel_clauses): New location argument. * tree-nested.c (convert_nonlocal_reference_stmt): Pass location to build_omp_clause. (convert_local_reference_stmt): Same. (convert_gimple_call): Same. * c-common.h (c_split_parallel_clauses): New argument. * c-parser.c (c_parser_statement_after_labels): Pass location to c_finish_goto_label. (c_parser_switch_statement): Pass location to c_start_case. (c_parser_for_statement): Pass location to c_finish_expr_stmt, and c_process_expr_stmt. (c_parser_omp_variable_list): Add location argument. (c_parser_omp_clause_collapse): Pass location to build_omp_clause. (c_parser_omp_clause_default): Same. (c_parser_omp_clause_if): Same. (c_parser_omp_clause_num_threads): Same. (-c_parser_omp_clause_ordered): Same. (c_parser_omp_clause_reduction): Pass location to c_parser_omp_variable_list. (c_parser_omp_clause_schedule): Pass location to build_omp_clause. (c_parser_omp_clause_untied): Same. (c_parser_omp_for_loop): Pass location to c_process_expr_stmt. (c_parser_omp_parallel): Pass location to c_split_parallel_clauses. * c-tree.h (check_for_loop_decls, undeclared_variable, build_component_ref, build_array_ref, build_external_ref, c_expr_sizeof_expr, c_expr_sizeof_type, parser_build_unary_op, build_conditional_expr, build_compound_expr, c_cast_expr, build_c_cast, build_asm_expr, c_end_compound_stmt, c_finish_stmt_expr, c_finish_return, c_finish_omp_parallel, c_finish_omp_task): New argument. * c-semantics.c (build_stmt): Same. (build_case_label): Same. * c-decl.c (c_finish_incomplete_decl): Pass location on down. (undeclared_variable): New argument. (make_label): Same. (lookup_label): Pass location on down. (define_label): Same. (finish_decl): Same. (build_compound_literal): Same. (finish_struct): Same. (finish_function): Do not set location here. (check_for_loop_decls): New argument. * tree.c (save_expr): Set location. (build_empty_stmt): New argument. * tree.h (build_empty_stmt): New argument to build_empty_stmt. (CAN_HAVE_LOCATION_P): Make sure we have a non empty node. * builtins.c (gimplify_va_arg_expr): Use locations. (expand_builtin_sync_operation): Same. * c-typeck.c (build_component_ref): New argument. (build_array_ref): Same. (build_external_ref): Same. (c_expr_sizeof_expr): Same. (c_expr_sizeof_type): Same. (parser_build_unary_op): Same. (build_conditional_expr): Same. (build_compound_expr): Pass location on down. (build_compound_expr): New argument. (build_c_cast): Same. (c_cast_expr): Same. (build_asm_expr): Same. (c_finish_return): Same. (c_process_expr_stmt): Pass location on down. (c_finish_stmt_expr): New argument. (push_clenaup): Same. (c_finish_omp_parallel): Same. (c_finish_omp_task): Same. * gimplify.c (gimplify_call_expr): Pass location on down. * c-omp.c (c_finish_omp_master): New argument. (c_finish_omp_critical): Same. (c_finish_omp_ordered): Same. (c_finish_omp_barrier): Same. (-c_finish_omp_taskwait): Same. (c_finish_omp_atomic): Same. (c_finish_omp_flush): Same. * tree-inline.c (copy_tree_body_r): Pass location on down. (inline_forbidden_p): Remove use of input_location. * c-gimplify.c (c_build_bind_expr): New argument. * c-common.c (c_common_truthvalue_conversion): Pass location on down. (c_sizeof_or_alignof_type): New argument. (c_alignof_expr): Same. (build_va_arg): Same. (c_add_case_label): Same. * c-common.h (c_sizeof_or_alignof_type, c_alignof_expr, c_sizeof, c_alignof, build_va_arg, build_stmt, build_case_label, c_build_bind_expr, objc_build_selector_expr, objc_build_throw_stmt, c_finish_omp_master, c_finish_omp_critical, c_finish_omp_ordered, c_finish_omp_barrier, c_finish_omp_atomic, c_finish_omp_flush, c_finish_omp_taskwait, c_finish_omp_for, c_split_parallel_clauses): New argument. * stub-objc.c (objc_build_selector_expr): Same. (objc_build_throw_stmt): Same. * c-parser.c (c_parser_declaration_or_fndef): Pass location on down. (c_parser_initelt): Same. (c_parser_compound_statement): Same. (c_parser_compound_statement_nostart): Same. (c_parser_label): Same. (c_parser_statement_after_labels): Same. (c_parser_if_body): Same. (c_parser_else_body): Same. (c_parser_if_statement): Same. (c_parser_switch_statement): Same. (c_parser_while_statement): Same. (c_parser_do_statement): Same. (c_parser_for_statement): Same. (c_parser_asm_statement): Same. (c_parser_conditional_expression): Same. (c_parser_binary_expression): Same. (c_parser_cast_expression): Same. (c_parser_unary_expression): Same. (c_parser_sizeof_expression): Same. (c_parser_alignof_expression): Same. (c_parser_postfix_expression): Same. (c_parser_expression): Same. (c_parser_objc_receiver): Same. (c_parser_omp_variable_list): Same. (c_parser_omp_structured_block): Same. (c_parser_omp_atomic): New argument. (c_parser_omp_barrier): Same. (c_parser_omp_critical): Same. (c_parser_omp_flush): Pass location on down. (c_parser_omp_for_loop): New argument. (c_parser_omp_for): Same. (c_parser_omp_master): Same. (c_parser_omp_ordered): Same. (c_parser_omp_sections_scope): Same. (c_parser_omp_sections): Same. (c_parser_omp_parallel): Same. (c_parser_omp_single): Same. (c_parser_omp_task): Same. (c_parser_omp_taskwait): Pass location on down. (c_parser_omp_construct): Same. (c_parser_omp_threadprivate): Same. * dwarf2asm.c, targhooks.c, optabs.c, tree.c, tree.h, target.h, builtins.c, omp-low.c, cgraphunit.c, tree-call-cdce.c, tree-ssa-alias.c, gimple-low.c, c-tree.h, expr.c, tree-parloops.c, c-decl.c, tree-eh.c, langhooks.c, function.c, stor-layout.c, c-typeck.c, gimplify.c, c-pragma.c, expmed.c, except.c, coverage.c, emit-rtl.c, cfgexpand.c, tree-mudflap.c, varasm.c, tree-nested.c, rtl.h, tree-inline.c, tree-profile.c, c-common.c, c-common.h, tree-switch-conversion.c, tree-cfg.c, ipa-struct-reorg.c, c-parser.c, config/i386/i386.c, stmt.c: Add location argument to the following function definitions and/or function calls: build_decl, objcp_start_struct, objcp_finish_struct, start_struct, finish_struct, PUSH_FIELD, create_artificial_label, cp_make_fname_decl, pushtag, implicitly_declare, c_make_fname_decl, build_compound_literal, parser_xref_tag, resolve_overloaded_builtin, do_case, c_finish_bc_stmt, build_compound_literal, build_function_call. * c-decl.c (build_compound_literal): Add location argument. Make all diagnostic calls use location. (start_struct): Same. (finish_struct): Same. (start_enum): Same. (build_enumerator): Same. (start_function): Same. (grokdeclarator): Make all diagnostic calls use location. (store_parm_decls_oldstyle): Same. * c-typeck.c (build_function_call): Add location argument. Make all diagnostic calls use location. (do_case): Same. (c_finish_bc_stmt): Same. * tree-nested.c (get_trampoline_type): Add argument. Pass location to build_decl. (lookup_tramp_for_decl): Pass location to get_trampoline_type. * rtl.h (RTL_LOCATION): New. * c-common.c (c_add_case_label): Add location argument. Make all diagnostic calls use location. * c-common.h: Add location argument to make_fname_decl, do_case, c_add_case_label, build_function_call, resolve_overloaded_builtin. * c-parser.c (c_parser_enum_specifier): Rename ident_loc to enum_loc. Set it appropriately for every case. Pass enum_loc to start_enum call. Pass value_loc first to build_enumerator. Pass enum_loc to parser_xref_tag. (c_parser_struct_or_union_specifier): Save location. Use it for start_struct, finish_struct, and parser_xref_tag. gcc/testsuite/ * gcc.dg/old-style-prom-3.c: Add column info. * gcc.dg/overflow-warn-1.c * gcc.dg/gomp/pr27415.c * gcc.dg/gomp/for-1.c: Same. * gcc.dg/enum-compat-1.c: Same. * gcc.dg/c99-tag-3.c: Same. * gcc.dg/Wredundant-decls-2.c: Same. * gcc.dg/func-ptr-conv-1.c: Same. * gcc.dg/asm-wide-1.c: Same. * gcc.dg/nofixed-point-2.c: Same. * gcc.dg/cpp/line3.c: Same. * gcc.dg/array-10.c: Same. * gcc.dg/c99-vla-jump-1.c: Same. * gcc.dg/pr20368-1.c: Same. * gcc.dg/Wshadow-3.c: Same. * gcc.dg/c90-const-expr-8.c: Same. * gcc.dg/label-decl-2.c: Same. * gcc.dg/dremf-type-compat-2.c: Same. * gcc.dg/c90-const-expr-5.c: Same. * gcc.dg/builtins-30.c: Same. * gcc.dg/Warray-bounds.c: Same. * gcc.dg/Wcxx-compat-2.c: Same. * gcc.dg/tree-ssa/col-1.c: Same. * gcc.dg/old-style-prom-2.c: Same. * gcc.dg/cast-function-1.c: Same. * gcc.dg/pr15698-1.c: Same. * gcc.dg/dremf-type-compat-3.c: Same. * gcc.dg/vla-8.c: Same. * gcc.dg/gomp/pr27415.c: Move firstprivate diagnostics to correct line. * gcc.dg/label-decl-2.c: Move label diagnostic to correct line. * gcc.dg/old-style-prom-3.c: Check for error on the correct line. * gcc.dg/enum-compat-1.c: Same. * gcc.dg/dremf-type-compat-2.c: Same. * gcc.dg/old-style-prom-2.c: Same. * gcc.dg/pr15698-1.c: Same. * gcc.dg/pr20368-1.c: Same. * gcc.dg/dremf-type-compat-3.c: Same. * gcc.dg/builtins-30.c: Same. Test for columns. gcc/objcp/ * objcp-decl.h (c_end_compound_stmt): New argument. * objcp-decl.c (objcp_start_struct): Add argument. (objcp_finish_struct): Same. gcc/cp/ * typeck.c (cp_build_binary_op): Pass location to overflow_warning. (build_modify_expr): New arg. * semantics.c (finish_unary_op_expr): Pass location to overflow_warning. (handle_omp_for_class_iterator): Pass location to build_modify_expr. * typeck.c (cxx_sizeof_or_alignof_type): Pass location to c_sizeof_or_alignof_type. (build_array_ref): New argument. (build_compound_expr): Same. (build_const_cast): Same. (build_ptrmemfunc): Pass location to build_c_cast. * init.c (avoid_placement_new_aliasing): Pass location to build_stmt. (build_vec_delete_1): Pass location to cp_build_modify_expr, build_compound_expr. * class.c (build_vtbl_ref_1): Pass location to build_array_ref. * decl.c (poplevel): Pass location to c_build_bind_expr. (finish_case_label): Pass location to build_case_label. (finish_constructor_body): Same. (finish_destructor_body): Pass location to build_stmt. (cxx_maybe_build_cleanup): Same, but to build_compound_expr. * call.c (build_new_op): Pass location to build_array_ref. (build_x_va_arg): Pass location to build_va_arg. * except.c (expand_end_catch_block): Pass location to build_stmt. * cp-tree.h (build_array_ref): New argument. (build_compound_expr): Same. (build_c_cast): Same. * cp-gimplify.c (gimplify_if_stmt): Pass location on down. (gimplify_switch_stmt): Same. * typeck2.c (split_nonconstant_init_1): Same. * pt.c (tsubst_copy): Same. * semantics.c (add_decl_expr): Same. (do_poplevel): Same. (push_cleanup): Same. (finish_goto_stmt): Same. (finish_expr_stmt): Same. (begin_if_stmt): Same. (begin_while_stmt): Same. (begin_do_stmt): Same. (finish_return_stmt): Same. (begin_for_stmt): Same. (finish_break_stmt): Same. (finish_continue_stmt): Same. (begin_switch_stmt): Same. (begin_try_block): Same. (begin_handler): Same. (finish_asm_stmt): Same. (finish_label_stmt): Same. (finish_stmt_expr_expr): Same. (finalize_nrv_r): Same. (finish_omp_atomic): Same. * name-lookup.c (do_using_directive): Same. * decl2.c (grok_array_decl): Same. * parser.c (cp_parser_cast_expression): Same. (cp_parser_selection_statement): Same. (cp_parser_implicitly_scoped_statement): Same. (cp_parser_objc_selector_expression): Same. (cp_parser_objc_synchronized_statement): Same. (cp_parser_objc_throw_statement): Same. (cp_parser_omp_critical): Same. (cp_parser_omp_master): Same. * typeck.c (build_function_call): Add location argument. * init.c: Add location argument to all build_decl calls. * class.c: Same. * method.c: Same. * rtti.c: Same. * tree.c: Same. * pt.c: Same. * semantics.c: Same. * lex.c: Same. * decl2.c: Same. * cp-gimplify.c: Same. * decl.c: Same. (cp_make_fname_decl): Add location argument. Pass location ot build_decl. (finish_case_label): Same. * cp-tree.h (finish_case_label): Add location argument. * parser.c (cp_parser_label_for_labeled_statement): Pass location to finish_case_label. gcc/fortran/ * trans-array.c (gfc_trans_allocate_array_storage): Pass location on down. (gfc_trans_array_constructor_value): Same. (gfc_trans_scalarized_loop_end): Same. (gfc_conv_ss_startstride): Same. (gfc_trans_g77_array): Same. (gfc_trans_dummy_array_bias): Same. (gfc_conv_array_parameter): Same. (structure_alloc_comps): Same. * trans-expr.c (gfc_conv_function_call): Same. (fill_with_spaces): Same. (gfc_trans_string_copy): Same. (gfc_trans_scalar_assign): Same. * trans-stmt.c (gfc_trans_goto): Same. (gfc_trans_if_1): Same. (gfc_trans_simple_do): Same. (gfc_trans_do): Same. (gfc_trans_do_while): Same. (gfc_trans_logical_select): Same. (gfc_trans_select): Same. (gfc_trans_forall_loop): Same. (gfc_trans_nested_forall_loop): Same. (generate_loop_for_temp_to_lhs): Same. (generate_loop_for_rhs_to_temp): Same. (gfc_trans_forall_1): Same. (gfc_trans_where_assign): Same. (gfc_trans_where_3): Same. (gfc_trans_allocate): Same. * trans.c (gfc_finish_block): Same. (gfc_trans_runtime_check): Same. (gfc_call_malloc): Same. (gfc_allocate_with_status): Same. (gfc_call_free): Same. (gfc_deallocate_with_status): Same. (gfc_call_realloc): Same. (gfc_trans_code): Same. * trans-decl.c (gfc_init_default_dt): Same. (gfc_generate_constructors): Same. * trans-io.c (gfc_trans_io_runtime_check): Same. * trans-intrinsic.c (gfc_conv_intrinsic_ctime): Same. (gfc_conv_intrinsic_fdate): Same. (gfc_conv_intrinsic_ttynam): Same. (gfc_conv_intrinsic_minmax): Same. (gfc_conv_intrinsic_minmax_char): Same. (gfc_conv_intrinsic_anyall): Same. (gfc_conv_intrinsic_count): Same. (gfc_conv_intrinsic_arith): Same. (gfc_conv_intrinsic_minmaxloc): Same. (gfc_conv_intrinsic_minmaxval): Same. (gfc_conv_intrinsic_rrspacing): Same. (gfc_conv_intrinsic_array_transfer): Same. (gfc_conv_intrinsic_trim): Same. (gfc_conv_intrinsic_repeat): Same. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@148442 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog296
-rw-r--r--gcc/builtins.c25
-rw-r--r--gcc/c-common.c257
-rw-r--r--gcc/c-common.h53
-rw-r--r--gcc/c-decl.c574
-rw-r--r--gcc/c-gimplify.c5
-rw-r--r--gcc/c-omp.c86
-rw-r--r--gcc/c-parser.c608
-rw-r--r--gcc/c-pragma.c3
-rw-r--r--gcc/c-semantics.c11
-rw-r--r--gcc/c-tree.h79
-rw-r--r--gcc/c-typeck.c555
-rw-r--r--gcc/cfgexpand.c3
-rw-r--r--gcc/cgraphunit.c5
-rw-r--r--gcc/config/i386/i386.c31
-rw-r--r--gcc/coverage.c54
-rw-r--r--gcc/cp/ChangeLog83
-rw-r--r--gcc/cp/call.c4
-rw-r--r--gcc/cp/class.c17
-rw-r--r--gcc/cp/cp-gimplify.c15
-rw-r--r--gcc/cp/cp-tree.h11
-rw-r--r--gcc/cp/decl.c73
-rw-r--r--gcc/cp/decl2.c11
-rw-r--r--gcc/cp/except.c2
-rw-r--r--gcc/cp/init.c17
-rw-r--r--gcc/cp/lex.c6
-rw-r--r--gcc/cp/method.c9
-rw-r--r--gcc/cp/name-lookup.c4
-rw-r--r--gcc/cp/parser.c64
-rw-r--r--gcc/cp/pt.c28
-rw-r--r--gcc/cp/rtti.c42
-rw-r--r--gcc/cp/semantics.c49
-rw-r--r--gcc/cp/tree.c6
-rw-r--r--gcc/cp/typeck.c29
-rw-r--r--gcc/cp/typeck2.c4
-rw-r--r--gcc/dwarf2asm.c2
-rw-r--r--gcc/emit-rtl.c3
-rw-r--r--gcc/except.c18
-rw-r--r--gcc/expmed.c2
-rw-r--r--gcc/expr.c10
-rw-r--r--gcc/fortran/ChangeLog56
-rw-r--r--gcc/fortran/trans-array.c29
-rw-r--r--gcc/fortran/trans-common.c18
-rw-r--r--gcc/fortran/trans-decl.c101
-rw-r--r--gcc/fortran/trans-expr.c15
-rw-r--r--gcc/fortran/trans-intrinsic.c50
-rw-r--r--gcc/fortran/trans-io.c2
-rw-r--r--gcc/fortran/trans-openmp.c33
-rw-r--r--gcc/fortran/trans-stmt.c51
-rw-r--r--gcc/fortran/trans-types.c38
-rw-r--r--gcc/fortran/trans.c31
-rw-r--r--gcc/function.c6
-rw-r--r--gcc/gimple-low.c9
-rw-r--r--gcc/gimple-pretty-print.c4
-rw-r--r--gcc/gimplify.c58
-rw-r--r--gcc/ipa-struct-reorg.c3
-rw-r--r--gcc/java/ChangeLog16
-rw-r--r--gcc/java/builtins.c5
-rw-r--r--gcc/java/class.c101
-rw-r--r--gcc/java/constants.c5
-rw-r--r--gcc/java/decl.c278
-rw-r--r--gcc/java/except.c6
-rw-r--r--gcc/java/expr.c29
-rw-r--r--gcc/java/java-gimplify.c2
-rw-r--r--gcc/java/java-tree.h6
-rw-r--r--gcc/java/jcf-parse.c8
-rw-r--r--gcc/java/resource.c14
-rw-r--r--gcc/java/typeck.c8
-rw-r--r--gcc/langhooks.c4
-rw-r--r--gcc/objc/ChangeLog28
-rw-r--r--gcc/objc/objc-act.c253
-rw-r--r--gcc/objcp/ChangeLog6
-rw-r--r--gcc/objcp/objcp-decl.c6
-rw-r--r--gcc/objcp/objcp-decl.h6
-rw-r--r--gcc/omp-low.c61
-rw-r--r--gcc/optabs.c3
-rw-r--r--gcc/rtl.h6
-rw-r--r--gcc/stmt.c7
-rw-r--r--gcc/stor-layout.c3
-rw-r--r--gcc/stub-objc.c4
-rw-r--r--gcc/target.h3
-rw-r--r--gcc/targhooks.c8
-rw-r--r--gcc/testsuite/ChangeLog42
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds.c30
-rw-r--r--gcc/testsuite/gcc.dg/Wcxx-compat-2.c64
-rw-r--r--gcc/testsuite/gcc.dg/Wredundant-decls-2.c20
-rw-r--r--gcc/testsuite/gcc.dg/Wshadow-3.c80
-rw-r--r--gcc/testsuite/gcc.dg/array-10.c42
-rw-r--r--gcc/testsuite/gcc.dg/asm-wide-1.c18
-rw-r--r--gcc/testsuite/gcc.dg/builtins-30.c18
-rw-r--r--gcc/testsuite/gcc.dg/c90-const-expr-5.c8
-rw-r--r--gcc/testsuite/gcc.dg/c90-const-expr-8.c28
-rw-r--r--gcc/testsuite/gcc.dg/c99-tag-3.c22
-rw-r--r--gcc/testsuite/gcc.dg/c99-vla-jump-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/cast-function-1.c8
-rw-r--r--gcc/testsuite/gcc.dg/cpp/line3.c12
-rw-r--r--gcc/testsuite/gcc.dg/dremf-type-compat-2.c6
-rw-r--r--gcc/testsuite/gcc.dg/dremf-type-compat-3.c6
-rw-r--r--gcc/testsuite/gcc.dg/enum-compat-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/func-ptr-conv-1.c44
-rw-r--r--gcc/testsuite/gcc.dg/gomp/for-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/gomp/pr27415.c8
-rw-r--r--gcc/testsuite/gcc.dg/label-decl-2.c3
-rw-r--r--gcc/testsuite/gcc.dg/nofixed-point-2.c3
-rw-r--r--gcc/testsuite/gcc.dg/old-style-prom-2.c6
-rw-r--r--gcc/testsuite/gcc.dg/old-style-prom-3.c6
-rw-r--r--gcc/testsuite/gcc.dg/overflow-warn-1.c18
-rw-r--r--gcc/testsuite/gcc.dg/pr15698-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/pr20368-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/col-1.c17
-rw-r--r--gcc/testsuite/gcc.dg/vla-8.c4
-rw-r--r--gcc/tree-call-cdce.c2
-rw-r--r--gcc/tree-cfg.c8
-rw-r--r--gcc/tree-eh.c50
-rw-r--r--gcc/tree-inline.c10
-rw-r--r--gcc/tree-mudflap.c9
-rw-r--r--gcc/tree-nested.c31
-rw-r--r--gcc/tree-parloops.c25
-rw-r--r--gcc/tree-profile.c4
-rw-r--r--gcc/tree-ssa-ccp.c94
-rw-r--r--gcc/tree-ssa-forwprop.c3
-rw-r--r--gcc/tree-ssa-operands.c3
-rw-r--r--gcc/tree-ssa.c2
-rw-r--r--gcc/tree-switch-conversion.c9
-rw-r--r--gcc/tree-vrp.c18
-rw-r--r--gcc/tree.c39
-rw-r--r--gcc/tree.h23
-rw-r--r--gcc/varasm.c24
128 files changed, 3455 insertions, 1970 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d8c08aa9920..d1c91f4b8e8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,299 @@
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * tree-pretty-print.c (dump_generic_node): Dump column numbers.
+ * gimple-pretty-print.c (dump_gimple_stmt): Same.
+ * gimplify.c (gimplify_modify_expr): Set location for GIMPLE_ASSIGNs
+ created.
+ * c-parser.c (c_parser_binary_expression): Use current column while
+ building binary operations.
+ * common.opt (fshow-column): Enable by default.
+ * tree-vrp.c (check_array_ref): Use warning_at.
+ (check_array_bounds): Use location from call back if expr has no
+ location.
+ * tree.h: Add location argument to maybe_fold_*.
+ * tree-ssa-ccp.c (ccp_fold): Pass location to maybe_fold_*.
+ (maybe_fold_offset_to_array_ref): Add location argument and use it.
+ (maybe_fold_offset_to_component_ref): Same.
+ (maybe_fold_offset_to_reference): Same.
+ (maybe_fold_offset_to_address): Same.
+ (maybe_fold_stmt_indirect): Same.
+ (maybe_fold_stmt_addition): Same.
+ (fold_stmt_r): Pass location to maybe_fold_*.
+ (fold_gimple_assign): Same.
+ * c-tree.h: Add location argument to finish_decl,
+ default_function_array_conversion, store_init_value.
+ * c-decl.c (define_label): Use error_at.
+ (c_make_fname_decl): Pass location to finish_decl.
+ (finish_decl): New location argument.
+ (build_compound_literal): Pass location to store_init_value.
+ (grokdeclarator): Pass location to finish_decl.
+ (grokfield): Same.
+ * c-typeck.c (array_to_pointer_conversion): New location argument.
+ (function_to_pointer_conversion): Same.
+ (default_function_array_conversion): Same.
+ (parser_build_unary_op): Pass location to overflow_warning.
+ (parser_build_binary_op): Same. Use warning_at.
+ (build_unary_op): Pass location to array_to_pointer_conversion.
+ (build_c_cast): Pass location to digest_init.
+ (build_modify_expr): New location argument.
+ (convert_for_assignment): Same.
+ (store_init_value): Same.
+ (digest_init): Same.
+ (output_init_element): Pass location to digest_init and
+ array_to_pointer_conversion.
+ (c_finish_return): Pass location to convert_for_assignment.
+ * gimplify.c (gimplify_conversion): Pass location to
+ maybe_fold_offset_to_address.
+ * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Pass location
+ to maybe_fold_stmt_addition.
+ * c-omp.c (c_finish_omp_atomic): Pass new location to
+ build_modify_expr.
+ (c_finish_omp_for): Same.
+ * c-common.c (overflow_warning): New argument.
+ * c-common.h: New argument to build_modify_expr, overflow_warning.
+ * c-parser.c (c_parser_declaration_or_fndef): Pass location to
+ finish_decl.
+ (c_parser_initializer): Pass location to
+ default_function_array_conversion.
+ (c_parser_initelt): Same.
+ (c_parser_initval): Same.
+ (c_parser_asm_operands): Same.
+ (c_parser_expr_no_commas): Same. Pass location to build_modify_expr.
+ (c_parser_conditional_expression): Same.
+ (c_parser_binary_expression): Add location info to stack. Use it.
+ (c_parser_unary_expression): Pass location to
+ default_function_array_conversion, parser_build_unary_op,
+ build_indirect_ref, c_parser_postfix_expression_after_primary.
+ (c_parser_postfix_expression_after_primary): New location argument.
+ Use it.
+ (c_parser_expression_conv): Pass location to
+ default_function_array_conversion.
+ (c_parser_expr_list): Same.
+ (c_parser_omp_atomic): Same.
+ (c_parser_omp_for_loop): Same.
+ * c-tree.h: (struct c_declarator): Add comment to id_loc.
+ (build_array_declarator): New argument.
+ * c-decl.c (build_array_declarator): Add location argument.
+ (grokdeclarator): Set id_loc for cdk_array.
+ * c-parser.c (c_parser_direct_declarator_inner): Pass location to
+ build_array_declarator.
+ * tree.c (build_omp_clause): Add location argument.
+ * tree.h (OMP_CLAUSE_HAS_LOCATION): New macro.
+ (OMP_CLAUSE_LOCATION): New macro.
+ (struct tree_omp_clause): Add location field.
+ (build_omp_clause): Add argument.
+ * testsuite/gcc.dg/gomp/for-1.c: Fix column.
+ * cp/pt.c (tsubst_omp_for_iterator): Pass location to
+ build_omp_clause.
+ * cp/parser.c (cp_parser_omp_var_list_no_open): Same.
+ (cp_parser_omp_clause_collapse): Same.
+ (cp_parser_omp_clause_default): Same.
+ (cp_parser_omp_clause_if): Same.
+ (cp_parser_omp_clause_nowait): Same.
+ (cp_parser_omp_clause_num_threads): Same.
+ (cp_parser_omp_clause_ordered): Same.
+ (cp_parser_omp_clause_schedule): Same.
+ (cp_parser_omp_clause_untied): Same.
+ (cp_parser_omp_for_loop): Same.
+ (cp_parser_omp_parallel): Pass location to c_split_parallel_clauses.
+ * c-tree.h (c_start_case): Add location argument.
+ (c_process_expr_stmt): Same.
+ (c_finish_goto_*): Same.
+ * tree-parloops.c (initialize_reductions): Pass location to
+ build_omp_clause.
+ (create_parallel_loop): Same.
+ * fortran/trans-openmp.c (gfc_trans_omp_variable_list): Same.
+ (gfc_trans_omp_reduction_list): Same.
+ (gfc_trans_omp_clauses): Same.
+ (gfc_trans_omp_do): Same.
+ * c-typeck.c (c_finish_goto_label): Same.
+ (c_finish_goto_ptr): New location argument.
+ (c_start_case): Same.
+ (emit_side_effect_warnings): Same.
+ (c_process_expr_stmt): Same.
+ (c_finish_stmt_expr): Same.
+ (c_finish_omp_clauses): Use error_at instead of error.
+ * gimplify.c (gimplify_adjust_omp_clauses_1): Pass location to
+ build_omp_clause.
+ * c-omp.c (c_split_parallel_clauses): New location argument.
+ * tree-nested.c (convert_nonlocal_reference_stmt): Pass location
+ to build_omp_clause.
+ (convert_local_reference_stmt): Same.
+ (convert_gimple_call): Same.
+ * c-common.h (c_split_parallel_clauses): New argument.
+ * c-parser.c (c_parser_statement_after_labels): Pass location to
+ c_finish_goto_label.
+ (c_parser_switch_statement): Pass location to c_start_case.
+ (c_parser_for_statement): Pass location to c_finish_expr_stmt,
+ and c_process_expr_stmt.
+ (c_parser_omp_variable_list): Add location argument.
+ (c_parser_omp_clause_collapse): Pass location to
+ build_omp_clause.
+ (c_parser_omp_clause_default): Same.
+ (c_parser_omp_clause_if): Same.
+ (c_parser_omp_clause_num_threads): Same.
+ (-c_parser_omp_clause_ordered): Same.
+ (c_parser_omp_clause_reduction): Pass location to
+ c_parser_omp_variable_list.
+ (c_parser_omp_clause_schedule): Pass location to build_omp_clause.
+ (c_parser_omp_clause_untied): Same.
+ (c_parser_omp_for_loop): Pass location to c_process_expr_stmt.
+ (c_parser_omp_parallel): Pass location to
+ c_split_parallel_clauses.
+
+ * c-tree.h (check_for_loop_decls, undeclared_variable,
+ build_component_ref, build_array_ref, build_external_ref,
+ c_expr_sizeof_expr, c_expr_sizeof_type, parser_build_unary_op,
+ build_conditional_expr, build_compound_expr, c_cast_expr,
+ build_c_cast, build_asm_expr, c_end_compound_stmt, c_finish_stmt_expr,
+ c_finish_return, c_finish_omp_parallel, c_finish_omp_task): New
+ argument.
+ * c-semantics.c (build_stmt): Same.
+ (build_case_label): Same.
+ * c-decl.c (c_finish_incomplete_decl): Pass location on down.
+ (undeclared_variable): New argument.
+ (make_label): Same.
+ (lookup_label): Pass location on down.
+ (define_label): Same.
+ (finish_decl): Same.
+ (build_compound_literal): Same.
+ (finish_struct): Same.
+ (finish_function): Do not set location here.
+ (check_for_loop_decls): New argument.
+ * tree.c (save_expr): Set location.
+ (build_empty_stmt): New argument.
+ * tree.h (build_empty_stmt): New argument to build_empty_stmt.
+ (CAN_HAVE_LOCATION_P): Make sure we have a non empty node.
+ * builtins.c (gimplify_va_arg_expr): Use locations.
+ (expand_builtin_sync_operation): Same.
+ * c-typeck.c (build_component_ref): New argument.
+ (build_array_ref): Same.
+ (build_external_ref): Same.
+ (c_expr_sizeof_expr): Same.
+ (c_expr_sizeof_type): Same.
+ (parser_build_unary_op): Same.
+ (build_conditional_expr): Same.
+ (build_compound_expr): Pass location on down.
+ (build_compound_expr): New argument.
+ (build_c_cast): Same.
+ (c_cast_expr): Same.
+ (build_asm_expr): Same.
+ (c_finish_return): Same.
+ (c_process_expr_stmt): Pass location on down.
+ (c_finish_stmt_expr): New argument.
+ (push_clenaup): Same.
+ (c_finish_omp_parallel): Same.
+ (c_finish_omp_task): Same.
+ * gimplify.c (gimplify_call_expr): Pass location on down.
+ * c-omp.c (c_finish_omp_master): New argument.
+ (c_finish_omp_critical): Same.
+ (c_finish_omp_ordered): Same.
+ (c_finish_omp_barrier): Same.
+ (-c_finish_omp_taskwait): Same.
+ (c_finish_omp_atomic): Same.
+ (c_finish_omp_flush): Same.
+ * tree-inline.c (copy_tree_body_r): Pass location on down.
+ (inline_forbidden_p): Remove use of input_location.
+ * c-gimplify.c (c_build_bind_expr): New argument.
+ * c-common.c (c_common_truthvalue_conversion): Pass location on down.
+ (c_sizeof_or_alignof_type): New argument.
+ (c_alignof_expr): Same.
+ (build_va_arg): Same.
+ (c_add_case_label): Same.
+ * c-common.h (c_sizeof_or_alignof_type, c_alignof_expr,
+ c_sizeof, c_alignof, build_va_arg, build_stmt, build_case_label,
+ c_build_bind_expr, objc_build_selector_expr, objc_build_throw_stmt,
+ c_finish_omp_master, c_finish_omp_critical, c_finish_omp_ordered,
+ c_finish_omp_barrier, c_finish_omp_atomic, c_finish_omp_flush,
+ c_finish_omp_taskwait, c_finish_omp_for, c_split_parallel_clauses):
+ New argument.
+ * stub-objc.c (objc_build_selector_expr): Same.
+ (objc_build_throw_stmt): Same.
+ * c-parser.c (c_parser_declaration_or_fndef): Pass location on down.
+ (c_parser_initelt): Same.
+ (c_parser_compound_statement): Same.
+ (c_parser_compound_statement_nostart): Same.
+ (c_parser_label): Same.
+ (c_parser_statement_after_labels): Same.
+ (c_parser_if_body): Same.
+ (c_parser_else_body): Same.
+ (c_parser_if_statement): Same.
+ (c_parser_switch_statement): Same.
+ (c_parser_while_statement): Same.
+ (c_parser_do_statement): Same.
+ (c_parser_for_statement): Same.
+ (c_parser_asm_statement): Same.
+ (c_parser_conditional_expression): Same.
+ (c_parser_binary_expression): Same.
+ (c_parser_cast_expression): Same.
+ (c_parser_unary_expression): Same.
+ (c_parser_sizeof_expression): Same.
+ (c_parser_alignof_expression): Same.
+ (c_parser_postfix_expression): Same.
+ (c_parser_expression): Same.
+ (c_parser_objc_receiver): Same.
+ (c_parser_omp_variable_list): Same.
+ (c_parser_omp_structured_block): Same.
+ (c_parser_omp_atomic): New argument.
+ (c_parser_omp_barrier): Same.
+ (c_parser_omp_critical): Same.
+ (c_parser_omp_flush): Pass location on down.
+ (c_parser_omp_for_loop): New argument.
+ (c_parser_omp_for): Same.
+ (c_parser_omp_master): Same.
+ (c_parser_omp_ordered): Same.
+ (c_parser_omp_sections_scope): Same.
+ (c_parser_omp_sections): Same.
+ (c_parser_omp_parallel): Same.
+ (c_parser_omp_single): Same.
+ (c_parser_omp_task): Same.
+ (c_parser_omp_taskwait): Pass location on down.
+ (c_parser_omp_construct): Same.
+ (c_parser_omp_threadprivate): Same.
+ * dwarf2asm.c, targhooks.c, optabs.c, tree.c, tree.h, target.h,
+ builtins.c, omp-low.c, cgraphunit.c, tree-call-cdce.c,
+ tree-ssa-alias.c, gimple-low.c, c-tree.h, expr.c, tree-parloops.c,
+ c-decl.c, tree-eh.c, langhooks.c, function.c, stor-layout.c,
+ c-typeck.c, gimplify.c, c-pragma.c, expmed.c, except.c, coverage.c,
+ emit-rtl.c, cfgexpand.c, tree-mudflap.c, varasm.c, tree-nested.c,
+ rtl.h, tree-inline.c, tree-profile.c, c-common.c, c-common.h,
+ tree-switch-conversion.c, tree-cfg.c, ipa-struct-reorg.c, c-parser.c,
+ config/i386/i386.c, stmt.c:
+ Add location argument to the following function definitions and/or
+ function calls: build_decl, objcp_start_struct, objcp_finish_struct,
+ start_struct, finish_struct, PUSH_FIELD, create_artificial_label,
+ cp_make_fname_decl, pushtag, implicitly_declare, c_make_fname_decl,
+ build_compound_literal, parser_xref_tag, resolve_overloaded_builtin,
+ do_case, c_finish_bc_stmt, build_compound_literal,
+ build_function_call.
+ * c-decl.c (build_compound_literal): Add location argument.
+ Make all diagnostic calls use location.
+ (start_struct): Same.
+ (finish_struct): Same.
+ (start_enum): Same.
+ (build_enumerator): Same.
+ (start_function): Same.
+ (grokdeclarator): Make all diagnostic calls use location.
+ (store_parm_decls_oldstyle): Same.
+ * c-typeck.c (build_function_call): Add location argument.
+ Make all diagnostic calls use location.
+ (do_case): Same.
+ (c_finish_bc_stmt): Same.
+ * tree-nested.c (get_trampoline_type): Add argument.
+ Pass location to build_decl.
+ (lookup_tramp_for_decl): Pass location to get_trampoline_type.
+ * rtl.h (RTL_LOCATION): New.
+ * c-common.c (c_add_case_label): Add location argument.
+ Make all diagnostic calls use location.
+ * c-common.h: Add location argument to make_fname_decl, do_case,
+ c_add_case_label, build_function_call, resolve_overloaded_builtin.
+ * c-parser.c (c_parser_enum_specifier): Rename ident_loc to enum_loc.
+ Set it appropriately for every case. Pass enum_loc to start_enum
+ call. Pass value_loc first to build_enumerator. Pass enum_loc to
+ parser_xref_tag.
+ (c_parser_struct_or_union_specifier): Save location. Use it for
+ start_struct, finish_struct, and parser_xref_tag.
+
2009-06-12 Ian Lance Taylor <iant@google.com>
* fold-const.c (fold_unary): Rename local variable and to
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 98919780e28..a6d26efa776 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -4975,6 +4975,8 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
tree valist = TREE_OPERAND (*expr_p, 0);
tree type = TREE_TYPE (*expr_p);
tree t;
+ location_t loc = EXPR_HAS_LOCATION (*expr_p) ? EXPR_LOCATION (*expr_p) :
+ UNKNOWN_LOCATION;
/* Verify that valist is of the proper type. */
have_va_type = TREE_TYPE (valist);
@@ -4984,7 +4986,7 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
if (have_va_type == NULL_TREE)
{
- error ("first argument to %<va_arg%> not of type %<va_list%>");
+ error_at (loc, "first argument to %<va_arg%> not of type %<va_list%>");
return GS_ERROR;
}
@@ -4999,19 +5001,20 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
/* Unfortunately, this is merely undefined, rather than a constraint
violation, so we cannot make this an error. If this call is never
executed, the program is still strictly conforming. */
- warned = warning (0, "%qT is promoted to %qT when passed through %<...%>",
- type, promoted_type);
+ warned = warning_at (loc, 0,
+ "%qT is promoted to %qT when passed through %<...%>",
+ type, promoted_type);
if (!gave_help && warned)
{
gave_help = true;
- inform (input_location, "(so you should pass %qT not %qT to %<va_arg%>)",
- promoted_type, type);
+ inform (loc, "(so you should pass %qT not %qT to %<va_arg%>)",
+ promoted_type, type);
}
/* We can, however, treat "undefined" any way we please.
Call abort to encourage the user to fix the program. */
if (warned)
- inform (input_location, "if this code is reached, the program will abort");
+ inform (loc, "if this code is reached, the program will abort");
/* Before the abort, allow the evaluation of the va_list
expression to exit or longjmp. */
gimplify_and_add (valist, pre_p);
@@ -5984,7 +5987,8 @@ expand_builtin_fork_or_exec (tree fn, tree exp, rtx target, int ignore)
gcc_unreachable ();
}
- decl = build_decl (FUNCTION_DECL, id, TREE_TYPE (fn));
+ decl = build_decl (DECL_SOURCE_LOCATION (fn),
+ FUNCTION_DECL, id, TREE_TYPE (fn));
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
@@ -6050,6 +6054,7 @@ expand_builtin_sync_operation (enum machine_mode mode, tree exp,
{
rtx val, mem;
enum machine_mode old_mode;
+ location_t loc = EXPR_LOCATION (exp);
if (code == NOT && warn_sync_nand)
{
@@ -6070,8 +6075,7 @@ expand_builtin_sync_operation (enum machine_mode mode, tree exp,
break;
fndecl = implicit_built_in_decls[BUILT_IN_FETCH_AND_NAND_N];
- inform (input_location,
- "%qD changed semantics in GCC 4.4", fndecl);
+ inform (loc, "%qD changed semantics in GCC 4.4", fndecl);
warned_f_a_n = true;
break;
@@ -6085,8 +6089,7 @@ expand_builtin_sync_operation (enum machine_mode mode, tree exp,
break;
fndecl = implicit_built_in_decls[BUILT_IN_NAND_AND_FETCH_N];
- inform (input_location,
- "%qD changed semantics in GCC 4.4", fndecl);
+ inform (loc, "%qD changed semantics in GCC 4.4", fndecl);
warned_n_a_f = true;
break;
diff --git a/gcc/c-common.c b/gcc/c-common.c
index b26662da18c..139a5d2346f 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -440,7 +440,7 @@ int max_tinst_depth = 500;
type names and storage classes. It is indexed by a RID_... value. */
tree *ridpointers;
-tree (*make_fname_decl) (tree, int);
+tree (*make_fname_decl) (location_t, tree, int);
/* Nonzero means the expression being parsed will never be evaluated.
This is a count, since unevaluated expressions can nest. */
@@ -971,7 +971,7 @@ fname_decl (location_t loc, unsigned int rid, tree id)
input_location = UNKNOWN_LOCATION;
stmts = push_stmt_list ();
- decl = (*make_fname_decl) (id, fname_vars[ix].pretty);
+ decl = (*make_fname_decl) (loc, id, fname_vars[ix].pretty);
stmts = pop_stmt_list (stmts);
if (!IS_EMPTY_STMT (stmts))
saved_function_name_decls
@@ -1505,33 +1505,36 @@ constant_expression_error (tree value)
already overflowed. */
void
-overflow_warning (tree value)
+overflow_warning (location_t loc, tree value)
{
if (skip_evaluation) return;
switch (TREE_CODE (value))
{
case INTEGER_CST:
- warning (OPT_Woverflow, "integer overflow in expression");
+ warning_at (loc, OPT_Woverflow, "integer overflow in expression");
break;
case REAL_CST:
- warning (OPT_Woverflow, "floating point overflow in expression");
+ warning_at (loc, OPT_Woverflow,
+ "floating point overflow in expression");
break;
case FIXED_CST:
- warning (OPT_Woverflow, "fixed-point overflow in expression");
+ warning_at (loc, OPT_Woverflow, "fixed-point overflow in expression");
break;
case VECTOR_CST:
- warning (OPT_Woverflow, "vector overflow in expression");
+ warning_at (loc, OPT_Woverflow, "vector overflow in expression");
break;
case COMPLEX_CST:
if (TREE_CODE (TREE_REALPART (value)) == INTEGER_CST)
- warning (OPT_Woverflow, "complex integer overflow in expression");
+ warning_at (loc, OPT_Woverflow,
+ "complex integer overflow in expression");
else if (TREE_CODE (TREE_REALPART (value)) == REAL_CST)
- warning (OPT_Woverflow, "complex floating point overflow in expression");
+ warning_at (loc, OPT_Woverflow,
+ "complex floating point overflow in expression");
break;
default:
@@ -3224,7 +3227,8 @@ c_register_builtin_type (tree type, const char* name)
{
tree decl;
- decl = build_decl (TYPE_DECL, get_identifier (name), type);
+ decl = build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, get_identifier (name), type);
DECL_ARTIFICIAL (decl) = 1;
if (!TYPE_NAME (type))
TYPE_NAME (type) = decl;
@@ -3799,8 +3803,9 @@ c_common_truthvalue_conversion (location_t location, tree expr)
case ORDERED_EXPR: case UNORDERED_EXPR:
if (TREE_TYPE (expr) == truthvalue_type_node)
return expr;
- return build2 (TREE_CODE (expr), truthvalue_type_node,
+ expr = build2 (TREE_CODE (expr), truthvalue_type_node,
TREE_OPERAND (expr, 0), TREE_OPERAND (expr, 1));
+ goto ret;
case TRUTH_ANDIF_EXPR:
case TRUTH_ORIF_EXPR:
@@ -3809,18 +3814,20 @@ c_common_truthvalue_conversion (location_t location, tree expr)
case TRUTH_XOR_EXPR:
if (TREE_TYPE (expr) == truthvalue_type_node)
return expr;
- return build2 (TREE_CODE (expr), truthvalue_type_node,
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr, 0)),
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr, 1)));
+ expr = build2 (TREE_CODE (expr), truthvalue_type_node,
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr, 0)),
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr, 1)));
+ goto ret;
case TRUTH_NOT_EXPR:
if (TREE_TYPE (expr) == truthvalue_type_node)
return expr;
- return build1 (TREE_CODE (expr), truthvalue_type_node,
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr, 0)));
+ expr = build1 (TREE_CODE (expr), truthvalue_type_node,
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr, 0)));
+ goto ret;
case ERROR_MARK:
return expr;
@@ -3866,14 +3873,17 @@ c_common_truthvalue_conversion (location_t location, tree expr)
}
if (TREE_SIDE_EFFECTS (inner))
- return build2 (COMPOUND_EXPR, truthvalue_type_node,
- inner, truthvalue_true_node);
+ {
+ expr = build2 (COMPOUND_EXPR, truthvalue_type_node,
+ inner, truthvalue_true_node);
+ goto ret;
+ }
else
return truthvalue_true_node;
}
case COMPLEX_EXPR:
- return build_binary_op (EXPR_LOCATION (expr),
+ expr = build_binary_op (EXPR_LOCATION (expr),
(TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1))
? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
c_common_truthvalue_conversion (location,
@@ -3881,6 +3891,7 @@ c_common_truthvalue_conversion (location_t location, tree expr)
c_common_truthvalue_conversion (location,
TREE_OPERAND (expr, 1)),
0);
+ goto ret;
case NEGATE_EXPR:
case ABS_EXPR:
@@ -3894,10 +3905,13 @@ c_common_truthvalue_conversion (location_t location, tree expr)
/* These don't change whether an object is zero or nonzero, but
we can't ignore them if their second arg has side-effects. */
if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
- return build2 (COMPOUND_EXPR, truthvalue_type_node,
- TREE_OPERAND (expr, 1),
- c_common_truthvalue_conversion
- (location, TREE_OPERAND (expr, 0)));
+ {
+ expr = build2 (COMPOUND_EXPR, truthvalue_type_node,
+ TREE_OPERAND (expr, 1),
+ c_common_truthvalue_conversion
+ (location, TREE_OPERAND (expr, 0)));
+ goto ret;
+ }
else
return c_common_truthvalue_conversion (location,
TREE_OPERAND (expr, 0));
@@ -3905,22 +3919,28 @@ c_common_truthvalue_conversion (location_t location, tree expr)
case COND_EXPR:
/* Distribute the conversion into the arms of a COND_EXPR. */
if (c_dialect_cxx ())
- return fold_build3 (COND_EXPR, truthvalue_type_node,
- TREE_OPERAND (expr, 0),
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr,
- 1)),
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr,
- 2)));
+ {
+ expr = fold_build3 (COND_EXPR, truthvalue_type_node,
+ TREE_OPERAND (expr, 0),
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr,
+ 1)),
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr,
+ 2)));
+ goto ret;
+ }
else
- /* Folding will happen later for C. */
- return build3 (COND_EXPR, truthvalue_type_node,
- TREE_OPERAND (expr, 0),
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr, 1)),
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr, 2)));
+ {
+ /* Folding will happen later for C. */
+ expr = build3 (COND_EXPR, truthvalue_type_node,
+ TREE_OPERAND (expr, 0),
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr, 1)),
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr, 2)));
+ goto ret;
+ }
CASE_CONVERT:
/* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
@@ -3952,7 +3972,7 @@ c_common_truthvalue_conversion (location_t location, tree expr)
if (TREE_CODE (TREE_TYPE (expr)) == COMPLEX_TYPE)
{
tree t = c_save_expr (expr);
- return (build_binary_op
+ expr = (build_binary_op
(EXPR_LOCATION (expr),
(TREE_SIDE_EFFECTS (expr)
? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
@@ -3963,6 +3983,7 @@ c_common_truthvalue_conversion (location_t location, tree expr)
(location,
build_unary_op (location, IMAGPART_EXPR, t, 0)),
0));
+ goto ret;
}
if (TREE_CODE (TREE_TYPE (expr)) == FIXED_POINT_TYPE)
@@ -3972,8 +3993,12 @@ c_common_truthvalue_conversion (location_t location, tree expr)
(TREE_TYPE (expr))));
return build_binary_op (location, NE_EXPR, expr, fixed_zero_node, 1);
}
+ else
+ return build_binary_op (location, NE_EXPR, expr, integer_zero_node, 1);
- return build_binary_op (location, NE_EXPR, expr, integer_zero_node, 1);
+ ret:
+ protected_set_expr_location (expr, location);
+ return expr;
}
static void def_builtin_1 (enum built_in_function fncode,
@@ -4214,13 +4239,15 @@ c_common_get_alias_set (tree t)
return -1;
}
-/* Compute the value of 'sizeof (TYPE)' or '__alignof__ (TYPE)', where the
- second parameter indicates which OPERATOR is being applied. The COMPLAIN
- flag controls whether we should diagnose possibly ill-formed
- constructs or not. */
+/* Compute the value of 'sizeof (TYPE)' or '__alignof__ (TYPE)', where
+ the second parameter indicates which OPERATOR is being applied.
+ The COMPLAIN flag controls whether we should diagnose possibly
+ ill-formed constructs or not. LOC is the location of the SIZEOF or
+ TYPEOF operator. */
tree
-c_sizeof_or_alignof_type (tree type, bool is_sizeof, int complain)
+c_sizeof_or_alignof_type (location_t loc,
+ tree type, bool is_sizeof, int complain)
{
const char *op_name;
tree value = NULL;
@@ -4233,7 +4260,7 @@ c_sizeof_or_alignof_type (tree type, bool is_sizeof, int complain)
if (is_sizeof)
{
if (complain && (pedantic || warn_pointer_arith))
- pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
+ pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
"invalid application of %<sizeof%> to a function type");
else if (!complain)
return error_mark_node;
@@ -4246,7 +4273,7 @@ c_sizeof_or_alignof_type (tree type, bool is_sizeof, int complain)
{
if (type_code == VOID_TYPE
&& complain && (pedantic || warn_pointer_arith))
- pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
+ pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
"invalid application of %qs to a void type", op_name);
else if (!complain)
return error_mark_node;
@@ -4255,8 +4282,8 @@ c_sizeof_or_alignof_type (tree type, bool is_sizeof, int complain)
else if (!COMPLETE_TYPE_P (type))
{
if (complain)
- error ("invalid application of %qs to incomplete type %qT ",
- op_name, type);
+ error_at (loc, "invalid application of %qs to incomplete type %qT ",
+ op_name, type);
value = size_zero_node;
}
else
@@ -4283,10 +4310,11 @@ c_sizeof_or_alignof_type (tree type, bool is_sizeof, int complain)
/* Implement the __alignof keyword: Return the minimum required
alignment of EXPR, measured in bytes. For VAR_DECLs,
FUNCTION_DECLs and FIELD_DECLs return DECL_ALIGN (which can be set
- from an "aligned" __attribute__ specification). */
+ from an "aligned" __attribute__ specification). LOC is the
+ location of the ALIGNOF operator. */
tree
-c_alignof_expr (tree expr)
+c_alignof_expr (location_t loc, tree expr)
{
tree t;
@@ -4296,7 +4324,7 @@ c_alignof_expr (tree expr)
else if (TREE_CODE (expr) == COMPONENT_REF
&& DECL_C_BIT_FIELD (TREE_OPERAND (expr, 1)))
{
- error ("%<__alignof%> applied to a bit-field");
+ error_at (loc, "%<__alignof%> applied to a bit-field");
t = size_one_node;
}
else if (TREE_CODE (expr) == COMPONENT_REF
@@ -4319,10 +4347,10 @@ c_alignof_expr (tree expr)
if (thisalign > bestalign)
best = t, bestalign = thisalign;
}
- return c_alignof (TREE_TYPE (TREE_TYPE (best)));
+ return c_alignof (loc, TREE_TYPE (TREE_TYPE (best)));
}
else
- return c_alignof (TREE_TYPE (expr));
+ return c_alignof (loc, TREE_TYPE (expr));
return fold_convert (size_type_node, t);
}
@@ -4570,31 +4598,41 @@ c_common_nodes_and_builtins (void)
/* These are types that c_common_type_for_size and
c_common_type_for_mode use. */
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
intQI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
intHI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
intSI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
intDI_type_node));
#if HOST_BITS_PER_WIDE_INT >= 64
if (targetm.scalar_mode_supported_p (TImode))
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL,
get_identifier ("__int128_t"),
intTI_type_node));
#endif
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
unsigned_intQI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
unsigned_intHI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
unsigned_intSI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
unsigned_intDI_type_node));
#if HOST_BITS_PER_WIDE_INT >= 64
if (targetm.scalar_mode_supported_p (TImode))
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL,
get_identifier ("__uint128_t"),
unsigned_intTI_type_node));
#endif
@@ -4602,12 +4640,14 @@ c_common_nodes_and_builtins (void)
/* Create the widest literal types. */
widest_integer_literal_type_node
= make_signed_type (HOST_BITS_PER_WIDE_INT * 2);
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
widest_integer_literal_type_node));
widest_unsigned_literal_type_node
= make_unsigned_type (HOST_BITS_PER_WIDE_INT * 2);
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
widest_unsigned_literal_type_node));
/* `unsigned long' is the standard type for sizeof.
@@ -4699,17 +4739,21 @@ c_common_nodes_and_builtins (void)
}
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL,
get_identifier ("complex int"),
complex_integer_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL,
get_identifier ("complex float"),
complex_float_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL,
get_identifier ("complex double"),
complex_double_type_node));
lang_hooks.decls.pushdecl
- (build_decl (TYPE_DECL, get_identifier ("complex long double"),
+ (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, get_identifier ("complex long double"),
complex_long_double_type_node));
if (c_dialect_cxx ())
@@ -4903,7 +4947,8 @@ c_common_nodes_and_builtins (void)
unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node);
lang_hooks.decls.pushdecl
- (build_decl (TYPE_DECL, get_identifier ("__builtin_va_list"),
+ (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, get_identifier ("__builtin_va_list"),
va_list_type_node));
#ifdef TARGET_ENUM_VA_LIST
{
@@ -4913,7 +4958,8 @@ c_common_nodes_and_builtins (void)
for (l = 0; TARGET_ENUM_VA_LIST (l, &pname, &ptype); ++l)
{
lang_hooks.decls.pushdecl
- (build_decl (TYPE_DECL, get_identifier (pname),
+ (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, get_identifier (pname),
ptype));
}
@@ -4999,9 +5045,11 @@ set_compound_literal_name (tree decl)
}
tree
-build_va_arg (tree expr, tree type)
+build_va_arg (location_t loc, tree expr, tree type)
{
- return build1 (VA_ARG_EXPR, type, expr);
+ expr = build1 (VA_ARG_EXPR, type, expr);
+ SET_EXPR_LOCATION (expr, loc);
+ return expr;
}
@@ -5183,17 +5231,18 @@ case_compare (splay_tree_key k1, splay_tree_key k2)
return tree_int_cst_compare ((tree) k1, (tree) k2);
}
-/* Process a case label for the range LOW_VALUE ... HIGH_VALUE. If
- LOW_VALUE and HIGH_VALUE are both NULL_TREE then this case label is
- actually a `default' label. If only HIGH_VALUE is NULL_TREE, then
- case label was declared using the usual C/C++ syntax, rather than
- the GNU case range extension. CASES is a tree containing all the
- case ranges processed so far; COND is the condition for the
- switch-statement itself. Returns the CASE_LABEL_EXPR created, or
- ERROR_MARK_NODE if no CASE_LABEL_EXPR is created. */
+/* Process a case label, located at LOC, for the range LOW_VALUE
+ ... HIGH_VALUE. If LOW_VALUE and HIGH_VALUE are both NULL_TREE
+ then this case label is actually a `default' label. If only
+ HIGH_VALUE is NULL_TREE, then case label was declared using the
+ usual C/C++ syntax, rather than the GNU case range extension.
+ CASES is a tree containing all the case ranges processed so far;
+ COND is the condition for the switch-statement itself. Returns the
+ CASE_LABEL_EXPR created, or ERROR_MARK_NODE if no CASE_LABEL_EXPR
+ is created. */
tree
-c_add_case_label (splay_tree cases, tree cond, tree orig_type,
+c_add_case_label (location_t loc, splay_tree cases, tree cond, tree orig_type,
tree low_value, tree high_value)
{
tree type;
@@ -5202,7 +5251,7 @@ c_add_case_label (splay_tree cases, tree cond, tree orig_type,
splay_tree_node node;
/* Create the LABEL_DECL itself. */
- label = create_artificial_label ();
+ label = create_artificial_label (loc);
/* If there was an error processing the switch condition, bail now
before we get more confused. */
@@ -5214,13 +5263,13 @@ c_add_case_label (splay_tree cases, tree cond, tree orig_type,
|| (high_value && TREE_TYPE (high_value)
&& POINTER_TYPE_P (TREE_TYPE (high_value))))
{
- error ("pointers are not permitted as case values");
+ error_at (loc, "pointers are not permitted as case values");
goto error_out;
}
/* Case ranges are a GNU extension. */
if (high_value)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"range expressions in switch statements are non-standard");
type = TREE_TYPE (cond);
@@ -5247,7 +5296,7 @@ c_add_case_label (splay_tree cases, tree cond, tree orig_type,
if (tree_int_cst_equal (low_value, high_value))
high_value = NULL_TREE;
else if (!tree_int_cst_lt (low_value, high_value))
- warning (0, "empty range specified");
+ warning_at (loc, 0, "empty range specified");
}
/* See if the case is in range of the type of the original testing
@@ -5307,24 +5356,26 @@ c_add_case_label (splay_tree cases, tree cond, tree orig_type,
if (high_value)
{
- error ("duplicate (or overlapping) case value");
- error ("%Jthis is the first entry overlapping that value", duplicate);
+ error_at (loc, "duplicate (or overlapping) case value");
+ error_at (DECL_SOURCE_LOCATION (duplicate),
+ "this is the first entry overlapping that value");
}
else if (low_value)
{
- error ("duplicate case value") ;
- error ("%Jpreviously used here", duplicate);
+ error_at (loc, "duplicate case value") ;
+ error_at (DECL_SOURCE_LOCATION (duplicate), "previously used here");
}
else
{
- error ("multiple default labels in one switch");
- error ("%Jthis is the first default label", duplicate);
+ error_at (loc, "multiple default labels in one switch");
+ error_at (DECL_SOURCE_LOCATION (duplicate),
+ "this is the first default label");
}
goto error_out;
}
/* Add a CASE_LABEL to the statement-tree. */
- case_label = add_stmt (build_case_label (low_value, high_value, label));
+ case_label = add_stmt (build_case_label (loc, low_value, high_value, label));
/* Register this case label in the splay tree. */
splay_tree_insert (cases,
(splay_tree_key) low_value,
@@ -5338,8 +5389,8 @@ c_add_case_label (splay_tree cases, tree cond, tree orig_type,
that just leads to duplicates and thence to failure later on. */
if (!cases->root)
{
- tree t = create_artificial_label ();
- add_stmt (build_stmt (LABEL_EXPR, t));
+ tree t = create_artificial_label (loc);
+ add_stmt (build_stmt (loc, LABEL_EXPR, t));
}
return error_mark_node;
}
@@ -8615,13 +8666,15 @@ sync_resolve_return (tree first_param, tree result)
function should be called immediately after parsing the call expression
before surrounding code has committed to the type of the expression.
+ LOC is the location of the builtin call.
+
FUNCTION is the DECL that has been invoked; it is known to be a builtin.
PARAMS is the argument list for the call. The return value is non-null
when expansion is complete, and null if normal processing should
continue. */
tree
-resolve_overloaded_builtin (tree function, VEC(tree,gc) *params)
+resolve_overloaded_builtin (location_t loc, tree function, VEC(tree,gc) *params)
{
enum built_in_function orig_code = DECL_FUNCTION_CODE (function);
switch (DECL_BUILT_IN_CLASS (function))
@@ -8630,7 +8683,7 @@ resolve_overloaded_builtin (tree function, VEC(tree,gc) *params)
break;
case BUILT_IN_MD:
if (targetm.resolve_overloaded_builtin)
- return targetm.resolve_overloaded_builtin (function, params);
+ return targetm.resolve_overloaded_builtin (loc, function, params);
else
return NULL_TREE;
default:
@@ -8668,7 +8721,7 @@ resolve_overloaded_builtin (tree function, VEC(tree,gc) *params)
return error_mark_node;
first_param = VEC_index (tree, params, 0);
- result = build_function_call_vec (new_function, params, NULL);
+ result = build_function_call_vec (loc, new_function, params, NULL);
if (orig_code != BUILT_IN_BOOL_COMPARE_AND_SWAP_N
&& orig_code != BUILT_IN_LOCK_RELEASE_N)
result = sync_resolve_return (first_param, result);
diff --git a/gcc/c-common.h b/gcc/c-common.h
index b17020a027e..eecb1895f84 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -418,7 +418,7 @@ extern void push_cleanup (tree, tree, bool);
extern tree pushdecl_top_level (tree);
extern tree pushdecl (tree);
extern tree build_modify_expr (location_t, tree, tree, enum tree_code,
- tree, tree);
+ location_t, tree, tree);
extern tree build_indirect_ref (location_t, tree, const char *);
extern int c_expand_decl (tree);
@@ -754,7 +754,7 @@ extern const struct attribute_spec c_common_format_attribute_table[];
TYPE_DEP indicates whether it depends on type of the function or not
(i.e. __PRETTY_FUNCTION__). */
-extern tree (*make_fname_decl) (tree, int);
+extern tree (*make_fname_decl) (location_t, tree, int);
extern tree identifier_global_value (tree);
extern void record_builtin_type (enum rid, const char *, tree);
@@ -791,8 +791,8 @@ extern tree decl_constant_value_for_optimization (tree);
extern tree c_save_expr (tree);
extern tree c_common_truthvalue_conversion (location_t, tree);
extern void c_apply_type_quals_to_decl (int, tree);
-extern tree c_sizeof_or_alignof_type (tree, bool, int);
-extern tree c_alignof_expr (tree);
+extern tree c_sizeof_or_alignof_type (location_t, tree, bool, int);
+extern tree c_alignof_expr (location_t, tree);
/* Print an error message for invalid operands to arith operation CODE.
NOP_EXPR is used as a special case (see truthvalue_conversion). */
extern void binary_op_error (location_t, enum tree_code, tree, tree);
@@ -803,7 +803,7 @@ extern void constant_expression_error (tree);
extern bool strict_aliasing_warning (tree, tree, tree);
extern void warnings_for_convert_and_check (tree, tree, tree);
extern tree convert_and_check (tree, tree);
-extern void overflow_warning (tree);
+extern void overflow_warning (location_t, tree);
extern void warn_logical_operator (location_t, enum tree_code, tree,
enum tree_code, tree, enum tree_code, tree);
extern void check_main_parameter_types (tree decl);
@@ -815,8 +815,8 @@ extern void set_float_const_decimal64 (void);
extern void clear_float_const_decimal64 (void);
extern bool float_const_decimal64_p (void);
-#define c_sizeof(T) c_sizeof_or_alignof_type (T, true, 1)
-#define c_alignof(T) c_sizeof_or_alignof_type (T, false, 1)
+#define c_sizeof(LOC, T) c_sizeof_or_alignof_type (LOC, T, true, 1)
+#define c_alignof(LOC, T) c_sizeof_or_alignof_type (LOC, T, false, 1)
/* Subroutine of build_binary_op, used for certain operations. */
extern tree shorten_binary_op (tree result_type, tree op0, tree op1, bool bitwise);
@@ -841,7 +841,7 @@ extern void disable_builtin_function (const char *);
extern void set_compound_literal_name (tree decl);
-extern tree build_va_arg (tree, tree);
+extern tree build_va_arg (location_t, tree, tree);
extern unsigned int c_common_init_options (unsigned int, const char **);
extern bool c_common_post_options (const char **);
@@ -896,9 +896,9 @@ extern void finish_file (void);
#define CLEAR_DECL_C_BIT_FIELD(NODE) \
(DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 0)
-extern tree do_case (tree, tree);
-extern tree build_stmt (enum tree_code, ...);
-extern tree build_case_label (tree, tree, tree);
+extern tree do_case (location_t, tree, tree);
+extern tree build_stmt (location_t, enum tree_code, ...);
+extern tree build_case_label (location_t, tree, tree, tree);
/* These functions must be defined by each front-end which implements
a variant of the C language. They are used in c-common.c. */
@@ -924,15 +924,16 @@ extern tree boolean_increment (enum tree_code, tree);
extern int case_compare (splay_tree_key, splay_tree_key);
-extern tree c_add_case_label (splay_tree, tree, tree, tree, tree);
+extern tree c_add_case_label (location_t, splay_tree, tree, tree, tree, tree);
extern void c_do_switch_warnings (splay_tree, location_t, tree, tree);
-extern tree build_function_call (tree, tree);
+extern tree build_function_call (location_t, tree, tree);
-extern tree build_function_call_vec (tree, VEC(tree,gc) *, VEC(tree,gc) *);
+extern tree build_function_call_vec (location_t, tree,
+ VEC(tree,gc) *, VEC(tree,gc) *);
-extern tree resolve_overloaded_builtin (tree, VEC(tree,gc) *);
+extern tree resolve_overloaded_builtin (location_t, tree, VEC(tree,gc) *);
extern tree finish_label_address_expr (tree, location_t);
@@ -1021,7 +1022,7 @@ extern VEC(tree,gc) *make_tree_vector_copy (const VEC(tree,gc) *);
/* In c-gimplify.c */
extern void c_genericize (tree);
extern int c_gimplify_expr (tree *, gimple_seq *, gimple_seq *);
-extern tree c_build_bind_expr (tree, tree);
+extern tree c_build_bind_expr (location_t, tree, tree);
/* In c-pch.c */
extern void pch_init (void);
@@ -1065,7 +1066,7 @@ extern void objc_declare_class (tree);
extern void objc_declare_protocols (tree);
extern tree objc_build_message_expr (tree);
extern tree objc_finish_message_expr (tree, tree, tree);
-extern tree objc_build_selector_expr (tree);
+extern tree objc_build_selector_expr (location_t, tree);
extern tree objc_build_protocol_expr (tree);
extern tree objc_build_encode_expr (tree);
extern tree objc_build_string_object (tree);
@@ -1089,7 +1090,7 @@ extern void objc_start_method_definition (tree);
extern void objc_finish_method_definition (tree);
extern void objc_add_instance_variable (tree);
extern tree objc_build_keyword_decl (tree, tree, tree);
-extern tree objc_build_throw_stmt (tree);
+extern tree objc_build_throw_stmt (location_t, tree);
extern void objc_begin_try_stmt (location_t, tree);
extern tree objc_finish_try_stmt (void);
extern void objc_begin_catch_clause (tree);
@@ -1113,15 +1114,15 @@ extern void pp_dir_change (cpp_reader *, const char *);
extern bool check_missing_format_attribute (tree, tree);
/* In c-omp.c */
-extern tree c_finish_omp_master (tree);
-extern tree c_finish_omp_critical (tree, tree);
-extern tree c_finish_omp_ordered (tree);
-extern void c_finish_omp_barrier (void);
-extern tree c_finish_omp_atomic (enum tree_code, tree, tree);
-extern void c_finish_omp_flush (void);
-extern void c_finish_omp_taskwait (void);
+extern tree c_finish_omp_master (location_t, tree);
+extern tree c_finish_omp_critical (location_t, tree, tree);
+extern tree c_finish_omp_ordered (location_t, tree);
+extern void c_finish_omp_barrier (location_t);
+extern tree c_finish_omp_atomic (location_t, enum tree_code, tree, tree);
+extern void c_finish_omp_flush (location_t);
+extern void c_finish_omp_taskwait (location_t);
extern tree c_finish_omp_for (location_t, tree, tree, tree, tree, tree, tree);
-extern void c_split_parallel_clauses (tree, tree *, tree *);
+extern void c_split_parallel_clauses (location_t, tree, tree *, tree *);
extern enum omp_clause_default_kind c_omp_predetermined_sharing (tree);
/* Not in c-omp.c; provided by the front end. */
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 9159b3cf6e7..03d6dbd892b 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -443,7 +443,7 @@ static bool next_is_function_body;
/* Forward declarations. */
static tree lookup_name_in_scope (tree, struct c_scope *);
-static tree c_make_fname_decl (tree, int);
+static tree c_make_fname_decl (location_t, tree, int);
static tree grokdeclarator (const struct c_declarator *,
struct c_declspecs *,
enum decl_context, bool, tree *, tree *, tree *,
@@ -584,7 +584,8 @@ c_finish_incomplete_decl (tree decl)
&& !DECL_EXTERNAL (decl)
&& TYPE_DOMAIN (type) == 0)
{
- warning (0, "array %q+D assumed to have one element", decl);
+ warning_at (DECL_SOURCE_LOCATION (decl),
+ 0, "array %q+D assumed to have one element", decl);
complete_array_type (&TREE_TYPE (decl), NULL_TREE, true);
@@ -843,7 +844,8 @@ pop_scope (void)
context = current_function_decl;
else if (scope == file_scope)
{
- tree file_decl = build_decl (TRANSLATION_UNIT_DECL, 0, 0);
+ tree file_decl = build_decl (UNKNOWN_LOCATION,
+ TRANSLATION_UNIT_DECL, 0, 0);
TREE_CHAIN (file_decl) = all_translation_units;
all_translation_units = file_decl;
context = file_decl;
@@ -1089,13 +1091,14 @@ pop_file_scope (void)
/* Push a definition or a declaration of struct, union or enum tag "name".
"type" should be the type node.
- We assume that the tag "name" is not already defined.
+ We assume that the tag "name" is not already defined, and has a location
+ of LOC.
Note that the definition may really be just a forward reference.
In that case, the TYPE_SIZE will be zero. */
static void
-pushtag (tree name, tree type, location_t loc)
+pushtag (location_t loc, tree name, tree type)
{
/* Record the identifier as the type's name if it has none. */
if (name && !TYPE_NAME (type))
@@ -1109,7 +1112,8 @@ pushtag (tree name, tree type, location_t loc)
us a convenient place to record the "scope start" address for the
tagged type. */
- TYPE_STUB_DECL (type) = pushdecl (build_decl (TYPE_DECL, NULL_TREE, type));
+ TYPE_STUB_DECL (type) = pushdecl (build_decl (loc,
+ TYPE_DECL, NULL_TREE, type));
/* An approximation for now, so we can tell this is a function-scope tag.
This will be updated in pop_scope. */
@@ -2457,11 +2461,11 @@ implicit_decl_warning (tree id, tree olddecl)
}
}
-/* Generate an implicit declaration for identifier FUNCTIONID as a
+/* Generate an implicit declaration for identifier FUNCTIONID at LOC as a
function of type int (). */
tree
-implicitly_declare (tree functionid)
+implicitly_declare (location_t loc, tree functionid)
{
struct c_binding *b;
tree decl = 0;
@@ -2514,8 +2518,8 @@ implicitly_declare (tree functionid)
(TREE_TYPE (decl)));
if (!comptypes (newtype, TREE_TYPE (decl)))
{
- warning (0, "incompatible implicit declaration of built-in"
- " function %qD", decl);
+ warning_at (loc, 0, "incompatible implicit declaration of "
+ "built-in function %qD", decl);
newtype = TREE_TYPE (decl);
}
}
@@ -2523,8 +2527,7 @@ implicitly_declare (tree functionid)
{
if (!comptypes (newtype, TREE_TYPE (decl)))
{
- error ("incompatible implicit declaration of function %qD",
- decl);
+ error_at (loc, "incompatible implicit declaration of function %qD", decl);
locate_old_decl (decl);
}
}
@@ -2538,7 +2541,7 @@ implicitly_declare (tree functionid)
}
/* Not seen before. */
- decl = build_decl (FUNCTION_DECL, functionid, default_function_type);
+ decl = build_decl (loc, FUNCTION_DECL, functionid, default_function_type);
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
C_DECL_IMPLICIT (decl) = 1;
@@ -2570,7 +2573,7 @@ implicitly_declare (tree functionid)
in an appropriate scope, which will suppress further errors for the
same identifier. The error message should be given location LOC. */
void
-undeclared_variable (tree id, location_t loc)
+undeclared_variable (location_t loc, tree id)
{
static bool already = false;
struct c_scope *scope;
@@ -2603,13 +2606,12 @@ undeclared_variable (tree id, location_t loc)
LABEL_DECL with all the proper frills. */
static tree
-make_label (tree name, location_t location)
+make_label (location_t location, tree name)
{
- tree label = build_decl (LABEL_DECL, name, void_type_node);
+ tree label = build_decl (location, LABEL_DECL, name, void_type_node);
DECL_CONTEXT (label) = current_function_decl;
DECL_MODE (label) = VOIDmode;
- DECL_SOURCE_LOCATION (label) = location;
return label;
}
@@ -2646,7 +2648,7 @@ lookup_label (tree name)
}
/* No label binding for that identifier; make one. */
- label = make_label (name, input_location);
+ label = make_label (input_location, name);
/* Ordinary labels go in the current function scope. */
bind (name, label, current_function_scope,
@@ -2675,7 +2677,7 @@ declare_label (tree name)
return b->decl;
}
- label = make_label (name, input_location);
+ label = make_label (input_location, name);
C_DECLARED_LABEL_FLAG (label) = 1;
/* Declared labels go in the current scope. */
@@ -2704,7 +2706,7 @@ define_label (location_t location, tree name)
|| (DECL_CONTEXT (label) != current_function_decl
&& C_DECLARED_LABEL_FLAG (label))))
{
- error ("%Hduplicate label %qD", &location, label);
+ error_at (location, "duplicate label %qD", label);
locate_old_decl (label);
return 0;
}
@@ -2714,16 +2716,16 @@ define_label (location_t location, tree name)
but not defined. Update its location to point to this
definition. */
if (C_DECL_UNDEFINABLE_STMT_EXPR (label))
- error ("%Jjump into statement expression", label);
+ error_at (location, "jump into statement expression");
if (C_DECL_UNDEFINABLE_VM (label))
- error ("%Jjump into scope of identifier with variably modified type",
- label);
+ error_at (location,
+ "jump into scope of identifier with variably modified type");
DECL_SOURCE_LOCATION (label) = location;
}
else
{
/* No label binding for that identifier; make one. */
- label = make_label (name, location);
+ label = make_label (location, name);
/* Ordinary labels go in the current function scope. */
bind (name, label, current_function_scope,
@@ -2731,8 +2733,9 @@ define_label (location_t location, tree name)
}
if (!in_system_header && lookup_name (name))
- warning (OPT_Wtraditional, "%Htraditional C lacks a separate namespace "
- "for labels, identifier %qE conflicts", &location, name);
+ warning_at (location, OPT_Wtraditional,
+ "traditional C lacks a separate namespace "
+ "for labels, identifier %qE conflicts", name);
nlist_se = XOBNEW (&parser_obstack, struct c_label_list);
nlist_se->next = label_context_stack_se->labels_def;
@@ -2882,7 +2885,7 @@ c_init_decl_processing (void)
truthvalue_false_node = integer_zero_node;
/* Even in C99, which has a real boolean type. */
- pushdecl (build_decl (TYPE_DECL, get_identifier ("_Bool"),
+ pushdecl (build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier ("_Bool"),
boolean_type_node));
input_location = save_loc;
@@ -2893,15 +2896,16 @@ c_init_decl_processing (void)
start_fname_decls ();
}
-/* Create the VAR_DECL for __FUNCTION__ etc. ID is the name to give the
- decl, NAME is the initialization string and TYPE_DEP indicates whether
- NAME depended on the type of the function. As we don't yet implement
- delayed emission of static data, we mark the decl as emitted
- so it is not placed in the output. Anything using it must therefore pull
- out the STRING_CST initializer directly. FIXME. */
+/* Create the VAR_DECL at LOC for __FUNCTION__ etc. ID is the name to
+ give the decl, NAME is the initialization string and TYPE_DEP
+ indicates whether NAME depended on the type of the function. As we
+ don't yet implement delayed emission of static data, we mark the
+ decl as emitted so it is not placed in the output. Anything using
+ it must therefore pull out the STRING_CST initializer directly.
+ FIXME. */
static tree
-c_make_fname_decl (tree id, int type_dep)
+c_make_fname_decl (location_t loc, tree id, int type_dep)
{
const char *name = fname_as_string (type_dep);
tree decl, type, init;
@@ -2911,7 +2915,7 @@ c_make_fname_decl (tree id, int type_dep)
build_index_type (size_int (length)));
type = c_build_qualified_type (type, TYPE_QUAL_CONST);
- decl = build_decl (VAR_DECL, id, type);
+ decl = build_decl (loc, VAR_DECL, id, type);
TREE_STATIC (decl) = 1;
TREE_READONLY (decl) = 1;
@@ -2940,7 +2944,7 @@ c_make_fname_decl (tree id, int type_dep)
/*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION);
}
- finish_decl (decl, init, NULL_TREE, NULL_TREE);
+ finish_decl (decl, loc, init, NULL_TREE, NULL_TREE);
return decl;
}
@@ -3078,7 +3082,7 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
if (t == 0)
{
t = make_node (code);
- pushtag (name, t, input_location);
+ pushtag (input_location, name, t);
}
}
}
@@ -3174,21 +3178,24 @@ quals_from_declspecs (const struct c_declspecs *specs)
return quals;
}
-/* Construct an array declarator. EXPR is the expression inside [],
- or NULL_TREE. QUALS are the type qualifiers inside the [] (to be
- applied to the pointer to which a parameter array is converted).
- STATIC_P is true if "static" is inside the [], false otherwise.
- VLA_UNSPEC_P is true if the array is [*], a VLA of unspecified
- length which is nevertheless a complete type, false otherwise. The
- field for the contained declarator is left to be filled in by
- set_array_declarator_inner. */
+/* Construct an array declarator. LOC is the location of the
+ beginning of the array (usually the opening brace). EXPR is the
+ expression inside [], or NULL_TREE. QUALS are the type qualifiers
+ inside the [] (to be applied to the pointer to which a parameter
+ array is converted). STATIC_P is true if "static" is inside the
+ [], false otherwise. VLA_UNSPEC_P is true if the array is [*], a
+ VLA of unspecified length which is nevertheless a complete type,
+ false otherwise. The field for the contained declarator is left to
+ be filled in by set_array_declarator_inner. */
struct c_declarator *
-build_array_declarator (tree expr, struct c_declspecs *quals, bool static_p,
+build_array_declarator (location_t loc,
+ tree expr, struct c_declspecs *quals, bool static_p,
bool vla_unspec_p)
{
struct c_declarator *declarator = XOBNEW (&parser_obstack,
struct c_declarator);
+ declarator->id_loc = loc;
declarator->kind = cdk_array;
declarator->declarator = 0;
declarator->u.array.dimen = expr;
@@ -3207,11 +3214,11 @@ build_array_declarator (tree expr, struct c_declspecs *quals, bool static_p,
if (!flag_isoc99)
{
if (static_p || quals != NULL)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C90 does not support %<static%> or type "
"qualifiers in parameter array declarators");
if (vla_unspec_p)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C90 does not support %<[*]%> array declarators");
}
if (vla_unspec_p)
@@ -3219,7 +3226,8 @@ build_array_declarator (tree expr, struct c_declspecs *quals, bool static_p,
if (!current_scope->parm_flag)
{
/* C99 6.7.5.2p4 */
- error ("%<[*]%> not allowed in other than function prototype scope");
+ error_at (loc, "%<[*]%> not allowed in other than "
+ "function prototype scope");
declarator->u.array.vla_unspec_p = false;
return NULL;
}
@@ -3514,10 +3522,13 @@ c_maybe_initialize_eh (void)
install its initial value.
If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
If the length of an array type is not known before,
- it must be determined now, from the initial value, or it is an error. */
+ it must be determined now, from the initial value, or it is an error.
+
+ INIT_LOC is the location of the initial value. */
void
-finish_decl (tree decl, tree init, tree origtype, tree asmspec_tree)
+finish_decl (tree decl, location_t init_loc, tree init,
+ tree origtype, tree asmspec_tree)
{
tree type;
bool was_incomplete = (DECL_SIZE (decl) == 0);
@@ -3539,7 +3550,7 @@ finish_decl (tree decl, tree init, tree origtype, tree asmspec_tree)
init = 0;
if (init)
- store_init_value (decl, init, origtype);
+ store_init_value (init_loc, decl, init, origtype);
if (c_dialect_objc () && (TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == FUNCTION_DECL
@@ -3747,7 +3758,8 @@ finish_decl (tree decl, tree init, tree origtype, tree asmspec_tree)
add_stmt (bind);
BIND_EXPR_BODY (bind) = push_stmt_list ();
}
- add_stmt (build_stmt (DECL_EXPR, decl));
+ add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl),
+ DECL_EXPR, decl));
}
}
@@ -3772,7 +3784,7 @@ finish_decl (tree decl, tree init, tree origtype, tree asmspec_tree)
{
if (!DECL_FILE_SCOPE_P (decl)
&& variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
- add_stmt (build_stmt (DECL_EXPR, decl));
+ add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
rest_of_decl_compilation (decl, DECL_FILE_SCOPE_P (decl), 0);
}
@@ -3798,7 +3810,8 @@ finish_decl (tree decl, tree init, tree origtype, tree asmspec_tree)
cleanup = build_unary_op (input_location, ADDR_EXPR, decl, 0);
vec = VEC_alloc (tree, gc, 1);
VEC_quick_push (tree, vec, cleanup);
- cleanup = build_function_call_vec (cleanup_decl, vec, NULL);
+ cleanup = build_function_call_vec (DECL_SOURCE_LOCATION (decl),
+ cleanup_decl, vec, NULL);
VEC_free (tree, gc, vec);
/* Don't warn about decl unused; the cleanup uses it. */
@@ -3842,7 +3855,7 @@ push_parm_decl (const struct c_parm *parm)
decl = pushdecl (decl);
- finish_decl (decl, NULL_TREE, NULL_TREE, NULL_TREE);
+ finish_decl (decl, input_location, NULL_TREE, NULL_TREE, NULL_TREE);
}
/* Mark all the parameter declarations to date as forward decls.
@@ -3867,12 +3880,12 @@ mark_forward_parm_decls (void)
/* Build a COMPOUND_LITERAL_EXPR. TYPE is the type given in the compound
literal, which may be an incomplete array type completed by the
- initializer; INIT is a CONSTRUCTOR that initializes the compound
+ initializer; INIT is a CONSTRUCTOR at LOC that initializes the compound
literal. NON_CONST is true if the initializers contain something
that cannot occur in a constant expression. */
tree
-build_compound_literal (tree type, tree init, bool non_const)
+build_compound_literal (location_t loc, tree type, tree init, bool non_const)
{
/* We do not use start_decl here because we have a type, not a declarator;
and do not use finish_decl because the decl should be stored inside
@@ -3884,7 +3897,7 @@ build_compound_literal (tree type, tree init, bool non_const)
if (type == error_mark_node)
return error_mark_node;
- decl = build_decl (VAR_DECL, NULL_TREE, type);
+ decl = build_decl (loc, VAR_DECL, NULL_TREE, type);
DECL_EXTERNAL (decl) = 0;
TREE_PUBLIC (decl) = 0;
TREE_STATIC (decl) = (current_scope == file_scope);
@@ -3892,7 +3905,7 @@ build_compound_literal (tree type, tree init, bool non_const)
TREE_USED (decl) = 1;
TREE_TYPE (decl) = type;
TREE_READONLY (decl) = TYPE_READONLY (type);
- store_init_value (decl, init, NULL_TREE);
+ store_init_value (loc, decl, init, NULL_TREE);
if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
{
@@ -3907,7 +3920,7 @@ build_compound_literal (tree type, tree init, bool non_const)
if (type == error_mark_node || !COMPLETE_TYPE_P (type))
return error_mark_node;
- stmt = build_stmt (DECL_EXPR, decl);
+ stmt = build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl);
complit = build1 (COMPOUND_LITERAL_EXPR, type, stmt);
TREE_SIDE_EFFECTS (complit) = 1;
@@ -3938,7 +3951,7 @@ build_compound_literal (tree type, tree init, bool non_const)
is valid for C++. */
void
-check_compound_literal_type (struct c_type_name *type_name, location_t loc)
+check_compound_literal_type (location_t loc, struct c_type_name *type_name)
{
if (warn_cxx_compat && type_name->specs->tag_defined_p)
warning_at (loc, OPT_Wc___compat,
@@ -4202,6 +4215,7 @@ grokdeclarator (const struct c_declarator *declarator,
bool bitfield = width != NULL;
tree element_type;
struct c_arg_info *arg_info = 0;
+ location_t loc = UNKNOWN_LOCATION;
const char *errmsg;
tree expr_dummy;
bool expr_const_operands_dummy;
@@ -4225,8 +4239,11 @@ grokdeclarator (const struct c_declarator *declarator,
while (decl)
switch (decl->kind)
{
- case cdk_function:
case cdk_array:
+ loc = decl->id_loc;
+ /* FALL THRU. */
+
+ case cdk_function:
case cdk_pointer:
funcdef_syntax = (decl->kind == cdk_function);
decl = decl->declarator;
@@ -4237,6 +4254,7 @@ grokdeclarator (const struct c_declarator *declarator,
break;
case cdk_id:
+ loc = decl->id_loc;
if (decl->u.id)
name = decl->u.id;
decl = 0;
@@ -4275,9 +4293,9 @@ grokdeclarator (const struct c_declarator *declarator,
&& variably_modified_type_p (type, NULL_TREE))
{
if (name)
- error ("variably modified %qE at file scope", name);
+ error_at (loc, "variably modified %qE at file scope", name);
else
- error ("variably modified field at file scope");
+ error_at (loc, "variably modified field at file scope");
type = integer_type_node;
}
@@ -4296,7 +4314,7 @@ grokdeclarator (const struct c_declarator *declarator,
else
{
if (name)
- pedwarn_c99 (input_location, flag_isoc99 ? 0 : OPT_Wimplicit_int,
+ pedwarn_c99 (loc, flag_isoc99 ? 0 : OPT_Wimplicit_int,
"type defaults to %<int%> in declaration of %qE",
name);
else
@@ -4330,11 +4348,11 @@ grokdeclarator (const struct c_declarator *declarator,
if (pedantic && !flag_isoc99)
{
if (constp > 1)
- pedwarn (input_location, OPT_pedantic, "duplicate %<const%>");
+ pedwarn (loc, OPT_pedantic, "duplicate %<const%>");
if (restrictp > 1)
- pedwarn (input_location, OPT_pedantic, "duplicate %<restrict%>");
+ pedwarn (loc, OPT_pedantic, "duplicate %<restrict%>");
if (volatilep > 1)
- pedwarn (input_location, OPT_pedantic, "duplicate %<volatile%>");
+ pedwarn (loc, OPT_pedantic, "duplicate %<volatile%>");
}
if (!flag_gen_aux_info && (TYPE_QUALS (element_type)))
type = TYPE_MAIN_VARIANT (type);
@@ -4352,15 +4370,15 @@ grokdeclarator (const struct c_declarator *declarator,
|| storage_class == csc_typedef))
{
if (storage_class == csc_auto)
- pedwarn (input_location,
+ pedwarn (loc,
(current_scope == file_scope) ? 0 : OPT_pedantic,
"function definition declared %<auto%>");
if (storage_class == csc_register)
- error ("function definition declared %<register%>");
+ error_at (loc, "function definition declared %<register%>");
if (storage_class == csc_typedef)
- error ("function definition declared %<typedef%>");
+ error_at (loc, "function definition declared %<typedef%>");
if (threadp)
- error ("function definition declared %<__thread%>");
+ error_at (loc, "function definition declared %<__thread%>");
threadp = false;
if (storage_class == csc_auto
|| storage_class == csc_register
@@ -4377,19 +4395,20 @@ grokdeclarator (const struct c_declarator *declarator,
{
case FIELD:
if (name)
- error ("storage class specified for structure field %qE",
- name);
+ error_at (loc, "storage class specified for structure "
+ "field %qE", name);
else
- error ("storage class specified for structure field");
+ error_at (loc, "storage class specified for structure field");
break;
case PARM:
if (name)
- error ("storage class specified for parameter %qE", name);
+ error_at (loc, "storage class specified for parameter %qE",
+ name);
else
- error ("storage class specified for unnamed parameter");
+ error_at (loc, "storage class specified for unnamed parameter");
break;
default:
- error ("storage class specified for typename");
+ error_at (loc, "storage class specified for typename");
break;
}
storage_class = csc_none;
@@ -4406,15 +4425,17 @@ grokdeclarator (const struct c_declarator *declarator,
/* It is fine to have 'extern const' when compiling at C
and C++ intersection. */
if (!(warn_cxx_compat && constp))
- warning (0, "%qE initialized and declared %<extern%>", name);
+ warning_at (loc, 0, "%qE initialized and declared %<extern%>",
+ name);
}
else
- error ("%qE has both %<extern%> and initializer", name);
+ error_at (loc, "%qE has both %<extern%> and initializer", name);
}
else if (current_scope == file_scope)
{
if (storage_class == csc_auto)
- error ("file-scope declaration of %qE specifies %<auto%>", name);
+ error_at (loc, "file-scope declaration of %qE specifies %<auto%>",
+ name);
if (pedantic && storage_class == csc_register)
pedwarn (input_location, OPT_pedantic,
"file-scope declaration of %qE specifies %<register%>", name);
@@ -4422,12 +4443,12 @@ grokdeclarator (const struct c_declarator *declarator,
else
{
if (storage_class == csc_extern && funcdef_flag)
- error ("nested function %qE declared %<extern%>", name);
+ error_at (loc, "nested function %qE declared %<extern%>", name);
else if (threadp && storage_class == csc_none)
{
- error ("function-scope %qE implicitly auto and declared "
- "%<__thread%>",
- name);
+ error_at (loc, "function-scope %qE implicitly auto and declared "
+ "%<__thread%>",
+ name);
threadp = false;
}
}
@@ -4472,7 +4493,7 @@ grokdeclarator (const struct c_declarator *declarator,
/* Only the innermost declarator (making a parameter be of
array type which is converted to pointer type)
may have static or type qualifiers. */
- error ("static or type qualifiers in non-parameter array declarator");
+ error_at (loc, "static or type qualifiers in non-parameter array declarator");
array_ptr_quals = TYPE_UNQUALIFIED;
array_ptr_attrs = NULL_TREE;
array_parm_static = 0;
@@ -4520,23 +4541,25 @@ grokdeclarator (const struct c_declarator *declarator,
if (VOID_TYPE_P (type))
{
if (name)
- error ("declaration of %qE as array of voids", name);
+ error_at (loc, "declaration of %qE as array of voids", name);
else
- error ("declaration of type name as array of voids");
+ error_at (loc, "declaration of type name as array of voids");
type = error_mark_node;
}
if (TREE_CODE (type) == FUNCTION_TYPE)
{
if (name)
- error ("declaration of %qE as array of functions", name);
+ error_at (loc, "declaration of %qE as array of functions",
+ name);
else
- error ("declaration of type name as array of functions");
+ error_at (loc, "declaration of type name as array of "
+ "functions");
type = error_mark_node;
}
if (pedantic && !in_system_header && flexible_array_type_p (type))
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"invalid use of structure with flexible array member");
if (size == error_mark_node)
@@ -4563,9 +4586,11 @@ grokdeclarator (const struct c_declarator *declarator,
if (!INTEGRAL_TYPE_P (TREE_TYPE (size)))
{
if (name)
- error ("size of array %qE has non-integer type", name);
+ error_at (loc, "size of array %qE has non-integer type",
+ name);
else
- error ("size of unnamed array has non-integer type");
+ error_at (loc,
+ "size of unnamed array has non-integer type");
size = integer_one_node;
}
@@ -4574,10 +4599,10 @@ grokdeclarator (const struct c_declarator *declarator,
if (pedantic && size_maybe_const && integer_zerop (size))
{
if (name)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids zero-size array %qE", name);
else
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids zero-size array");
}
@@ -4587,9 +4612,9 @@ grokdeclarator (const struct c_declarator *declarator,
if (tree_int_cst_sgn (size) < 0)
{
if (name)
- error ("size of array %qE is negative", name);
+ error_at (loc, "size of array %qE is negative", name);
else
- error ("size of unnamed array is negative");
+ error_at (loc, "size of unnamed array is negative");
size = integer_one_node;
}
/* Handle a size folded to an integer constant but
@@ -4614,7 +4639,7 @@ grokdeclarator (const struct c_declarator *declarator,
else if ((decl_context == NORMAL || decl_context == FIELD)
&& current_scope == file_scope)
{
- error ("variably modified %qE at file scope", name);
+ error_at (loc, "variably modified %qE at file scope", name);
size = integer_one_node;
}
else
@@ -4665,9 +4690,10 @@ grokdeclarator (const struct c_declarator *declarator,
&& TREE_OVERFLOW (itype))
{
if (name)
- error ("size of array %qE is too large", name);
+ error_at (loc, "size of array %qE is too large",
+ name);
else
- error ("size of unnamed array is too large");
+ error_at (loc, "size of unnamed array is too large");
type = error_mark_node;
continue;
}
@@ -4703,7 +4729,7 @@ grokdeclarator (const struct c_declarator *declarator,
}
if (flexible_array_member
&& pedantic && !flag_isoc99 && !in_system_header)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C90 does not support flexible array members");
/* ISO C99 Flexible array members are effectively
@@ -4738,7 +4764,7 @@ grokdeclarator (const struct c_declarator *declarator,
/* Complain about arrays of incomplete types. */
if (!COMPLETE_TYPE_P (type))
{
- error ("array type has incomplete element type");
+ error_at (loc, "array type has incomplete element type");
type = error_mark_node;
}
else
@@ -4788,7 +4814,7 @@ grokdeclarator (const struct c_declarator *declarator,
|| array_ptr_attrs != NULL_TREE
|| array_parm_static))
{
- error ("static or type qualifiers in non-parameter array declarator");
+ error_at (loc, "static or type qualifiers in non-parameter array declarator");
array_ptr_quals = TYPE_UNQUALIFIED;
array_ptr_attrs = NULL_TREE;
array_parm_static = 0;
@@ -4821,19 +4847,21 @@ grokdeclarator (const struct c_declarator *declarator,
if (TREE_CODE (type) == FUNCTION_TYPE)
{
if (name)
- error ("%qE declared as function returning a function",
- name);
+ error_at (loc, "%qE declared as function returning a "
+ "function", name);
else
- error ("type name declared as function "
- "returning a function");
+ error_at (loc, "type name declared as function "
+ "returning a function");
type = integer_type_node;
}
if (TREE_CODE (type) == ARRAY_TYPE)
{
if (name)
- error ("%qE declared as function returning an array", name);
+ error_at (loc, "%qE declared as function returning an array",
+ name);
else
- error ("type name declared as function returning an array");
+ error_at (loc, "type name declared as function returning "
+ "an array");
type = integer_type_node;
}
errmsg = targetm.invalid_return_type (type);
@@ -4861,10 +4889,10 @@ grokdeclarator (const struct c_declarator *declarator,
function definitions in ISO C; GCC used to used
them for noreturn functions. */
if (VOID_TYPE_P (type) && really_funcdef)
- pedwarn (input_location, 0,
+ pedwarn (loc, 0,
"function definition has qualified void return type");
else
- warning (OPT_Wignored_qualifiers,
+ warning_at (loc, OPT_Wignored_qualifiers,
"type qualifiers ignored on function return type");
type = c_build_qualified_type (type, type_quals);
@@ -4894,7 +4922,7 @@ grokdeclarator (const struct c_declarator *declarator,
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
&& type_quals)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids qualified function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
@@ -4927,10 +4955,10 @@ grokdeclarator (const struct c_declarator *declarator,
&& (decl_context == NORMAL || decl_context == FIELD)
&& variably_modified_type_p (type, NULL_TREE))
{
- tree decl = build_decl (TYPE_DECL, NULL_TREE, type);
+ tree decl = build_decl (loc, TYPE_DECL, NULL_TREE, type);
DECL_ARTIFICIAL (decl) = 1;
pushdecl (decl);
- finish_decl (decl, NULL_TREE, NULL_TREE, NULL_TREE);
+ finish_decl (decl, loc, NULL_TREE, NULL_TREE, NULL_TREE);
TYPE_NAME (type) = decl;
}
@@ -4964,9 +4992,9 @@ grokdeclarator (const struct c_declarator *declarator,
&& TREE_OVERFLOW (TYPE_SIZE_UNIT (type)))
{
if (name)
- error ("size of array %qE is too large", name);
+ error_at (loc, "size of array %qE is too large", name);
else
- error ("size of unnamed array is too large");
+ error_at (loc, "size of unnamed array is too large");
/* If we proceed with the array type as it is, we'll eventually
crash in tree_low_cst(). */
type = error_mark_node;
@@ -4979,16 +5007,16 @@ grokdeclarator (const struct c_declarator *declarator,
tree decl;
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
&& type_quals)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids qualified function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
- decl = build_decl (TYPE_DECL, declarator->u.id, type);
- DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
+ decl = build_decl (declarator->id_loc,
+ TYPE_DECL, declarator->u.id, type);
if (declspecs->explicit_signed_p)
C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
if (declspecs->inline_p)
- pedwarn (input_location, 0,"typedef %q+D declared %<inline%>", decl);
+ pedwarn (loc, 0,"typedef %q+D declared %<inline%>", decl);
if (warn_cxx_compat && declarator->u.id != NULL_TREE)
{
@@ -5023,7 +5051,7 @@ grokdeclarator (const struct c_declarator *declarator,
&& !declspecs->inline_p);
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
&& type_quals)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids const or volatile function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
@@ -5034,8 +5062,8 @@ grokdeclarator (const struct c_declarator *declarator,
&& variably_modified_type_p (type, NULL_TREE))
{
/* C99 6.7.2.1p8 */
- pedwarn (input_location, OPT_pedantic,
- "a member of a structure or union cannot have a variably modified type");
+ pedwarn (loc, OPT_pedantic, "a member of a structure or union cannot "
+ "have a variably modified type");
}
/* Aside from typedefs and type names (handle above),
@@ -5051,7 +5079,7 @@ grokdeclarator (const struct c_declarator *declarator,
&& !(storage_class == csc_static
|| storage_class == csc_register)))))
{
- error ("variable or field %qE declared void", name);
+ error_at (loc, "variable or field %qE declared void", name);
type = integer_type_node;
}
@@ -5081,15 +5109,15 @@ grokdeclarator (const struct c_declarator *declarator,
/* We don't yet implement attributes in this context. */
if (array_ptr_attrs != NULL_TREE)
- warning (OPT_Wattributes,
- "attributes in parameter array declarator ignored");
+ warning_at (loc, OPT_Wattributes,
+ "attributes in parameter array declarator ignored");
size_varies = 0;
}
else if (TREE_CODE (type) == FUNCTION_TYPE)
{
if (type_quals)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids qualified function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
@@ -5099,8 +5127,8 @@ grokdeclarator (const struct c_declarator *declarator,
else if (type_quals)
type = c_build_qualified_type (type, type_quals);
- decl = build_decl (PARM_DECL, declarator->u.id, type);
- DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
+ decl = build_decl (declarator->id_loc,
+ PARM_DECL, declarator->u.id, type);
if (size_varies)
C_DECL_VARIABLE_SIZE (decl) = 1;
@@ -5116,7 +5144,7 @@ grokdeclarator (const struct c_declarator *declarator,
DECL_ARG_TYPE (decl) = promoted_type;
if (declspecs->inline_p)
- pedwarn (input_location, 0, "parameter %q+D declared %<inline%>", decl);
+ pedwarn (loc, 0, "parameter %q+D declared %<inline%>", decl);
}
else if (decl_context == FIELD)
{
@@ -5129,21 +5157,21 @@ grokdeclarator (const struct c_declarator *declarator,
if (TREE_CODE (type) == FUNCTION_TYPE)
{
- error ("field %qE declared as a function", name);
+ error_at (loc, "field %qE declared as a function", name);
type = build_pointer_type (type);
}
else if (TREE_CODE (type) != ERROR_MARK
&& !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type))
{
if (name)
- error ("field %qE has incomplete type", name);
+ error_at (loc, "field %qE has incomplete type", name);
else
- error ("unnamed field has incomplete type");
+ error_at (loc, "unnamed field has incomplete type");
type = error_mark_node;
}
type = c_build_qualified_type (type, type_quals);
- decl = build_decl (FIELD_DECL, declarator->u.id, type);
- DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
+ decl = build_decl (declarator->id_loc,
+ FIELD_DECL, declarator->u.id, type);
DECL_NONADDRESSABLE_P (decl) = bitfield;
if (bitfield && !declarator->u.id)
TREE_NO_WARNING (decl) = 1;
@@ -5155,7 +5183,7 @@ grokdeclarator (const struct c_declarator *declarator,
{
if (storage_class == csc_register || threadp)
{
- error ("invalid storage class for function %qE", name);
+ error_at (loc, "invalid storage class for function %qE", name);
}
else if (current_scope != file_scope)
{
@@ -5165,11 +5193,11 @@ grokdeclarator (const struct c_declarator *declarator,
GCC allows 'auto', perhaps with 'inline', to support
nested functions. */
if (storage_class == csc_auto)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"invalid storage class for function %qE", name);
else if (storage_class == csc_static)
{
- error ("invalid storage class for function %qE", name);
+ error_at (loc, "invalid storage class for function %qE", name);
if (funcdef_flag)
storage_class = declspecs->storage_class = csc_none;
else
@@ -5177,19 +5205,19 @@ grokdeclarator (const struct c_declarator *declarator,
}
}
- decl = build_decl (FUNCTION_DECL, declarator->u.id, type);
- DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
+ decl = build_decl (declarator->id_loc,
+ FUNCTION_DECL, declarator->u.id, type);
decl = build_decl_attribute_variant (decl, decl_attr);
if (pedantic && type_quals && !DECL_IN_SYSTEM_HEADER (decl))
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids qualified function types");
/* GNU C interprets a volatile-qualified function type to indicate
that the function does not return. */
if ((type_quals & TYPE_QUAL_VOLATILE)
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
- warning (0, "%<noreturn%> function returns non-void value");
+ warning_at (loc, 0, "%<noreturn%> function returns non-void value");
/* Every function declaration is an external reference
(DECL_EXTERNAL) except for those which are not at file
@@ -5225,7 +5253,7 @@ grokdeclarator (const struct c_declarator *declarator,
if (flag_hosted && MAIN_NAME_P (declarator->u.id))
{
if (declspecs->inline_p)
- pedwarn (input_location, 0, "cannot inline function %<main%>");
+ pedwarn (loc, 0, "cannot inline function %<main%>");
}
else if (declspecs->inline_p)
/* Record that the function is declared `inline'. */
@@ -5254,17 +5282,17 @@ grokdeclarator (const struct c_declarator *declarator,
&& global_decl != visible_decl
&& TREE_CODE (global_decl) == VAR_DECL
&& !TREE_PUBLIC (global_decl))
- error ("variable previously declared %<static%> redeclared "
- "%<extern%>");
+ error_at (loc, "variable previously declared %<static%> "
+ "redeclared %<extern%>");
}
- decl = build_decl (VAR_DECL, declarator->u.id, type);
- DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
+ decl = build_decl (declarator->id_loc,
+ VAR_DECL, declarator->u.id, type);
if (size_varies)
C_DECL_VARIABLE_SIZE (decl) = 1;
if (declspecs->inline_p)
- pedwarn (input_location, 0, "variable %q+D declared %<inline%>", decl);
+ pedwarn (loc, 0, "variable %q+D declared %<inline%>", decl);
/* At file scope, an initialized extern declaration may follow
a static declaration. In that case, DECL_EXTERNAL will be
@@ -5299,9 +5327,10 @@ grokdeclarator (const struct c_declarator *declarator,
{
/* C99 6.7.5.2p2 */
if (TREE_CODE (type) == FUNCTION_TYPE)
- error ("non-nested function with variably modified type");
+ error_at (loc, "non-nested function with variably modified type");
else
- error ("object with variably modified type must have no linkage");
+ error_at (loc, "object with variably modified type must have "
+ "no linkage");
}
/* Record `register' declaration for warnings on &
@@ -5634,11 +5663,12 @@ get_parm_info (bool ellipsis)
}
/* Get the struct, enum or union (CODE says which) with tag NAME.
- Define the tag as a forward-reference if it is not defined.
- Return a c_typespec structure for the type specifier. */
+ Define the tag as a forward-reference with location LOC if it is
+ not defined. Return a c_typespec structure for the type
+ specifier. */
struct c_typespec
-parser_xref_tag (enum tree_code code, tree name, location_t loc)
+parser_xref_tag (location_t loc, enum tree_code code, tree name)
{
struct c_typespec ret;
tree ref;
@@ -5717,7 +5747,7 @@ parser_xref_tag (enum tree_code code, tree name, location_t loc)
TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node);
}
- pushtag (name, ref, loc);
+ pushtag (loc, name, ref);
ret.spec = ref;
return ret;
@@ -5730,11 +5760,12 @@ parser_xref_tag (enum tree_code code, tree name, location_t loc)
tree
xref_tag (enum tree_code code, tree name)
{
- return parser_xref_tag (code, name, UNKNOWN_LOCATION).spec;
+ return parser_xref_tag (input_location, code, name).spec;
}
/* Make sure that the tag NAME is defined *in the current scope*
at least as a forward reference.
+ LOC is the location of the struct's definition.
CODE says which kind of tag NAME ought to be.
This stores the current value of the file static IN_STRUCT in
@@ -5744,8 +5775,9 @@ xref_tag (enum tree_code code, tree name)
finish_struct. */
tree
-start_struct (enum tree_code code, tree name, bool *enclosing_in_struct,
- VEC(tree,heap) **enclosing_struct_types, location_t loc)
+start_struct (location_t loc, enum tree_code code, tree name,
+ bool *enclosing_in_struct,
+ VEC(tree,heap) **enclosing_struct_types)
{
/* If there is already a tag defined at this scope
(as a forward reference), just return it. */
@@ -5787,7 +5819,7 @@ start_struct (enum tree_code code, tree name, bool *enclosing_in_struct,
if (ref == NULL_TREE || TREE_CODE (ref) != code)
{
ref = make_node (code);
- pushtag (name, ref, loc);
+ pushtag (loc, name, ref);
}
C_TYPE_BEING_DEFINED (ref) = 1;
@@ -5881,7 +5913,7 @@ grokfield (location_t loc,
width ? &width : NULL, decl_attrs, NULL, NULL,
DEPRECATED_NORMAL);
- finish_decl (value, NULL_TREE, NULL_TREE, NULL_TREE);
+ finish_decl (value, loc, NULL_TREE, NULL_TREE, NULL_TREE);
DECL_INITIAL (value) = width;
return value;
@@ -5945,6 +5977,7 @@ detect_field_duplicates (tree fieldlist)
}
/* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.
+ LOC is the location of the RECORD_TYPE or UNION_TYPE's definition.
FIELDLIST is a chain of FIELD_DECL nodes for the fields.
ATTRIBUTES are attributes to be applied to the structure.
@@ -5954,7 +5987,7 @@ detect_field_duplicates (tree fieldlist)
for any type defined in the current struct. */
tree
-finish_struct (tree t, tree fieldlist, tree attributes,
+finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
bool enclosing_in_struct,
VEC(tree,heap) *enclosing_struct_types)
{
@@ -5981,16 +6014,16 @@ finish_struct (tree t, tree fieldlist, tree attributes,
if (TREE_CODE (t) == UNION_TYPE)
{
if (fieldlist)
- pedwarn (input_location, OPT_pedantic, "union has no named members");
+ pedwarn (loc, OPT_pedantic, "union has no named members");
else
- pedwarn (input_location, OPT_pedantic, "union has no members");
+ pedwarn (loc, OPT_pedantic, "union has no members");
}
else
{
if (fieldlist)
- pedwarn (input_location, OPT_pedantic, "struct has no named members");
+ pedwarn (loc, OPT_pedantic, "struct has no named members");
else
- pedwarn (input_location, OPT_pedantic, "struct has no members");
+ pedwarn (loc, OPT_pedantic, "struct has no members");
}
}
}
@@ -6054,24 +6087,28 @@ finish_struct (tree t, tree fieldlist, tree attributes,
{
if (TREE_CODE (t) == UNION_TYPE)
{
- error ("%Jflexible array member in union", x);
+ error_at (DECL_SOURCE_LOCATION (x),
+ "%Jflexible array member in union", x);
TREE_TYPE (x) = error_mark_node;
}
else if (TREE_CHAIN (x) != NULL_TREE)
{
- error ("%Jflexible array member not at end of struct", x);
+ error_at (DECL_SOURCE_LOCATION (x),
+ "%Jflexible array member not at end of struct", x);
TREE_TYPE (x) = error_mark_node;
}
else if (!saw_named_field)
{
- error ("%Jflexible array member in otherwise empty struct", x);
+ error_at (DECL_SOURCE_LOCATION (x),
+ "%Jflexible array member in otherwise empty struct",
+ x);
TREE_TYPE (x) = error_mark_node;
}
}
if (pedantic && !in_system_header && TREE_CODE (t) == RECORD_TYPE
&& flexible_array_type_p (TREE_TYPE (x)))
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"%Jinvalid use of structure with flexible array member", x);
if (DECL_NAME (x))
@@ -6181,7 +6218,7 @@ finish_struct (tree t, tree fieldlist, tree attributes,
&& (!TYPE_FIELDS (t) || TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t))))
{
TYPE_TRANSPARENT_UNION (t) = 0;
- warning (0, "union cannot be made transparent");
+ warning_at (loc, 0, "union cannot be made transparent");
}
/* If this structure or union completes the type of any previous
@@ -6212,7 +6249,8 @@ finish_struct (tree t, tree fieldlist, tree attributes,
parsing parameters, then arrange for the size of a variable sized type
to be bound now. */
if (cur_stmt_list && variably_modified_type_p (t, NULL_TREE))
- add_stmt (build_stmt (DECL_EXPR, build_decl (TYPE_DECL, NULL, t)));
+ add_stmt (build_stmt (loc,
+ DECL_EXPR, build_decl (loc, TYPE_DECL, NULL, t)));
/* Set the C_TYPE_DEFINED_IN_STRUCT flag for each type defined in
the current struct. We do this now at the end of the struct
@@ -6247,12 +6285,13 @@ layout_array_type (tree t)
/* Begin compiling the definition of an enumeration type.
NAME is its name (or null if anonymous).
+ LOC is the enum's location.
Returns the type object, as yet incomplete.
Also records info about it so that build_enumerator
may be used to declare the individual values as they are read. */
tree
-start_enum (struct c_enum_contents *the_enum, tree name, location_t loc)
+start_enum (location_t loc, struct c_enum_contents *the_enum, tree name)
{
tree enumtype = NULL_TREE;
location_t enumloc = UNKNOWN_LOCATION;
@@ -6267,7 +6306,7 @@ start_enum (struct c_enum_contents *the_enum, tree name, location_t loc)
if (enumtype == 0 || TREE_CODE (enumtype) != ENUMERAL_TYPE)
{
enumtype = make_node (ENUMERAL_TYPE);
- pushtag (name, enumtype, loc);
+ pushtag (loc, name, enumtype);
}
if (C_TYPE_BEING_DEFINED (enumtype))
@@ -6452,12 +6491,13 @@ finish_enum (tree enumtype, tree values, tree attributes)
/* Build and install a CONST_DECL for one value of the
current enumeration type (one that was begun with start_enum).
+ LOC is the location of the enumerator.
Return a tree-list containing the CONST_DECL and its value.
Assignment of sequential values by default is handled here. */
tree
-build_enumerator (struct c_enum_contents *the_enum, tree name, tree value,
- location_t value_loc)
+build_enumerator (location_t loc,
+ struct c_enum_contents *the_enum, tree name, tree value)
{
tree decl, type;
@@ -6471,7 +6511,8 @@ build_enumerator (struct c_enum_contents *the_enum, tree name, tree value,
value = 0;
else if (!INTEGRAL_TYPE_P (TREE_TYPE (value)))
{
- error ("enumerator value for %qE is not an integer constant", name);
+ error_at (loc, "enumerator value for %qE is not an integer constant",
+ name);
value = 0;
}
else
@@ -6480,7 +6521,7 @@ build_enumerator (struct c_enum_contents *the_enum, tree name, tree value,
{
value = c_fully_fold (value, false, NULL);
if (TREE_CODE (value) == INTEGER_CST)
- pedwarn (value_loc, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"enumerator value for %qE is not an integer "
"constant expression", name);
}
@@ -6505,14 +6546,14 @@ build_enumerator (struct c_enum_contents *the_enum, tree name, tree value,
{
value = the_enum->enum_next_value;
if (the_enum->enum_overflow)
- error ("overflow in enumeration values");
+ error_at (loc, "overflow in enumeration values");
}
/* Even though the underlying type of an enum is unspecified, the
type of enumeration constants is explicitly defined as int
(6.4.4.3/2 in the C99 Standard). GCC allows any integer type as
an extension. */
else if (!int_fits_type_p (value, integer_type_node))
- pedwarn (value_loc, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C restricts enumerator values to range of %<int%>");
/* The ISO C Standard mandates enumerators to have type int, even
@@ -6543,7 +6584,7 @@ build_enumerator (struct c_enum_contents *the_enum, tree name, tree value,
>= TYPE_PRECISION (integer_type_node)
&& TYPE_UNSIGNED (type)));
- decl = build_decl (CONST_DECL, name, type);
+ decl = build_decl (loc, CONST_DECL, name, type);
DECL_INITIAL (decl) = convert (type, value);
pushdecl (decl);
@@ -6571,6 +6612,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
tree restype, resdecl;
struct c_label_context_se *nstack_se;
struct c_label_context_vm *nstack_vm;
+ location_t loc;
current_function_returns_value = 0; /* Assume, until we see it does. */
current_function_returns_null = 0;
@@ -6608,13 +6650,16 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
return 0;
}
+ loc = DECL_SOURCE_LOCATION (decl1);
+
decl_attributes (&decl1, attributes, 0);
if (DECL_DECLARED_INLINE_P (decl1)
&& DECL_UNINLINABLE (decl1)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1)))
- warning (OPT_Wattributes, "inline function %q+D given attribute noinline",
- decl1);
+ warning_at (loc, OPT_Wattributes,
+ "inline function %qD given attribute noinline",
+ decl1);
/* Handle gnu_inline attribute. */
if (declspecs->inline_p
@@ -6631,7 +6676,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl1))))
{
- error ("return type is an incomplete type");
+ error_at (loc, "return type is an incomplete type");
/* Make it return void instead. */
TREE_TYPE (decl1)
= build_function_type (void_type_node,
@@ -6639,7 +6684,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
}
if (warn_about_return_type)
- pedwarn_c99 (input_location, flag_isoc99 ? 0
+ pedwarn_c99 (loc, flag_isoc99 ? 0
: (warn_return_type ? OPT_Wreturn_type : OPT_Wimplicit_int),
"return type defaults to %<int%>");
@@ -6706,15 +6751,16 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
&& old_decl != error_mark_node
&& TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0
&& C_DECL_ISNT_PROTOTYPE (old_decl))
- warning (OPT_Wstrict_prototypes,
- "function declaration isn%'t a prototype");
+ warning_at (loc, OPT_Wstrict_prototypes,
+ "function declaration isn%'t a prototype");
/* Optionally warn of any global def with no previous prototype. */
else if (warn_missing_prototypes
&& old_decl != error_mark_node
&& TREE_PUBLIC (decl1)
&& !MAIN_NAME_P (DECL_NAME (decl1))
&& C_DECL_ISNT_PROTOTYPE (old_decl))
- warning (OPT_Wmissing_prototypes, "no previous prototype for %q+D", decl1);
+ warning_at (loc, OPT_Wmissing_prototypes,
+ "no previous prototype for %qD", decl1);
/* Optionally warn of any def with no previous prototype
if the function has already been used. */
else if (warn_missing_prototypes
@@ -6722,15 +6768,16 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
&& old_decl != error_mark_node
&& TREE_USED (old_decl)
&& TYPE_ARG_TYPES (TREE_TYPE (old_decl)) == 0)
- warning (OPT_Wmissing_prototypes,
- "%q+D was used with no prototype before its definition", decl1);
+ warning_at (loc, OPT_Wmissing_prototypes,
+ "%qD was used with no prototype before its definition", decl1);
/* Optionally warn of any global def with no previous declaration. */
else if (warn_missing_declarations
&& TREE_PUBLIC (decl1)
&& old_decl == 0
&& !MAIN_NAME_P (DECL_NAME (decl1)))
- warning (OPT_Wmissing_declarations, "no previous declaration for %q+D",
- decl1);
+ warning_at (loc, OPT_Wmissing_declarations,
+ "no previous declaration for %qD",
+ decl1);
/* Optionally warn of any def with no previous declaration
if the function has already been used. */
else if (warn_missing_declarations
@@ -6738,8 +6785,8 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
&& old_decl != error_mark_node
&& TREE_USED (old_decl)
&& C_DECL_IMPLICIT (old_decl))
- warning (OPT_Wmissing_declarations,
- "%q+D was used with no declaration before its definition", decl1);
+ warning_at (loc, OPT_Wmissing_declarations,
+ "%qD was used with no declaration before its definition", decl1);
/* This function exists in static storage.
(This does not mean `static' in the C sense!) */
@@ -6762,12 +6809,13 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
{
if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
!= integer_type_node)
- pedwarn (input_location, OPT_Wmain, "return type of %q+D is not %<int%>", decl1);
+ pedwarn (loc, OPT_Wmain, "return type of %qD is not %<int%>", decl1);
check_main_parameter_types (decl1);
if (!TREE_PUBLIC (decl1))
- pedwarn (input_location, OPT_Wmain, "%q+D is normally a non-static function", decl1);
+ pedwarn (loc, OPT_Wmain,
+ "%qD is normally a non-static function", decl1);
}
/* Record the decl so that the function name is defined.
@@ -6780,7 +6828,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
declare_parm_level ();
restype = TREE_TYPE (TREE_TYPE (current_function_decl));
- resdecl = build_decl (RESULT_DECL, NULL_TREE, restype);
+ resdecl = build_decl (loc, RESULT_DECL, NULL_TREE, restype);
DECL_ARTIFICIAL (resdecl) = 1;
DECL_IGNORED_P (resdecl) = 1;
DECL_RESULT (current_function_decl) = resdecl;
@@ -6866,8 +6914,8 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
struct pointer_set_t *seen_args = pointer_set_create ();
if (!in_system_header)
- warning (OPT_Wold_style_definition, "%Jold-style function definition",
- fndecl);
+ warning_at (DECL_SOURCE_LOCATION (fndecl),
+ OPT_Wold_style_definition, "old-style function definition");
/* Match each formal parameter name with its declaration. Save each
decl in the appropriate TREE_PURPOSE slot of the parmids chain. */
@@ -6875,7 +6923,8 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
{
if (TREE_VALUE (parm) == 0)
{
- error ("%Jparameter name missing from parameter list", fndecl);
+ error_at (DECL_SOURCE_LOCATION (fndecl),
+ "parameter name missing from parameter list");
TREE_PURPOSE (parm) = 0;
continue;
}
@@ -6886,12 +6935,14 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
decl = b->decl;
/* If we got something other than a PARM_DECL it is an error. */
if (TREE_CODE (decl) != PARM_DECL)
- error ("%q+D declared as a non-parameter", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qD declared as a non-parameter", decl);
/* If the declaration is already marked, we have a duplicate
name. Complain and ignore the duplicate. */
else if (pointer_set_contains (seen_args, decl))
{
- error ("multiple parameters named %q+D", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "multiple parameters named %qD", decl);
TREE_PURPOSE (parm) = 0;
continue;
}
@@ -6899,7 +6950,8 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
an int. */
else if (VOID_TYPE_P (TREE_TYPE (decl)))
{
- error ("parameter %q+D declared with void type", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "parameter %qD declared with void type", decl);
TREE_TYPE (decl) = integer_type_node;
DECL_ARG_TYPE (decl) = integer_type_node;
layout_decl (decl, 0);
@@ -6909,16 +6961,30 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
/* If no declaration found, default to int. */
else
{
- decl = build_decl (PARM_DECL, TREE_VALUE (parm), integer_type_node);
+ /* FIXME diagnostics: This should be the location of the argument,
+ not the FNDECL. E.g., for an old-style declaration
+
+ int f10(v) { blah; }
+
+ We should use the location of the V, not the F10.
+ Unfortunately, the V is an IDENTIFIER_NODE which has no
+ location. In the future we need locations for c_arg_info
+ entries.
+
+ See gcc.dg/Wshadow-3.c for an example of this problem. */
+ decl = build_decl (DECL_SOURCE_LOCATION (fndecl),
+ PARM_DECL, TREE_VALUE (parm), integer_type_node);
DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
- DECL_SOURCE_LOCATION (decl) = DECL_SOURCE_LOCATION (fndecl);
pushdecl (decl);
warn_if_shadowing (decl);
if (flag_isoc99)
- pedwarn (input_location, 0, "type of %q+D defaults to %<int%>", decl);
+ pedwarn (DECL_SOURCE_LOCATION (decl),
+ 0, "type of %qD defaults to %<int%>", decl);
else
- warning (OPT_Wmissing_parameter_type, "type of %q+D defaults to %<int%>", decl);
+ warning_at (DECL_SOURCE_LOCATION (decl),
+ OPT_Wmissing_parameter_type,
+ "type of %qD defaults to %<int%>", decl);
}
TREE_PURPOSE (parm) = decl;
@@ -6937,13 +7003,16 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
if (TREE_TYPE (parm) != error_mark_node
&& !COMPLETE_TYPE_P (TREE_TYPE (parm)))
{
- error ("parameter %q+D has incomplete type", parm);
+ error_at (DECL_SOURCE_LOCATION (parm),
+ "parameter %qD has incomplete type", parm);
TREE_TYPE (parm) = error_mark_node;
}
if (!pointer_set_contains (seen_args, parm))
{
- error ("declaration for parameter %q+D but no such parameter", parm);
+ error_at (DECL_SOURCE_LOCATION (parm),
+ "declaration for parameter %qD but no such parameter",
+ parm);
/* Pretend the parameter was not missing.
This gets us to a standard state and minimizes
@@ -6993,13 +7062,22 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
|| TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
{
if (current_function_prototype_built_in)
- warning (0, "number of arguments doesn%'t match "
- "built-in prototype");
+ warning_at (DECL_SOURCE_LOCATION (fndecl),
+ 0, "number of arguments doesn%'t match "
+ "built-in prototype");
else
{
- error ("number of arguments doesn%'t match prototype");
- error ("%Hprototype declaration",
- &current_function_prototype_locus);
+ /* FIXME diagnostics: This should be the location of
+ FNDECL, but there is bug when a prototype is
+ declared inside function context, but defined
+ outside of it (e.g., gcc.dg/pr15698-2.c). In
+ which case FNDECL gets the location of the
+ prototype, not the definition. */
+ error_at (input_location,
+ "number of arguments doesn%'t match prototype");
+
+ error_at (current_function_prototype_locus,
+ "prototype declaration");
}
break;
}
@@ -7032,11 +7110,13 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
been diagnosed as conflicting with an
old-style definition and discarded? */
if (current_function_prototype_built_in)
- warning (OPT_pedantic, "promoted argument %qD "
- "doesn%'t match built-in prototype", parm);
+ warning_at (DECL_SOURCE_LOCATION (parm),
+ OPT_pedantic, "promoted argument %qD "
+ "doesn%'t match built-in prototype", parm);
else
{
- pedwarn (input_location, OPT_pedantic, "promoted argument %qD "
+ pedwarn (DECL_SOURCE_LOCATION (parm),
+ OPT_pedantic, "promoted argument %qD "
"doesn%'t match prototype", parm);
pedwarn (current_function_prototype_locus, OPT_pedantic,
"prototype declaration");
@@ -7045,13 +7125,15 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
else
{
if (current_function_prototype_built_in)
- warning (0, "argument %qD doesn%'t match "
- "built-in prototype", parm);
+ warning_at (DECL_SOURCE_LOCATION (parm),
+ 0, "argument %qD doesn%'t match "
+ "built-in prototype", parm);
else
{
- error ("argument %qD doesn%'t match prototype", parm);
- error ("%Hprototype declaration",
- &current_function_prototype_locus);
+ error_at (DECL_SOURCE_LOCATION (parm),
+ "argument %qD doesn%'t match prototype", parm);
+ error_at (current_function_prototype_locus,
+ "prototype declaration");
}
}
}
@@ -7228,14 +7310,13 @@ finish_function (void)
&& TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
== integer_type_node && flag_isoc99)
{
- tree stmt = c_finish_return (integer_zero_node, NULL_TREE);
/* Hack. We don't want the middle-end to warn that this return
is unreachable, so we mark its location as special. Using
UNKNOWN_LOCATION has the problem that it gets clobbered in
annotate_one_with_locus. A cleaner solution might be to
ensure ! should_carry_locus_p (stmt), but that needs a flag.
*/
- SET_EXPR_LOCATION (stmt, BUILTINS_LOCATION);
+ c_finish_return (BUILTINS_LOCATION, integer_zero_node, NULL_TREE);
}
/* Tie off the statement tree for this function. */
@@ -7315,10 +7396,11 @@ finish_function (void)
}
/* Check the declarations given in a for-loop for satisfying the C99
- constraints. If exactly one such decl is found, return it. */
+ constraints. If exactly one such decl is found, return it. LOC is
+ the location of the opening parenthesis of the for loop. */
tree
-check_for_loop_decls (void)
+check_for_loop_decls (location_t loc)
{
struct c_binding *b;
tree one_decl = NULL_TREE;
@@ -7330,10 +7412,11 @@ check_for_loop_decls (void)
/* If we get here, declarations have been used in a for loop without
the C99 for loop scope. This doesn't make much sense, so don't
allow it. */
- error ("%<for%> loop initial declarations are only allowed in C99 mode");
+ error_at (loc, "%<for%> loop initial declarations "
+ "are only allowed in C99 mode");
if (hint)
{
- inform (input_location,
+ inform (loc,
"use option -std=c99 or -std=gnu99 to compile your code");
hint = false;
}
@@ -7364,29 +7447,36 @@ check_for_loop_decls (void)
switch (TREE_CODE (decl))
{
case VAR_DECL:
- if (TREE_STATIC (decl))
- error ("declaration of static variable %q+D in %<for%> loop "
- "initial declaration", decl);
- else if (DECL_EXTERNAL (decl))
- error ("declaration of %<extern%> variable %q+D in %<for%> loop "
- "initial declaration", decl);
+ {
+ location_t decl_loc = DECL_SOURCE_LOCATION (decl);
+ if (TREE_STATIC (decl))
+ error_at (decl_loc,
+ "declaration of static variable %qD in %<for%> loop "
+ "initial declaration", decl);
+ else if (DECL_EXTERNAL (decl))
+ error_at (decl_loc,
+ "declaration of %<extern%> variable %qD in %<for%> loop "
+ "initial declaration", decl);
+ }
break;
case RECORD_TYPE:
- error ("%<struct %E%> declared in %<for%> loop initial declaration",
- id);
+ error_at (loc,
+ "%<struct %E%> declared in %<for%> loop initial "
+ "declaration", id);
break;
case UNION_TYPE:
- error ("%<union %E%> declared in %<for%> loop initial declaration",
- id);
+ error_at (loc,
+ "%<union %E%> declared in %<for%> loop initial declaration",
+ id);
break;
case ENUMERAL_TYPE:
- error ("%<enum %E%> declared in %<for%> loop initial declaration",
- id);
+ error_at (loc, "%<enum %E%> declared in %<for%> loop "
+ "initial declaration", id);
break;
default:
- error ("declaration of non-variable %q+D in %<for%> loop "
- "initial declaration", decl);
+ error_at (loc, "declaration of non-variable "
+ "%qD in %<for%> loop initial declaration", decl);
}
n_decls++;
@@ -7506,7 +7596,7 @@ record_builtin_type (enum rid rid_index, const char *name, tree type)
id = ridpointers[(int) rid_index];
else
id = get_identifier (name);
- decl = build_decl (TYPE_DECL, id, type);
+ decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL, id, type);
pushdecl (decl);
if (debug_hooks->type_decl)
debug_hooks->type_decl (decl, false);
diff --git a/gcc/c-gimplify.c b/gcc/c-gimplify.c
index 9cb4a0b2d17..6595fc8fa03 100644
--- a/gcc/c-gimplify.c
+++ b/gcc/c-gimplify.c
@@ -140,7 +140,7 @@ add_block_to_enclosing (tree block)
genericized. */
tree
-c_build_bind_expr (tree block, tree body)
+c_build_bind_expr (location_t loc, tree block, tree body)
{
tree decls, bind;
@@ -162,11 +162,12 @@ c_build_bind_expr (tree block, tree body)
}
if (!body)
- body = build_empty_stmt ();
+ body = build_empty_stmt (loc);
if (decls || block)
{
bind = build3 (BIND_EXPR, void_type_node, decls, body, block);
TREE_SIDE_EFFECTS (bind) = 1;
+ SET_EXPR_LOCATION (bind, loc);
}
else
bind = body;
diff --git a/gcc/c-omp.c b/gcc/c-omp.c
index d31fb07e002..5ec9f94ff68 100644
--- a/gcc/c-omp.c
+++ b/gcc/c-omp.c
@@ -35,72 +35,81 @@ along with GCC; see the file COPYING3. If not see
/* Complete a #pragma omp master construct. STMT is the structured-block
- that follows the pragma. */
+ that follows the pragma. LOC is the l*/
tree
-c_finish_omp_master (tree stmt)
+c_finish_omp_master (location_t loc, tree stmt)
{
- return add_stmt (build1 (OMP_MASTER, void_type_node, stmt));
+ tree t = add_stmt (build1 (OMP_MASTER, void_type_node, stmt));
+ SET_EXPR_LOCATION (t, loc);
+ return t;
}
/* Complete a #pragma omp critical construct. STMT is the structured-block
that follows the pragma, NAME is the identifier in the pragma, or null
- if it was omitted. */
+ if it was omitted. LOC is the location of the #pragma. */
tree
-c_finish_omp_critical (tree body, tree name)
+c_finish_omp_critical (location_t loc, tree body, tree name)
{
tree stmt = make_node (OMP_CRITICAL);
TREE_TYPE (stmt) = void_type_node;
OMP_CRITICAL_BODY (stmt) = body;
OMP_CRITICAL_NAME (stmt) = name;
+ SET_EXPR_LOCATION (stmt, loc);
return add_stmt (stmt);
}
/* Complete a #pragma omp ordered construct. STMT is the structured-block
- that follows the pragma. */
+ that follows the pragma. LOC is the location of the #pragma. */
tree
-c_finish_omp_ordered (tree stmt)
+c_finish_omp_ordered (location_t loc, tree stmt)
{
- return add_stmt (build1 (OMP_ORDERED, void_type_node, stmt));
+ tree t = build1 (OMP_ORDERED, void_type_node, stmt);
+ SET_EXPR_LOCATION (t, loc);
+ return add_stmt (t);
}
-/* Complete a #pragma omp barrier construct. */
+/* Complete a #pragma omp barrier construct. LOC is the location of
+ the #pragma. */
void
-c_finish_omp_barrier (void)
+c_finish_omp_barrier (location_t loc)
{
tree x;
x = built_in_decls[BUILT_IN_GOMP_BARRIER];
x = build_call_expr (x, 0);
+ SET_EXPR_LOCATION (x, loc);
add_stmt (x);
}
-/* Complete a #pragma omp taskwait construct. */
+/* Complete a #pragma omp taskwait construct. LOC is the location of the
+ pragma. */
void
-c_finish_omp_taskwait (void)
+c_finish_omp_taskwait (location_t loc)
{
tree x;
x = built_in_decls[BUILT_IN_GOMP_TASKWAIT];
x = build_call_expr (x, 0);
+ SET_EXPR_LOCATION (x, loc);
add_stmt (x);
}
-/* Complete a #pragma omp atomic construct. The expression to be
- implemented atomically is LHS code= RHS. The value returned is
- either error_mark_node (if the construct was erroneous) or an
- OMP_ATOMIC node which should be added to the current statement tree
- with add_stmt. */
+/* Complete a #pragma omp atomic construct. The expression to be
+ implemented atomically is LHS code= RHS. LOC is the location of
+ the atomic statement. The value returned is either error_mark_node
+ (if the construct was erroneous) or an OMP_ATOMIC node which should
+ be added to the current statement tree with add_stmt.*/
tree
-c_finish_omp_atomic (enum tree_code code, tree lhs, tree rhs)
+c_finish_omp_atomic (location_t loc, enum tree_code code, tree lhs, tree rhs)
{
tree x, type, addr;
@@ -116,7 +125,7 @@ c_finish_omp_atomic (enum tree_code code, tree lhs, tree rhs)
&& !POINTER_TYPE_P (type)
&& !SCALAR_FLOAT_TYPE_P (type))
{
- error ("invalid expression type for %<#pragma omp atomic%>");
+ error_at (loc, "invalid expression type for %<#pragma omp atomic%>");
return error_mark_node;
}
@@ -124,7 +133,7 @@ c_finish_omp_atomic (enum tree_code code, tree lhs, tree rhs)
/* Take and save the address of the lhs. From then on we'll reference it
via indirection. */
- addr = build_unary_op (input_location, ADDR_EXPR, lhs, 0);
+ addr = build_unary_op (loc, ADDR_EXPR, lhs, 0);
if (addr == error_mark_node)
return error_mark_node;
addr = save_expr (addr);
@@ -137,32 +146,37 @@ c_finish_omp_atomic (enum tree_code code, tree lhs, tree rhs)
tree var = create_tmp_var_raw (TREE_TYPE (addr), NULL);
addr = build4 (TARGET_EXPR, TREE_TYPE (addr), var, addr, NULL, NULL);
}
- lhs = build_indirect_ref (input_location, addr, NULL);
+ lhs = build_indirect_ref (loc, addr, NULL);
/* There are lots of warnings, errors, and conversions that need to happen
in the course of interpreting a statement. Use the normal mechanisms
to do this, and then take it apart again. */
- x = build_modify_expr (input_location, lhs, NULL_TREE, code, rhs, NULL_TREE);
+ x = build_modify_expr (input_location, lhs, NULL_TREE, code,
+ input_location, rhs, NULL_TREE);
if (x == error_mark_node)
return error_mark_node;
gcc_assert (TREE_CODE (x) == MODIFY_EXPR);
rhs = TREE_OPERAND (x, 1);
/* Punt the actual generation of atomic operations to common code. */
- return build2 (OMP_ATOMIC, void_type_node, addr, rhs);
+ x = build2 (OMP_ATOMIC, void_type_node, addr, rhs);
+ SET_EXPR_LOCATION (x, loc);
+ return x;
}
-/* Complete a #pragma omp flush construct. We don't do anything with the
- variable list that the syntax allows. */
+/* Complete a #pragma omp flush construct. We don't do anything with
+ the variable list that the syntax allows. LOC is the location of
+ the #pragma. */
void
-c_finish_omp_flush (void)
+c_finish_omp_flush (location_t loc)
{
tree x;
x = built_in_decls[BUILT_IN_SYNCHRONIZE];
x = build_call_expr (x, 0);
+ SET_EXPR_LOCATION (x, loc);
add_stmt (x);
}
@@ -260,7 +274,11 @@ c_finish_omp_for (location_t locus, tree declv, tree initv, tree condv,
fail = true;
}
- init = build_modify_expr (elocus, decl, NULL_TREE, NOP_EXPR, init,
+ init = build_modify_expr (elocus, decl, NULL_TREE, NOP_EXPR,
+ /* FIXME diagnostics: This should
+ be the location of the INIT. */
+ elocus,
+ init,
NULL_TREE);
}
gcc_assert (TREE_CODE (init) == MODIFY_EXPR);
@@ -448,18 +466,20 @@ c_finish_omp_for (location_t locus, tree declv, tree initv, tree condv,
}
-/* Divide CLAUSES into two lists: those that apply to a parallel construct,
- and those that apply to a work-sharing construct. Place the results in
- *PAR_CLAUSES and *WS_CLAUSES respectively. In addition, add a nowait
- clause to the work-sharing list. */
+/* Divide CLAUSES into two lists: those that apply to a parallel
+ construct, and those that apply to a work-sharing construct. Place
+ the results in *PAR_CLAUSES and *WS_CLAUSES respectively. In
+ addition, add a nowait clause to the work-sharing list. LOC is the
+ location of the OMP_PARALLEL*. */
void
-c_split_parallel_clauses (tree clauses, tree *par_clauses, tree *ws_clauses)
+c_split_parallel_clauses (location_t loc, tree clauses,
+ tree *par_clauses, tree *ws_clauses)
{
tree next;
*par_clauses = NULL;
- *ws_clauses = build_omp_clause (OMP_CLAUSE_NOWAIT);
+ *ws_clauses = build_omp_clause (loc, OMP_CLAUSE_NOWAIT);
for (; clauses ; clauses = next)
{
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index 284708656b5..6c7b8308b28 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -916,6 +916,7 @@ static struct c_expr c_parser_postfix_expression_after_paren_type (c_parser *,
struct c_type_name *,
location_t);
static struct c_expr c_parser_postfix_expression_after_primary (c_parser *,
+ location_t loc,
struct c_expr);
static struct c_expr c_parser_expression (c_parser *);
static struct c_expr c_parser_expression_conv (c_parser *);
@@ -1224,6 +1225,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
{
tree d;
struct c_expr init;
+ location_t init_loc;
c_parser_consume_token (parser);
/* The declaration of the variable is in effect while
its initializer is parsed. */
@@ -1232,12 +1234,14 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
if (!d)
d = error_mark_node;
start_init (d, asm_name, global_bindings_p ());
+ init_loc = c_parser_peek_token (parser)->location;
init = c_parser_initializer (parser);
finish_init ();
if (d != error_mark_node)
{
maybe_warn_string_init (TREE_TYPE (d), init);
- finish_decl (d, init.value, init.original_type, asm_name);
+ finish_decl (d, init_loc, init.value,
+ init.original_type, asm_name);
}
}
else
@@ -1246,7 +1250,8 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
chainon (postfix_attrs,
all_prefix_attrs));
if (d)
- finish_decl (d, NULL_TREE, NULL_TREE, asm_name);
+ finish_decl (d, UNKNOWN_LOCATION, NULL_TREE,
+ NULL_TREE, asm_name);
}
if (c_parser_next_token_is (parser, CPP_COMMA))
{
@@ -1319,7 +1324,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
add_stmt (fnbody);
finish_function ();
c_pop_function_context ();
- add_stmt (build_stmt (DECL_EXPR, decl));
+ add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
}
else
{
@@ -1628,6 +1633,7 @@ c_parser_enum_specifier (c_parser *parser)
enum_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
attrs = c_parser_attributes (parser);
+ enum_loc = c_parser_peek_token (parser)->location;
/* Set the location in case we create a decl now. */
c_parser_set_source_position_from_token (c_parser_peek_token (parser));
if (c_parser_next_token_is (parser, CPP_NAME))
@@ -1641,7 +1647,7 @@ c_parser_enum_specifier (c_parser *parser)
{
/* Parse an enum definition. */
struct c_enum_contents the_enum;
- tree type = start_enum (&the_enum, ident, enum_loc);
+ tree type = start_enum (enum_loc, &the_enum, ident);
tree postfix_attrs;
/* We chain the enumerators in reverse order, then put them in
forward order at the end. */
@@ -1677,8 +1683,8 @@ c_parser_enum_specifier (c_parser *parser)
}
else
enum_value = NULL_TREE;
- enum_decl = build_enumerator (&the_enum, enum_id, enum_value,
- value_loc);
+ enum_decl = build_enumerator (value_loc,
+ &the_enum, enum_id, enum_value);
TREE_CHAIN (enum_decl) = values;
values = enum_decl;
seen_comma = false;
@@ -1720,13 +1726,13 @@ c_parser_enum_specifier (c_parser *parser)
ret.expr_const_operands = true;
return ret;
}
- ret = parser_xref_tag (ENUMERAL_TYPE, ident, ident_loc);
+ ret = parser_xref_tag (ident_loc, ENUMERAL_TYPE, ident);
/* In ISO C, enumerated types can be referred to only if already
defined. */
if (pedantic && !COMPLETE_TYPE_P (ret.spec))
{
gcc_assert (ident);
- pedwarn (ident_loc, OPT_pedantic,
+ pedwarn (enum_loc, OPT_pedantic,
"ISO C forbids forward references to %<enum%> types");
}
return ret;
@@ -1794,8 +1800,10 @@ c_parser_struct_or_union_specifier (c_parser *parser)
struct_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
attrs = c_parser_attributes (parser);
+
/* Set the location in case we create a decl now. */
c_parser_set_source_position_from_token (c_parser_peek_token (parser));
+
if (c_parser_next_token_is (parser, CPP_NAME))
{
ident = c_parser_peek_token (parser)->value;
@@ -1809,8 +1817,8 @@ c_parser_struct_or_union_specifier (c_parser *parser)
tag before parsing components. */
bool in_struct;
VEC(tree,heap) *struct_types;
- tree type = start_struct (code, ident, &in_struct, &struct_types,
- struct_loc);
+ tree type = start_struct (struct_loc, code, ident,
+ &in_struct, &struct_types);
tree postfix_attrs;
/* We chain the components in reverse order, then put them in
forward order at the end. Each struct-declaration may
@@ -1899,7 +1907,7 @@ c_parser_struct_or_union_specifier (c_parser *parser)
}
}
postfix_attrs = c_parser_attributes (parser);
- ret.spec = finish_struct (type, nreverse (contents),
+ ret.spec = finish_struct (struct_loc, type, nreverse (contents),
chainon (attrs, postfix_attrs),
in_struct, struct_types);
ret.kind = ctsk_tagdef;
@@ -1916,7 +1924,7 @@ c_parser_struct_or_union_specifier (c_parser *parser)
ret.expr_const_operands = true;
return ret;
}
- ret = parser_xref_tag (code, ident, ident_loc);
+ ret = parser_xref_tag (ident_loc, code, ident);
return ret;
}
@@ -2366,6 +2374,7 @@ c_parser_direct_declarator_inner (c_parser *parser, bool id_present,
/* Parse a sequence of array declarators and parameter lists. */
if (c_parser_next_token_is (parser, CPP_OPEN_SQUARE))
{
+ location_t brace_loc = c_parser_peek_token (parser)->location;
struct c_declarator *declarator;
struct c_declspecs *quals_attrs = build_null_declspecs ();
bool static_seen;
@@ -2423,8 +2432,8 @@ c_parser_direct_declarator_inner (c_parser *parser, bool id_present,
"expected %<]%>");
return NULL;
}
- declarator = build_array_declarator (dimen, quals_attrs, static_seen,
- star_seen);
+ declarator = build_array_declarator (brace_loc, dimen, quals_attrs,
+ static_seen, star_seen);
if (declarator == NULL)
return NULL;
inner = set_array_declarator_inner (declarator, inner);
@@ -3020,10 +3029,11 @@ c_parser_initializer (c_parser *parser)
else
{
struct c_expr ret;
+ location_t loc = c_parser_peek_token (parser)->location;
ret = c_parser_expr_no_commas (parser, NULL);
if (TREE_CODE (ret.value) != STRING_CST
&& TREE_CODE (ret.value) != COMPOUND_LITERAL_EXPR)
- ret = default_function_array_conversion (ret);
+ ret = default_function_array_conversion (loc, ret);
return ret;
}
}
@@ -3189,10 +3199,13 @@ c_parser_initelt (c_parser *parser)
while (c_parser_next_token_is (parser, CPP_COMMA))
{
struct c_expr next;
+ location_t comma_loc, exp_loc;
+ comma_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
next = c_parser_expr_no_commas (parser, NULL);
- next = default_function_array_conversion (next);
- rec = build_compound_expr (rec, next.value);
+ next = default_function_array_conversion (exp_loc, next);
+ rec = build_compound_expr (comma_loc, rec, next.value);
}
parse_message_args:
/* Now parse the objc-message-args. */
@@ -3279,11 +3292,12 @@ c_parser_initval (c_parser *parser, struct c_expr *after)
init = c_parser_braced_init (parser, NULL_TREE, true);
else
{
+ location_t loc = c_parser_peek_token (parser)->location;
init = c_parser_expr_no_commas (parser, after);
if (init.value != NULL_TREE
&& TREE_CODE (init.value) != STRING_CST
&& TREE_CODE (init.value) != COMPOUND_LITERAL_EXPR)
- init = default_function_array_conversion (init);
+ init = default_function_array_conversion (loc, init);
}
process_init_element (init, false);
}
@@ -3345,17 +3359,19 @@ static tree
c_parser_compound_statement (c_parser *parser)
{
tree stmt;
+ location_t brace_loc;
+ brace_loc = c_parser_peek_token (parser)->location;
if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
{
/* Ensure a scope is entered and left anyway to avoid confusion
if we have just prepared to enter a function body. */
stmt = c_begin_compound_stmt (true);
- c_end_compound_stmt (stmt, true);
+ c_end_compound_stmt (brace_loc, stmt, true);
return error_mark_node;
}
stmt = c_begin_compound_stmt (true);
c_parser_compound_statement_nostart (parser);
- return c_end_compound_stmt (stmt, true);
+ return c_end_compound_stmt (brace_loc, stmt, true);
}
/* Parse a compound statement except for the opening brace. This is
@@ -3377,12 +3393,12 @@ c_parser_compound_statement_nostart (c_parser *parser)
mark_valid_location_for_stdc_pragma (true);
if (c_parser_next_token_is_keyword (parser, RID_LABEL))
{
- location_t err_loc = c_parser_peek_token (parser)->location;
/* Read zero or more forward-declarations for labels that nested
functions can jump to. */
mark_valid_location_for_stdc_pragma (false);
while (c_parser_next_token_is_keyword (parser, RID_LABEL))
{
+ label_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
/* Any identifiers, including those declared as type names,
are OK here. */
@@ -3397,7 +3413,7 @@ c_parser_compound_statement_nostart (c_parser *parser)
label
= declare_label (c_parser_peek_token (parser)->value);
C_DECLARED_LABEL_FLAG (label) = 1;
- add_stmt (build_stmt (DECL_EXPR, label));
+ add_stmt (build_stmt (label_loc, DECL_EXPR, label));
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_COMMA))
c_parser_consume_token (parser);
@@ -3406,7 +3422,7 @@ c_parser_compound_statement_nostart (c_parser *parser)
}
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
}
- pedwarn (err_loc, OPT_pedantic, "ISO C forbids label declarations");
+ pedwarn (label_loc, OPT_pedantic, "ISO C forbids label declarations");
}
/* We must now have at least one statement, label or declaration. */
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
@@ -3557,14 +3573,14 @@ c_parser_label (c_parser *parser)
if (c_parser_next_token_is (parser, CPP_COLON))
{
c_parser_consume_token (parser);
- label = do_case (exp1, NULL_TREE);
+ label = do_case (loc1, exp1, NULL_TREE);
}
else if (c_parser_next_token_is (parser, CPP_ELLIPSIS))
{
c_parser_consume_token (parser);
exp2 = c_parser_expr_no_commas (parser, NULL).value;
if (c_parser_require (parser, CPP_COLON, "expected %<:%>"))
- label = do_case (exp1, exp2);
+ label = do_case (loc1, exp1, exp2);
}
else
c_parser_error (parser, "expected %<:%> or %<...%>");
@@ -3573,7 +3589,7 @@ c_parser_label (c_parser *parser)
{
c_parser_consume_token (parser);
if (c_parser_require (parser, CPP_COLON, "expected %<:%>"))
- label = do_case (NULL_TREE, NULL_TREE);
+ label = do_case (loc1, NULL_TREE, NULL_TREE);
}
else
{
@@ -3590,12 +3606,11 @@ c_parser_label (c_parser *parser)
if (tlab)
{
decl_attributes (&tlab, attrs, 0);
- label = add_stmt (build_stmt (LABEL_EXPR, tlab));
+ label = add_stmt (build_stmt (loc1, LABEL_EXPR, tlab));
}
}
if (label)
{
- SET_EXPR_LOCATION (label, loc1);
if (c_parser_next_token_starts_declspecs (parser)
&& !(c_parser_next_token_is (parser, CPP_NAME)
&& c_parser_peek_2nd_token (parser)->type == CPP_COLON))
@@ -3754,36 +3769,38 @@ c_parser_statement_after_labels (c_parser *parser)
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_NAME))
{
- stmt = c_finish_goto_label (c_parser_peek_token (parser)->value);
+ stmt = c_finish_goto_label (loc,
+ c_parser_peek_token (parser)->value);
c_parser_consume_token (parser);
}
else if (c_parser_next_token_is (parser, CPP_MULT))
{
c_parser_consume_token (parser);
- stmt = c_finish_goto_ptr (c_parser_expression (parser).value);
+ stmt = c_finish_goto_ptr (loc,
+ c_parser_expression (parser).value);
}
else
c_parser_error (parser, "expected identifier or %<*%>");
goto expect_semicolon;
case RID_CONTINUE:
c_parser_consume_token (parser);
- stmt = c_finish_bc_stmt (&c_cont_label, false);
+ stmt = c_finish_bc_stmt (loc, &c_cont_label, false);
goto expect_semicolon;
case RID_BREAK:
c_parser_consume_token (parser);
- stmt = c_finish_bc_stmt (&c_break_label, true);
+ stmt = c_finish_bc_stmt (loc, &c_break_label, true);
goto expect_semicolon;
case RID_RETURN:
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
- stmt = c_finish_return (NULL_TREE, NULL_TREE);
+ stmt = c_finish_return (loc, NULL_TREE, NULL_TREE);
c_parser_consume_token (parser);
}
else
{
struct c_expr expr = c_parser_expression_conv (parser);
- stmt = c_finish_return (expr.value, expr.original_type);
+ stmt = c_finish_return (loc, expr.value, expr.original_type);
goto expect_semicolon;
}
break;
@@ -3795,14 +3812,14 @@ c_parser_statement_after_labels (c_parser *parser)
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
- stmt = objc_build_throw_stmt (NULL_TREE);
+ stmt = objc_build_throw_stmt (loc, NULL_TREE);
c_parser_consume_token (parser);
}
else
{
tree expr = c_parser_expression (parser).value;
expr = c_fully_fold (expr, false, NULL);
- stmt = objc_build_throw_stmt (expr);
+ stmt = objc_build_throw_stmt (loc, expr);
goto expect_semicolon;
}
break;
@@ -3835,7 +3852,7 @@ c_parser_statement_after_labels (c_parser *parser)
break;
default:
expr_stmt:
- stmt = c_finish_expr_stmt (c_parser_expression_conv (parser).value);
+ stmt = c_finish_expr_stmt (loc, c_parser_expression_conv (parser).value);
expect_semicolon:
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
break;
@@ -3850,7 +3867,9 @@ c_parser_statement_after_labels (c_parser *parser)
(recursively) all of the component statements should already have
line numbers assigned. ??? Can we discard no-op statements
earlier? */
- protected_set_expr_location (stmt, loc);
+ if (CAN_HAVE_LOCATION_P (stmt)
+ && EXPR_LOCATION (stmt) == UNKNOWN_LOCATION)
+ SET_EXPR_LOCATION (stmt, loc);
parser->in_if_block = in_if_block;
}
@@ -3860,9 +3879,8 @@ c_parser_statement_after_labels (c_parser *parser)
static tree
c_parser_condition (c_parser *parser)
{
- location_t loc;
+ location_t loc = c_parser_peek_token (parser)->location;
tree cond;
- loc = c_parser_peek_token (parser)->location;
cond = c_parser_expression_conv (parser).value;
cond = c_objc_common_truthvalue_conversion (loc, cond);
cond = c_fully_fold (cond, false, NULL);
@@ -3893,8 +3911,9 @@ static tree
c_parser_c99_block_statement (c_parser *parser)
{
tree block = c_begin_compound_stmt (flag_isoc99);
+ location_t loc = c_parser_peek_token (parser)->location;
c_parser_statement (parser);
- return c_end_compound_stmt (block, flag_isoc99);
+ return c_end_compound_stmt (loc, block, flag_isoc99);
}
/* Parse the body of an if statement. This is just parsing a
@@ -3909,6 +3928,7 @@ static tree
c_parser_if_body (c_parser *parser, bool *if_p)
{
tree block = c_begin_compound_stmt (flag_isoc99);
+ location_t body_loc = c_parser_peek_token (parser)->location;
while (c_parser_next_token_is_keyword (parser, RID_CASE)
|| c_parser_next_token_is_keyword (parser, RID_DEFAULT)
|| (c_parser_next_token_is (parser, CPP_NAME)
@@ -3918,7 +3938,7 @@ c_parser_if_body (c_parser *parser, bool *if_p)
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
location_t loc = c_parser_peek_token (parser)->location;
- add_stmt (build_empty_stmt ());
+ add_stmt (build_empty_stmt (loc));
c_parser_consume_token (parser);
if (!c_parser_next_token_is_keyword (parser, RID_ELSE))
warning_at (loc, OPT_Wempty_body,
@@ -3928,7 +3948,7 @@ c_parser_if_body (c_parser *parser, bool *if_p)
add_stmt (c_parser_compound_statement (parser));
else
c_parser_statement_after_labels (parser);
- return c_end_compound_stmt (block, flag_isoc99);
+ return c_end_compound_stmt (body_loc, block, flag_isoc99);
}
/* Parse the else body of an if statement. This is just parsing a
@@ -3938,6 +3958,7 @@ c_parser_if_body (c_parser *parser, bool *if_p)
static tree
c_parser_else_body (c_parser *parser)
{
+ location_t else_loc = c_parser_peek_token (parser)->location;
tree block = c_begin_compound_stmt (flag_isoc99);
while (c_parser_next_token_is_keyword (parser, RID_CASE)
|| c_parser_next_token_is_keyword (parser, RID_DEFAULT)
@@ -3946,15 +3967,16 @@ c_parser_else_body (c_parser *parser)
c_parser_label (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
- warning_at (c_parser_peek_token (parser)->location,
+ location_t loc = c_parser_peek_token (parser)->location;
+ warning_at (loc,
OPT_Wempty_body,
"suggest braces around empty body in an %<else%> statement");
- add_stmt (build_empty_stmt ());
+ add_stmt (build_empty_stmt (loc));
c_parser_consume_token (parser);
}
else
c_parser_statement_after_labels (parser);
- return c_end_compound_stmt (block, flag_isoc99);
+ return c_end_compound_stmt (else_loc, block, flag_isoc99);
}
/* Parse an if statement (C90 6.6.4, C99 6.8.4).
@@ -3991,7 +4013,7 @@ c_parser_if_statement (c_parser *parser)
else
second_body = NULL_TREE;
c_finish_if_stmt (loc, cond, first_body, second_body, first_if);
- add_stmt (c_end_compound_stmt (block, flag_isoc99));
+ add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
}
/* Parse a switch statement (C90 6.6.4, C99 6.8.4).
@@ -4004,25 +4026,36 @@ static void
c_parser_switch_statement (c_parser *parser)
{
tree block, expr, body, save_break;
+ location_t switch_loc = c_parser_peek_token (parser)->location;
+ location_t switch_cond_loc;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_SWITCH));
c_parser_consume_token (parser);
block = c_begin_compound_stmt (flag_isoc99);
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
+ switch_cond_loc = c_parser_peek_token (parser)->location;
expr = c_parser_expression (parser).value;
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
}
else
- expr = error_mark_node;
- c_start_case (expr);
+ {
+ switch_cond_loc = UNKNOWN_LOCATION;
+ expr = error_mark_node;
+ }
+ c_start_case (switch_loc, switch_cond_loc, expr);
save_break = c_break_label;
c_break_label = NULL_TREE;
body = c_parser_c99_block_statement (parser);
c_finish_case (body);
if (c_break_label)
- add_stmt (build1 (LABEL_EXPR, void_type_node, c_break_label));
+ {
+ location_t here = c_parser_peek_token (parser)->location;
+ tree t = build1 (LABEL_EXPR, void_type_node, c_break_label);
+ SET_EXPR_LOCATION (t, here);
+ add_stmt (t);
+ }
c_break_label = save_break;
- add_stmt (c_end_compound_stmt (block, flag_isoc99));
+ add_stmt (c_end_compound_stmt (switch_loc, block, flag_isoc99));
}
/* Parse a while statement (C90 6.6.5, C99 6.8.5).
@@ -4047,7 +4080,7 @@ c_parser_while_statement (c_parser *parser)
c_cont_label = NULL_TREE;
body = c_parser_c99_block_statement (parser);
c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, true);
- add_stmt (c_end_compound_stmt (block, flag_isoc99));
+ add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
c_break_label = save_break;
c_cont_label = save_cont;
}
@@ -4085,7 +4118,7 @@ c_parser_do_statement (c_parser *parser)
if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
c_parser_skip_to_end_of_block_or_statement (parser);
c_finish_loop (loc, cond, NULL, body, new_break, new_cont, false);
- add_stmt (c_end_compound_stmt (block, flag_isoc99));
+ add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
}
/* Parse a for statement (C90 6.6.5, C99 6.8.5).
@@ -4108,9 +4141,9 @@ static void
c_parser_for_statement (c_parser *parser)
{
tree block, cond, incr, save_break, save_cont, body;
- location_t loc;
+ location_t loc = c_parser_peek_token (parser)->location;
+ location_t for_loc = c_parser_peek_token (parser)->location;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_FOR));
- loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
block = c_begin_compound_stmt (flag_isoc99);
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
@@ -4119,12 +4152,12 @@ c_parser_for_statement (c_parser *parser)
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
c_parser_consume_token (parser);
- c_finish_expr_stmt (NULL_TREE);
+ c_finish_expr_stmt (loc, NULL_TREE);
}
else if (c_parser_next_token_starts_declspecs (parser))
{
c_parser_declaration_or_fndef (parser, true, true, true, true);
- check_for_loop_decls ();
+ check_for_loop_decls (for_loc);
}
else if (c_parser_next_token_is_keyword (parser, RID_EXTENSION))
{
@@ -4143,7 +4176,7 @@ c_parser_for_statement (c_parser *parser)
c_parser_consume_token (parser);
c_parser_declaration_or_fndef (parser, true, true, true, true);
restore_extension_diagnostics (ext);
- check_for_loop_decls ();
+ check_for_loop_decls (for_loc);
}
else
goto init_expr;
@@ -4151,7 +4184,7 @@ c_parser_for_statement (c_parser *parser)
else
{
init_expr:
- c_finish_expr_stmt (c_parser_expression (parser).value);
+ c_finish_expr_stmt (loc, c_parser_expression (parser).value);
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
}
/* Parse the loop condition. */
@@ -4167,9 +4200,9 @@ c_parser_for_statement (c_parser *parser)
}
/* Parse the increment expression. */
if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
- incr = c_process_expr_stmt (NULL_TREE);
+ incr = c_process_expr_stmt (loc, NULL_TREE);
else
- incr = c_process_expr_stmt (c_parser_expression (parser).value);
+ incr = c_process_expr_stmt (loc, c_parser_expression (parser).value);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
}
else
@@ -4183,7 +4216,7 @@ c_parser_for_statement (c_parser *parser)
c_cont_label = NULL_TREE;
body = c_parser_c99_block_statement (parser);
c_finish_loop (loc, cond, incr, body, c_break_label, c_cont_label, true);
- add_stmt (c_end_compound_stmt (block, flag_isoc99));
+ add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
c_break_label = save_break;
c_cont_label = save_cont;
}
@@ -4209,6 +4242,7 @@ c_parser_asm_statement (c_parser *parser)
{
tree quals, str, outputs, inputs, clobbers, ret;
bool simple;
+ location_t asm_loc = c_parser_peek_token (parser)->location;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_ASM));
c_parser_consume_token (parser);
if (c_parser_next_token_is_keyword (parser, RID_VOLATILE))
@@ -4304,7 +4338,7 @@ c_parser_asm_statement (c_parser *parser)
}
if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
c_parser_skip_to_end_of_block_or_statement (parser);
- ret = build_asm_stmt (quals, build_asm_expr (str, outputs, inputs,
+ ret = build_asm_stmt (quals, build_asm_expr (asm_loc, str, outputs, inputs,
clobbers, simple));
return ret;
}
@@ -4326,6 +4360,7 @@ static tree
c_parser_asm_operands (c_parser *parser, bool convert_p)
{
tree list = NULL_TREE;
+ location_t loc;
while (true)
{
tree name, str;
@@ -4360,9 +4395,10 @@ c_parser_asm_operands (c_parser *parser, bool convert_p)
parser->lex_untranslated_string = true;
return NULL_TREE;
}
+ loc = c_parser_peek_token (parser)->location;
expr = c_parser_expression (parser);
if (convert_p)
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (loc, expr);
expr.value = c_fully_fold (expr.value, false, NULL);
parser->lex_untranslated_string = true;
if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
@@ -4427,7 +4463,7 @@ c_parser_expr_no_commas (c_parser *parser, struct c_expr *after)
{
struct c_expr lhs, rhs, ret;
enum tree_code code;
- location_t op_location;
+ location_t op_location, exp_location;
gcc_assert (!after || c_dialect_objc ());
lhs = c_parser_conditional_expression (parser, after);
op_location = c_parser_peek_token (parser)->location;
@@ -4470,10 +4506,12 @@ c_parser_expr_no_commas (c_parser *parser, struct c_expr *after)
return lhs;
}
c_parser_consume_token (parser);
+ exp_location = c_parser_peek_token (parser)->location;
rhs = c_parser_expr_no_commas (parser, NULL);
- rhs = default_function_array_conversion (rhs);
+ rhs = default_function_array_conversion (exp_location, rhs);
ret.value = build_modify_expr (op_location, lhs.value, lhs.original_type,
- code, rhs.value, rhs.original_type);
+ code, exp_location, rhs.value,
+ rhs.original_type);
if (code == NOP_EXPR)
ret.original_code = MODIFY_EXPR;
else
@@ -4507,12 +4545,12 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after)
gcc_assert (!after || c_dialect_objc ());
- cond_loc = c_parser_peek_token (parser)->location;
cond = c_parser_binary_expression (parser, after);
if (c_parser_next_token_is_not (parser, CPP_QUERY))
return cond;
- cond = default_function_array_conversion (cond);
+ cond_loc = c_parser_peek_token (parser)->location;
+ cond = default_function_array_conversion (cond_loc, cond);
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_COLON))
{
@@ -4552,8 +4590,11 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after)
ret.original_type = NULL;
return ret;
}
- exp2 = c_parser_conditional_expression (parser, NULL);
- exp2 = default_function_array_conversion (exp2);
+ {
+ location_t exp2_loc = c_parser_peek_token (parser)->location;
+ exp2 = c_parser_conditional_expression (parser, NULL);
+ exp2 = default_function_array_conversion (exp2_loc, exp2);
+ }
skip_evaluation -= cond.value == truthvalue_true_node;
ret.value = build_conditional_expr (colon_loc, cond.value,
cond.original_code == C_MAYBE_CONST_EXPR,
@@ -4702,9 +4743,10 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
break; \
} \
stack[sp - 1].expr \
- = default_function_array_conversion (stack[sp - 1].expr); \
+ = default_function_array_conversion (stack[sp - 1].loc, \
+ stack[sp - 1].expr); \
stack[sp].expr \
- = default_function_array_conversion (stack[sp].expr); \
+ = default_function_array_conversion (stack[sp].loc, stack[sp].expr); \
stack[sp - 1].expr = parser_build_binary_op (stack[sp].loc, \
stack[sp].op, \
stack[sp - 1].expr, \
@@ -4809,14 +4851,16 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
{
case TRUTH_ANDIF_EXPR:
stack[sp].expr
- = default_function_array_conversion (stack[sp].expr);
+ = default_function_array_conversion (stack[sp].loc,
+ stack[sp].expr);
stack[sp].expr.value = c_objc_common_truthvalue_conversion
(stack[sp].loc, default_conversion (stack[sp].expr.value));
skip_evaluation += stack[sp].expr.value == truthvalue_false_node;
break;
case TRUTH_ORIF_EXPR:
stack[sp].expr
- = default_function_array_conversion (stack[sp].expr);
+ = default_function_array_conversion (stack[sp].loc,
+ stack[sp].expr);
stack[sp].expr.value = c_objc_common_truthvalue_conversion
(stack[sp].loc, default_conversion (stack[sp].expr.value));
skip_evaluation += stack[sp].expr.value == truthvalue_true_node;
@@ -4829,6 +4873,7 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
stack[sp].expr = c_parser_cast_expression (parser, NULL);
stack[sp].prec = oprec;
stack[sp].op = ocode;
+ stack[sp].loc = binary_loc;
}
out:
while (sp > 0)
@@ -4849,9 +4894,11 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
static struct c_expr
c_parser_cast_expression (c_parser *parser, struct c_expr *after)
{
+ location_t cast_loc = c_parser_peek_token (parser)->location;
gcc_assert (!after || c_dialect_objc ());
if (after)
- return c_parser_postfix_expression_after_primary (parser, *after);
+ return c_parser_postfix_expression_after_primary (parser,
+ cast_loc, *after);
/* If the expression begins with a parenthesized type name, it may
be either a cast or a compound literal; we need to see whether
the next character is '{' to tell the difference. If not, it is
@@ -4859,12 +4906,10 @@ c_parser_cast_expression (c_parser *parser, struct c_expr *after)
if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
&& c_token_starts_typename (c_parser_peek_2nd_token (parser)))
{
- location_t loc;
struct c_type_name *type_name;
struct c_expr ret;
struct c_expr expr;
c_parser_consume_token (parser);
- loc = c_parser_peek_token (parser)->location;
type_name = c_parser_type_name (parser);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
if (type_name == NULL)
@@ -4880,10 +4925,13 @@ c_parser_cast_expression (c_parser *parser, struct c_expr *after)
if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
return c_parser_postfix_expression_after_paren_type (parser, type_name,
- loc);
- expr = c_parser_cast_expression (parser, NULL);
- expr = default_function_array_conversion (expr);
- ret.value = c_cast_expr (type_name, expr.value, loc);
+ cast_loc);
+ {
+ location_t expr_loc = c_parser_peek_token (parser)->location;
+ expr = c_parser_cast_expression (parser, NULL);
+ expr = default_function_array_conversion (expr_loc, expr);
+ }
+ ret.value = c_cast_expr (cast_loc, type_name, expr.value);
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
return ret;
@@ -4924,63 +4972,70 @@ c_parser_unary_expression (c_parser *parser)
{
int ext;
struct c_expr ret, op;
- location_t loc = c_parser_peek_token (parser)->location;
+ location_t op_loc = c_parser_peek_token (parser)->location;
+ location_t exp_loc;
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
switch (c_parser_peek_token (parser)->type)
{
case CPP_PLUS_PLUS:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (PREINCREMENT_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, PREINCREMENT_EXPR, op);
case CPP_MINUS_MINUS:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (PREDECREMENT_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, PREDECREMENT_EXPR, op);
case CPP_AND:
c_parser_consume_token (parser);
- return parser_build_unary_op (ADDR_EXPR,
- c_parser_cast_expression (parser, NULL),
- loc);
+ return parser_build_unary_op (op_loc, ADDR_EXPR,
+ c_parser_cast_expression (parser, NULL));
case CPP_MULT:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- ret.value = build_indirect_ref (loc, op.value, "unary *");
+ op = default_function_array_conversion (exp_loc, op);
+ ret.value = build_indirect_ref (op_loc, op.value, "unary *");
return ret;
case CPP_PLUS:
if (!c_dialect_objc () && !in_system_header)
- warning_at (c_parser_peek_token (parser)->location,
+ warning_at (op_loc,
OPT_Wtraditional,
"traditional C rejects the unary plus operator");
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (CONVERT_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, CONVERT_EXPR, op);
case CPP_MINUS:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (NEGATE_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, NEGATE_EXPR, op);
case CPP_COMPL:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (BIT_NOT_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, BIT_NOT_EXPR, op);
case CPP_NOT:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (TRUTH_NOT_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, TRUTH_NOT_EXPR, op);
case CPP_AND_AND:
/* Refer to the address of a label as a pointer. */
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_NAME))
{
ret.value = finish_label_address_expr
- (c_parser_peek_token (parser)->value, loc);
+ (c_parser_peek_token (parser)->value, op_loc);
c_parser_consume_token (parser);
}
else
@@ -5004,14 +5059,16 @@ c_parser_unary_expression (c_parser *parser)
return ret;
case RID_REALPART:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (REALPART_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, REALPART_EXPR, op);
case RID_IMAGPART:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (IMAGPART_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, IMAGPART_EXPR, op);
default:
return c_parser_postfix_expression (parser);
}
@@ -5061,7 +5118,7 @@ c_parser_sizeof_expression (c_parser *parser)
/* sizeof ( type-name ). */
skip_evaluation--;
in_sizeof--;
- return c_expr_sizeof_type (type_name);
+ return c_expr_sizeof_type (expr_loc, type_name);
}
else
{
@@ -5073,7 +5130,7 @@ c_parser_sizeof_expression (c_parser *parser)
if (TREE_CODE (expr.value) == COMPONENT_REF
&& DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
error_at (expr_loc, "%<sizeof%> applied to a bit-field");
- return c_expr_sizeof_expr (expr);
+ return c_expr_sizeof_expr (expr_loc, expr);
}
}
@@ -5083,6 +5140,7 @@ static struct c_expr
c_parser_alignof_expression (c_parser *parser)
{
struct c_expr expr;
+ location_t loc = c_parser_peek_token (parser)->location;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_ALIGNOF));
c_parser_consume_token (parser);
skip_evaluation++;
@@ -5119,7 +5177,7 @@ c_parser_alignof_expression (c_parser *parser)
/* alignof ( type-name ). */
skip_evaluation--;
in_alignof--;
- ret.value = c_alignof (groktypename (type_name, NULL, NULL));
+ ret.value = c_alignof (loc, groktypename (type_name, NULL, NULL));
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
return ret;
@@ -5131,7 +5189,7 @@ c_parser_alignof_expression (c_parser *parser)
alignof_expr:
skip_evaluation--;
in_alignof--;
- ret.value = c_alignof_expr (expr.value);
+ ret.value = c_alignof_expr (loc, expr.value);
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
return ret;
@@ -5196,7 +5254,7 @@ c_parser_postfix_expression (c_parser *parser)
{
struct c_expr expr, e1, e2, e3;
struct c_type_name *t1, *t2;
- location_t loc;
+ location_t loc = c_parser_peek_token (parser)->location;;
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
switch (c_parser_peek_token (parser)->type)
@@ -5242,11 +5300,10 @@ c_parser_postfix_expression (c_parser *parser)
}
{
tree id = c_parser_peek_token (parser)->value;
- location_t loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
- expr.value = build_external_ref (id,
+ expr.value = build_external_ref (loc, id,
(c_parser_peek_token (parser)->type
- == CPP_OPEN_PAREN), loc,
+ == CPP_OPEN_PAREN),
&expr.original_type);
}
break;
@@ -5257,12 +5314,13 @@ c_parser_postfix_expression (c_parser *parser)
{
/* A statement expression. */
tree stmt;
- location_t here = c_parser_peek_token (parser)->location;
+ location_t brace_loc;
c_parser_consume_token (parser);
+ brace_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
if (cur_stmt_list == NULL)
{
- error_at (here, "braced-group within expression allowed "
+ error_at (loc, "braced-group within expression allowed "
"only inside a function");
parser->error = true;
c_parser_skip_until_found (parser, CPP_CLOSE_BRACE, NULL);
@@ -5274,9 +5332,9 @@ c_parser_postfix_expression (c_parser *parser)
c_parser_compound_statement_nostart (parser);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
- pedwarn (here, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids braced-groups within expressions");
- expr.value = c_finish_stmt_expr (stmt);
+ expr.value = c_finish_stmt_expr (brace_loc, stmt);
}
else if (c_token_starts_typename (c_parser_peek_2nd_token (parser)))
{
@@ -5320,7 +5378,7 @@ c_parser_postfix_expression (c_parser *parser)
case RID_FUNCTION_NAME:
case RID_PRETTY_FUNCTION_NAME:
case RID_C99_FUNCTION_NAME:
- expr.value = fname_decl (c_parser_peek_token (parser)->location,
+ expr.value = fname_decl (loc,
c_parser_peek_token (parser)->keyword,
c_parser_peek_token (parser)->value);
c_parser_consume_token (parser);
@@ -5351,9 +5409,8 @@ c_parser_postfix_expression (c_parser *parser)
else
{
tree type_expr = NULL_TREE;
- expr.value = c_build_va_arg (e1.value,
- groktypename (t1, &type_expr, NULL),
- loc);
+ expr.value = c_build_va_arg (loc, e1.value,
+ groktypename (t1, &type_expr, NULL));
if (type_expr)
{
expr.value = build2 (C_MAYBE_CONST_EXPR,
@@ -5388,14 +5445,17 @@ c_parser_postfix_expression (c_parser *parser)
if (type == error_mark_node)
offsetof_ref = error_mark_node;
else
- offsetof_ref = build1 (INDIRECT_REF, type, null_pointer_node);
+ {
+ offsetof_ref = build1 (INDIRECT_REF, type, null_pointer_node);
+ SET_EXPR_LOCATION (offsetof_ref, loc);
+ }
/* Parse the second argument to __builtin_offsetof. We
must have one identifier, and beyond that we want to
accept sub structure and sub array references. */
if (c_parser_next_token_is (parser, CPP_NAME))
{
offsetof_ref = build_component_ref
- (offsetof_ref, c_parser_peek_token (parser)->value);
+ (loc, offsetof_ref, c_parser_peek_token (parser)->value);
c_parser_consume_token (parser);
while (c_parser_next_token_is (parser, CPP_DOT)
|| c_parser_next_token_is (parser,
@@ -5406,9 +5466,9 @@ c_parser_postfix_expression (c_parser *parser)
if (c_parser_next_token_is (parser, CPP_DEREF))
{
loc = c_parser_peek_token (parser)->location;
- offsetof_ref = build_array_ref (offsetof_ref,
- integer_zero_node,
- loc);
+ offsetof_ref = build_array_ref (loc,
+ offsetof_ref,
+ integer_zero_node);
goto do_dot;
}
else if (c_parser_next_token_is (parser, CPP_DOT))
@@ -5422,7 +5482,7 @@ c_parser_postfix_expression (c_parser *parser)
break;
}
offsetof_ref = build_component_ref
- (offsetof_ref,
+ (loc, offsetof_ref,
c_parser_peek_token (parser)->value);
c_parser_consume_token (parser);
}
@@ -5435,7 +5495,7 @@ c_parser_postfix_expression (c_parser *parser)
idx = c_fully_fold (idx, false, NULL);
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
"expected %<]%>");
- offsetof_ref = build_array_ref (offsetof_ref, idx, loc);
+ offsetof_ref = build_array_ref (loc, offsetof_ref, idx);
}
}
}
@@ -5534,7 +5594,7 @@ c_parser_postfix_expression (c_parser *parser)
tree sel = c_parser_objc_selector_arg (parser);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
- expr.value = objc_build_selector_expr (sel);
+ expr.value = objc_build_selector_expr (loc, sel);
}
break;
case RID_AT_PROTOCOL:
@@ -5608,7 +5668,7 @@ c_parser_postfix_expression (c_parser *parser)
expr.value = error_mark_node;
break;
}
- return c_parser_postfix_expression_after_primary (parser, expr);
+ return c_parser_postfix_expression_after_primary (parser, loc, expr);
}
/* Parse a postfix expression after a parenthesized type name: the
@@ -5633,7 +5693,7 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser,
location_t start_loc;
tree type_expr = NULL_TREE;
bool type_expr_const = true;
- check_compound_literal_type (type_name, type_loc);
+ check_compound_literal_type (type_loc, type_name);
start_init (NULL_TREE, NULL, 0);
type = groktypename (type_name, &type_expr, &type_expr_const);
start_loc = c_parser_peek_token (parser)->location;
@@ -5652,7 +5712,7 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser,
? CONSTRUCTOR_NON_CONST (init.value)
: init.original_code == C_MAYBE_CONST_EXPR);
non_const |= !type_expr_const;
- expr.value = build_compound_literal (type, init.value, non_const);
+ expr.value = build_compound_literal (start_loc, type, init.value, non_const);
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
if (type_expr)
@@ -5669,33 +5729,35 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser,
type_expr, expr.value);
}
}
- return c_parser_postfix_expression_after_primary (parser, expr);
+ return c_parser_postfix_expression_after_primary (parser, start_loc, expr);
}
/* Parse a postfix expression after the initial primary or compound
- literal; that is, parse a series of postfix operators. */
+ literal; that is, parse a series of postfix operators.
+
+ EXPR_LOC is the location of the primary expression. */
static struct c_expr
c_parser_postfix_expression_after_primary (c_parser *parser,
+ location_t expr_loc,
struct c_expr expr)
{
struct c_expr orig_expr;
tree ident, idx;
VEC(tree,gc) *exprlist;
VEC(tree,gc) *origtypes;
- location_t loc = c_parser_peek_token (parser)->location;
while (true)
{
+ location_t op_loc = c_parser_peek_token (parser)->location;
switch (c_parser_peek_token (parser)->type)
{
case CPP_OPEN_SQUARE:
/* Array reference. */
- loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
idx = c_parser_expression (parser).value;
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
"expected %<]%>");
- expr.value = build_array_ref (expr.value, idx, loc);
+ expr.value = build_array_ref (op_loc, expr.value, idx);
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
break;
@@ -5709,7 +5771,9 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
orig_expr = expr;
- expr.value = build_function_call_vec (expr.value, exprlist,
+ /* FIXME diagnostics: Ideally we want the FUNCNAME, not the
+ "(" after the FUNCNAME, which is what we have now. */
+ expr.value = build_function_call_vec (op_loc, expr.value, exprlist,
origtypes);
expr.original_code = ERROR_MARK;
if (TREE_CODE (expr.value) == INTEGER_CST
@@ -5727,7 +5791,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
case CPP_DOT:
/* Structure element reference. */
c_parser_consume_token (parser);
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (expr_loc, expr);
if (c_parser_next_token_is (parser, CPP_NAME))
ident = c_parser_peek_token (parser)->value;
else
@@ -5739,7 +5803,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
return expr;
}
c_parser_consume_token (parser);
- expr.value = build_component_ref (expr.value, ident);
+ expr.value = build_component_ref (op_loc, expr.value, ident);
expr.original_code = ERROR_MARK;
if (TREE_CODE (expr.value) != COMPONENT_REF)
expr.original_type = NULL;
@@ -5756,7 +5820,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
case CPP_DEREF:
/* Structure element reference. */
c_parser_consume_token (parser);
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (expr_loc, expr);
if (c_parser_next_token_is (parser, CPP_NAME))
ident = c_parser_peek_token (parser)->value;
else
@@ -5768,7 +5832,8 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
return expr;
}
c_parser_consume_token (parser);
- expr.value = build_component_ref (build_indirect_ref (loc,
+ expr.value = build_component_ref (op_loc,
+ build_indirect_ref (op_loc,
expr.value,
"->"),
ident);
@@ -5788,8 +5853,8 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
case CPP_PLUS_PLUS:
/* Postincrement. */
c_parser_consume_token (parser);
- expr = default_function_array_conversion (expr);
- expr.value = build_unary_op (loc,
+ expr = default_function_array_conversion (expr_loc, expr);
+ expr.value = build_unary_op (op_loc,
POSTINCREMENT_EXPR, expr.value, 0);
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
@@ -5797,8 +5862,8 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
case CPP_MINUS_MINUS:
/* Postdecrement. */
c_parser_consume_token (parser);
- expr = default_function_array_conversion (expr);
- expr.value = build_unary_op (loc,
+ expr = default_function_array_conversion (expr_loc, expr);
+ expr.value = build_unary_op (op_loc,
POSTDECREMENT_EXPR, expr.value, 0);
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
@@ -5824,10 +5889,13 @@ c_parser_expression (c_parser *parser)
while (c_parser_next_token_is (parser, CPP_COMMA))
{
struct c_expr next;
+ location_t loc = c_parser_peek_token (parser)->location;
+ location_t expr_loc;
c_parser_consume_token (parser);
+ expr_loc = c_parser_peek_token (parser)->location;
next = c_parser_expr_no_commas (parser, NULL);
- next = default_function_array_conversion (next);
- expr.value = build_compound_expr (expr.value, next.value);
+ next = default_function_array_conversion (expr_loc, next);
+ expr.value = build_compound_expr (loc, expr.value, next.value);
expr.original_code = COMPOUND_EXPR;
expr.original_type = next.original_type;
}
@@ -5841,8 +5909,9 @@ static struct c_expr
c_parser_expression_conv (c_parser *parser)
{
struct c_expr expr;
+ location_t loc = c_parser_peek_token (parser)->location;
expr = c_parser_expression (parser);
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (loc, expr);
return expr;
}
@@ -5861,6 +5930,7 @@ c_parser_expr_list (c_parser *parser, bool convert_p, bool fold_p,
VEC(tree,gc) *ret;
VEC(tree,gc) *orig_types;
struct c_expr expr;
+ location_t loc = c_parser_peek_token (parser)->location;
ret = make_tree_vector ();
if (p_orig_types == NULL)
@@ -5870,7 +5940,7 @@ c_parser_expr_list (c_parser *parser, bool convert_p, bool fold_p,
expr = c_parser_expr_no_commas (parser, NULL);
if (convert_p)
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (loc, expr);
if (fold_p)
expr.value = c_fully_fold (expr.value, false, NULL);
VEC_quick_push (tree, ret, expr.value);
@@ -5879,9 +5949,10 @@ c_parser_expr_list (c_parser *parser, bool convert_p, bool fold_p,
while (c_parser_next_token_is (parser, CPP_COMMA))
{
c_parser_consume_token (parser);
+ loc = c_parser_peek_token (parser)->location;
expr = c_parser_expr_no_commas (parser, NULL);
if (convert_p)
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (loc, expr);
if (fold_p)
expr.value = c_fully_fold (expr.value, false, NULL);
VEC_safe_push (tree, gc, ret, expr.value);
@@ -6998,7 +7069,8 @@ check_no_duplicate_clause (tree clauses, enum omp_clause_code code,
for (c = clauses; c ; c = OMP_CLAUSE_CHAIN (c))
if (OMP_CLAUSE_CODE (c) == code)
{
- error ("too many %qs clauses", name);
+ location_t loc = OMP_CLAUSE_LOCATION (c);
+ error_at (loc, "too many %qs clauses", name);
break;
}
}
@@ -7008,14 +7080,17 @@ check_no_duplicate_clause (tree clauses, enum omp_clause_code code,
identifier
variable-list , identifier
- If KIND is nonzero, create the appropriate node and install the decl
- in OMP_CLAUSE_DECL and add the node to the head of the list.
+ If KIND is nonzero, create the appropriate node and install the
+ decl in OMP_CLAUSE_DECL and add the node to the head of the list.
+ If KIND is nonzero, CLAUSE_LOC is the location of the clause.
If KIND is zero, create a TREE_LIST with the decl in TREE_PURPOSE;
return the list created. */
static tree
-c_parser_omp_variable_list (c_parser *parser, enum omp_clause_code kind,
+c_parser_omp_variable_list (c_parser *parser,
+ location_t clause_loc,
+ enum omp_clause_code kind,
tree list)
{
if (c_parser_next_token_is_not (parser, CPP_NAME)
@@ -7028,13 +7103,13 @@ c_parser_omp_variable_list (c_parser *parser, enum omp_clause_code kind,
tree t = lookup_name (c_parser_peek_token (parser)->value);
if (t == NULL_TREE)
- undeclared_variable (c_parser_peek_token (parser)->value,
- c_parser_peek_token (parser)->location);
+ undeclared_variable (c_parser_peek_token (parser)->location,
+ c_parser_peek_token (parser)->value);
else if (t == error_mark_node)
;
else if (kind != 0)
{
- tree u = build_omp_clause (kind);
+ tree u = build_omp_clause (clause_loc, kind);
OMP_CLAUSE_DECL (u) = t;
OMP_CLAUSE_CHAIN (u) = list;
list = u;
@@ -7060,9 +7135,12 @@ static tree
c_parser_omp_var_list_parens (c_parser *parser, enum omp_clause_code kind,
tree list)
{
+ /* The clauses location. */
+ location_t loc = c_parser_peek_token (parser)->location;
+
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
- list = c_parser_omp_variable_list (parser, kind, list);
+ list = c_parser_omp_variable_list (parser, loc, kind, list);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
}
return list;
@@ -7097,7 +7175,7 @@ c_parser_omp_clause_collapse (c_parser *parser, tree list)
"collapse argument needs positive constant integer expression");
return list;
}
- c = build_omp_clause (OMP_CLAUSE_COLLAPSE);
+ c = build_omp_clause (loc, OMP_CLAUSE_COLLAPSE);
OMP_CLAUSE_COLLAPSE_EXPR (c) = num;
OMP_CLAUSE_CHAIN (c) = list;
return c;
@@ -7128,6 +7206,7 @@ static tree
c_parser_omp_clause_default (c_parser *parser, tree list)
{
enum omp_clause_default_kind kind = OMP_CLAUSE_DEFAULT_UNSPECIFIED;
+ location_t loc = c_parser_peek_token (parser)->location;
tree c;
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
@@ -7167,7 +7246,7 @@ c_parser_omp_clause_default (c_parser *parser, tree list)
return list;
check_no_duplicate_clause (list, OMP_CLAUSE_DEFAULT, "default");
- c = build_omp_clause (OMP_CLAUSE_DEFAULT);
+ c = build_omp_clause (loc, OMP_CLAUSE_DEFAULT);
OMP_CLAUSE_CHAIN (c) = list;
OMP_CLAUSE_DEFAULT_KIND (c) = kind;
@@ -7189,6 +7268,7 @@ c_parser_omp_clause_firstprivate (c_parser *parser, tree list)
static tree
c_parser_omp_clause_if (c_parser *parser, tree list)
{
+ location_t loc = c_parser_peek_token (parser)->location;
if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
{
tree t = c_parser_paren_condition (parser);
@@ -7196,7 +7276,7 @@ c_parser_omp_clause_if (c_parser *parser, tree list)
check_no_duplicate_clause (list, OMP_CLAUSE_IF, "if");
- c = build_omp_clause (OMP_CLAUSE_IF);
+ c = build_omp_clause (loc, OMP_CLAUSE_IF);
OMP_CLAUSE_IF_EXPR (c) = t;
OMP_CLAUSE_CHAIN (c) = list;
list = c;
@@ -7223,10 +7303,11 @@ static tree
c_parser_omp_clause_nowait (c_parser *parser ATTRIBUTE_UNUSED, tree list)
{
tree c;
+ location_t loc = c_parser_peek_token (parser)->location;
check_no_duplicate_clause (list, OMP_CLAUSE_NOWAIT, "nowait");
- c = build_omp_clause (OMP_CLAUSE_NOWAIT);
+ c = build_omp_clause (loc, OMP_CLAUSE_NOWAIT);
OMP_CLAUSE_CHAIN (c) = list;
return c;
}
@@ -7237,6 +7318,7 @@ c_parser_omp_clause_nowait (c_parser *parser ATTRIBUTE_UNUSED, tree list)
static tree
c_parser_omp_clause_num_threads (c_parser *parser, tree list)
{
+ location_t num_threads_loc = c_parser_peek_token (parser)->location;
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
location_t expr_loc = c_parser_peek_token (parser)->location;
@@ -7254,6 +7336,8 @@ c_parser_omp_clause_num_threads (c_parser *parser, tree list)
/* Attempt to statically determine when the number isn't positive. */
c = fold_build2 (LE_EXPR, boolean_type_node, t,
build_int_cst (TREE_TYPE (t), 0));
+ if (CAN_HAVE_LOCATION_P (c))
+ SET_EXPR_LOCATION (c, expr_loc);
if (c == boolean_true_node)
{
warning_at (expr_loc, 0,
@@ -7263,7 +7347,7 @@ c_parser_omp_clause_num_threads (c_parser *parser, tree list)
check_no_duplicate_clause (list, OMP_CLAUSE_NUM_THREADS, "num_threads");
- c = build_omp_clause (OMP_CLAUSE_NUM_THREADS);
+ c = build_omp_clause (num_threads_loc, OMP_CLAUSE_NUM_THREADS);
OMP_CLAUSE_NUM_THREADS_EXPR (c) = t;
OMP_CLAUSE_CHAIN (c) = list;
list = c;
@@ -7276,14 +7360,16 @@ c_parser_omp_clause_num_threads (c_parser *parser, tree list)
ordered */
static tree
-c_parser_omp_clause_ordered (c_parser *parser ATTRIBUTE_UNUSED, tree list)
+c_parser_omp_clause_ordered (c_parser *parser, tree list)
{
tree c;
check_no_duplicate_clause (list, OMP_CLAUSE_ORDERED, "ordered");
- c = build_omp_clause (OMP_CLAUSE_ORDERED);
+ c = build_omp_clause (c_parser_peek_token (parser)->location,
+ OMP_CLAUSE_ORDERED);
OMP_CLAUSE_CHAIN (c) = list;
+
return c;
}
@@ -7305,6 +7391,7 @@ c_parser_omp_clause_private (c_parser *parser, tree list)
static tree
c_parser_omp_clause_reduction (c_parser *parser, tree list)
{
+ location_t clause_loc = c_parser_peek_token (parser)->location;
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
enum tree_code code;
@@ -7347,7 +7434,8 @@ c_parser_omp_clause_reduction (c_parser *parser, tree list)
{
tree nl, c;
- nl = c_parser_omp_variable_list (parser, OMP_CLAUSE_REDUCTION, list);
+ nl = c_parser_omp_variable_list (parser, clause_loc,
+ OMP_CLAUSE_REDUCTION, list);
for (c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
OMP_CLAUSE_REDUCTION_CODE (c) = code;
@@ -7370,11 +7458,12 @@ static tree
c_parser_omp_clause_schedule (c_parser *parser, tree list)
{
tree c, t;
+ location_t loc = c_parser_peek_token (parser)->location;
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
return list;
- c = build_omp_clause (OMP_CLAUSE_SCHEDULE);
+ c = build_omp_clause (loc, OMP_CLAUSE_SCHEDULE);
if (c_parser_next_token_is (parser, CPP_NAME))
{
@@ -7470,8 +7559,10 @@ c_parser_omp_clause_untied (c_parser *parser ATTRIBUTE_UNUSED, tree list)
/* FIXME: Should we allow duplicates? */
check_no_duplicate_clause (list, OMP_CLAUSE_UNTIED, "untied");
- c = build_omp_clause (OMP_CLAUSE_UNTIED);
+ c = build_omp_clause (c_parser_peek_token (parser)->location,
+ OMP_CLAUSE_UNTIED);
OMP_CLAUSE_CHAIN (c) = list;
+
return c;
}
@@ -7607,10 +7698,12 @@ c_parser_omp_structured_block (c_parser *parser)
binop:
+, *, -, /, &, ^, |, <<, >>
- where x is an lvalue expression with scalar type. */
+ where x is an lvalue expression with scalar type.
+
+ LOC is the location of the #pragma token. */
static void
-c_parser_omp_atomic (c_parser *parser)
+c_parser_omp_atomic (location_t loc, c_parser *parser)
{
tree lhs, rhs;
tree stmt;
@@ -7679,13 +7772,16 @@ c_parser_omp_atomic (c_parser *parser)
}
c_parser_consume_token (parser);
- rhs_expr = c_parser_expression (parser);
- rhs_expr = default_function_array_conversion (rhs_expr);
+ {
+ location_t rhs_loc = c_parser_peek_token (parser)->location;
+ rhs_expr = c_parser_expression (parser);
+ rhs_expr = default_function_array_conversion (rhs_loc, rhs_expr);
+ }
rhs = rhs_expr.value;
rhs = c_fully_fold (rhs, false, NULL);
break;
}
- stmt = c_finish_omp_atomic (code, lhs, rhs);
+ stmt = c_finish_omp_atomic (loc, code, lhs, rhs);
if (stmt != error_mark_node)
add_stmt (stmt);
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
@@ -7699,19 +7795,21 @@ c_parser_omp_atomic (c_parser *parser)
static void
c_parser_omp_barrier (c_parser *parser)
{
+ location_t loc = c_parser_peek_token (parser)->location;
c_parser_consume_pragma (parser);
c_parser_skip_to_pragma_eol (parser);
- c_finish_omp_barrier ();
+ c_finish_omp_barrier (loc);
}
/* OpenMP 2.5:
# pragma omp critical [(name)] new-line
structured-block
-*/
+
+ LOC is the location of the #pragma itself. */
static tree
-c_parser_omp_critical (c_parser *parser)
+c_parser_omp_critical (location_t loc, c_parser *parser)
{
tree stmt, name = NULL;
@@ -7732,7 +7830,7 @@ c_parser_omp_critical (c_parser *parser)
c_parser_skip_to_pragma_eol (parser);
stmt = c_parser_omp_structured_block (parser);
- return c_finish_omp_critical (stmt, name);
+ return c_finish_omp_critical (loc, stmt, name);
}
/* OpenMP 2.5:
@@ -7744,6 +7842,7 @@ c_parser_omp_critical (c_parser *parser)
static void
c_parser_omp_flush (c_parser *parser)
{
+ location_t loc = c_parser_peek_token (parser)->location;
c_parser_consume_pragma (parser);
if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ERROR, NULL);
@@ -7751,21 +7850,23 @@ c_parser_omp_flush (c_parser *parser)
c_parser_error (parser, "expected %<(%> or end of line");
c_parser_skip_to_pragma_eol (parser);
- c_finish_omp_flush ();
+ c_finish_omp_flush (loc);
}
/* Parse the restricted form of the for statement allowed by OpenMP.
The real trick here is to determine the loop control variable early
- so that we can push a new decl if necessary to make it private. */
+ so that we can push a new decl if necessary to make it private.
+ LOC is the location of the OMP in "#pragma omp". */
static tree
-c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
+c_parser_omp_for_loop (location_t loc,
+ c_parser *parser, tree clauses, tree *par_clauses)
{
tree decl, cond, incr, save_break, save_cont, body, init, stmt, cl;
tree declv, condv, incrv, initv, for_block = NULL, ret = NULL;
- location_t loc;
bool fail = false, open_brace_parsed = false;
int i, collapse = 1, nbraces = 0;
+ location_t for_loc;
for (cl = clauses; cl; cl = OMP_CLAUSE_CHAIN (cl))
if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_COLLAPSE)
@@ -7783,7 +7884,7 @@ c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
c_parser_error (parser, "for statement expected");
return NULL;
}
- loc = c_parser_peek_token (parser)->location;
+ for_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
for (i = 0; i < collapse; i++)
@@ -7800,7 +7901,7 @@ c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
for_block
= tree_cons (NULL, c_begin_compound_stmt (true), for_block);
c_parser_declaration_or_fndef (parser, true, true, true, true);
- decl = check_for_loop_decls ();
+ decl = check_for_loop_decls (for_loc);
if (decl == NULL)
goto error_init;
if (DECL_INITIAL (decl) == error_mark_node)
@@ -7818,14 +7919,14 @@ c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
decl = decl_exp.value;
c_parser_require (parser, CPP_EQ, "expected %<=%>");
- init_loc = c_parser_peek_token (parser)->location;
+ init_loc = c_parser_peek_token (parser)->location;
init_exp = c_parser_expr_no_commas (parser, NULL);
- init_exp = default_function_array_conversion (init_exp);
+ init_exp = default_function_array_conversion (init_loc, init_exp);
init = build_modify_expr (init_loc, decl, decl_exp.original_type,
- NOP_EXPR, init_exp.value,
+ NOP_EXPR, init_loc, init_exp.value,
init_exp.original_type);
- init = c_process_expr_stmt (init);
+ init = c_process_expr_stmt (init_loc, init);
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
}
@@ -7873,8 +7974,8 @@ c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
{
location_t incr_loc = c_parser_peek_token (parser)->location;
- incr = c_process_expr_stmt (c_parser_expression (parser).value);
- protected_set_expr_location (incr, incr_loc);
+ incr = c_process_expr_stmt (incr_loc,
+ c_parser_expression (parser).value);
}
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
@@ -7937,14 +8038,19 @@ c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
if (open_brace_parsed)
{
+ location_t here = c_parser_peek_token (parser)->location;
stmt = c_begin_compound_stmt (true);
c_parser_compound_statement_nostart (parser);
- add_stmt (c_end_compound_stmt (stmt, true));
+ add_stmt (c_end_compound_stmt (here, stmt, true));
}
else
add_stmt (c_parser_c99_block_statement (parser));
if (c_cont_label)
- add_stmt (build1 (LABEL_EXPR, void_type_node, c_cont_label));
+ {
+ tree t = build1 (LABEL_EXPR, void_type_node, c_cont_label);
+ SET_EXPR_LOCATION (t, loc);
+ add_stmt (t);
+ }
body = pop_stmt_list (body);
c_break_label = save_break;
@@ -7964,10 +8070,11 @@ c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
c_parser_error (parser, "collapsed loops not perfectly nested");
while (nbraces)
{
+ location_t here = c_parser_peek_token (parser)->location;
stmt = c_begin_compound_stmt (true);
add_stmt (body);
c_parser_compound_statement_nostart (parser);
- body = c_end_compound_stmt (stmt, true);
+ body = c_end_compound_stmt (here, stmt, true);
nbraces--;
}
goto pop_scopes;
@@ -8007,7 +8114,8 @@ c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
/* Copy lastprivate (decl) clause to OMP_FOR_CLAUSES,
change it to shared (decl) in
OMP_PARALLEL_CLAUSES. */
- tree l = build_omp_clause (OMP_CLAUSE_LASTPRIVATE);
+ tree l = build_omp_clause (OMP_CLAUSE_LOCATION (*c),
+ OMP_CLAUSE_LASTPRIVATE);
OMP_CLAUSE_DECL (l) = OMP_CLAUSE_DECL (*c);
OMP_CLAUSE_CHAIN (l) = clauses;
clauses = l;
@@ -8022,7 +8130,10 @@ c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
pop_scopes:
while (for_block)
{
- stmt = c_end_compound_stmt (TREE_VALUE (for_block), true);
+ /* FIXME diagnostics: LOC below should be the actual location of
+ this particular for block. We need to build a list of
+ locations to go along with FOR_BLOCK. */
+ stmt = c_end_compound_stmt (loc, TREE_VALUE (for_block), true);
add_stmt (stmt);
for_block = TREE_CHAIN (for_block);
}
@@ -8032,6 +8143,8 @@ pop_scopes:
/* OpenMP 2.5:
#pragma omp for for-clause[optseq] new-line
for-loop
+
+ LOC is the location of the #pragma token.
*/
#define OMP_FOR_CLAUSE_MASK \
@@ -8045,7 +8158,7 @@ pop_scopes:
| (1u << PRAGMA_OMP_CLAUSE_NOWAIT))
static tree
-c_parser_omp_for (c_parser *parser)
+c_parser_omp_for (location_t loc, c_parser *parser)
{
tree block, clauses, ret;
@@ -8053,8 +8166,8 @@ c_parser_omp_for (c_parser *parser)
"#pragma omp for");
block = c_begin_compound_stmt (true);
- ret = c_parser_omp_for_loop (parser, clauses, NULL);
- block = c_end_compound_stmt (block, true);
+ ret = c_parser_omp_for_loop (loc, parser, clauses, NULL);
+ block = c_end_compound_stmt (loc, block, true);
add_stmt (block);
return ret;
@@ -8063,25 +8176,29 @@ c_parser_omp_for (c_parser *parser)
/* OpenMP 2.5:
# pragma omp master new-line
structured-block
+
+ LOC is the location of the #pragma token.
*/
static tree
-c_parser_omp_master (c_parser *parser)
+c_parser_omp_master (location_t loc, c_parser *parser)
{
c_parser_skip_to_pragma_eol (parser);
- return c_finish_omp_master (c_parser_omp_structured_block (parser));
+ return c_finish_omp_master (loc, c_parser_omp_structured_block (parser));
}
/* OpenMP 2.5:
# pragma omp ordered new-line
structured-block
+
+ LOC is the location of the #pragma itself.
*/
static tree
-c_parser_omp_ordered (c_parser *parser)
+c_parser_omp_ordered (location_t loc, c_parser *parser)
{
c_parser_skip_to_pragma_eol (parser);
- return c_finish_omp_ordered (c_parser_omp_structured_block (parser));
+ return c_finish_omp_ordered (loc, c_parser_omp_structured_block (parser));
}
/* OpenMP 2.5:
@@ -8091,15 +8208,18 @@ c_parser_omp_ordered (c_parser *parser)
section-sequence:
section-directive[opt] structured-block
- section-sequence section-directive structured-block */
+ section-sequence section-directive structured-block
+
+ SECTIONS_LOC is the location of the #pragma omp sections. */
static tree
-c_parser_omp_sections_scope (c_parser *parser)
+c_parser_omp_sections_scope (location_t sections_loc, c_parser *parser)
{
tree stmt, substmt;
bool error_suppress = false;
location_t loc;
+ loc = c_parser_peek_token (parser)->location;
if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
{
/* Avoid skipping until the end of the block. */
@@ -8109,7 +8229,6 @@ c_parser_omp_sections_scope (c_parser *parser)
stmt = push_stmt_list ();
- loc = c_parser_peek_token (parser)->location;
if (c_parser_peek_token (parser)->pragma_kind != PRAGMA_OMP_SECTION)
{
substmt = push_stmt_list ();
@@ -8163,6 +8282,7 @@ c_parser_omp_sections_scope (c_parser *parser)
substmt = pop_stmt_list (stmt);
stmt = make_node (OMP_SECTIONS);
+ SET_EXPR_LOCATION (stmt, sections_loc);
TREE_TYPE (stmt) = void_type_node;
OMP_SECTIONS_BODY (stmt) = substmt;
@@ -8172,6 +8292,8 @@ c_parser_omp_sections_scope (c_parser *parser)
/* OpenMP 2.5:
# pragma omp sections sections-clause[optseq] newline
sections-scope
+
+ LOC is the location of the #pragma token.
*/
#define OMP_SECTIONS_CLAUSE_MASK \
@@ -8182,7 +8304,7 @@ c_parser_omp_sections_scope (c_parser *parser)
| (1u << PRAGMA_OMP_CLAUSE_NOWAIT))
static tree
-c_parser_omp_sections (c_parser *parser)
+c_parser_omp_sections (location_t loc, c_parser *parser)
{
tree block, clauses, ret;
@@ -8190,10 +8312,10 @@ c_parser_omp_sections (c_parser *parser)
"#pragma omp sections");
block = c_begin_compound_stmt (true);
- ret = c_parser_omp_sections_scope (parser);
+ ret = c_parser_omp_sections_scope (loc, parser);
if (ret)
OMP_SECTIONS_CLAUSES (ret) = clauses;
- block = c_end_compound_stmt (block, true);
+ block = c_end_compound_stmt (loc, block, true);
add_stmt (block);
return ret;
@@ -8203,6 +8325,8 @@ c_parser_omp_sections (c_parser *parser)
# pragma parallel parallel-clause new-line
# pragma parallel for parallel-for-clause new-line
# pragma parallel sections parallel-sections-clause new-line
+
+ LOC is the location of the #pragma token.
*/
#define OMP_PARALLEL_CLAUSE_MASK \
@@ -8216,7 +8340,7 @@ c_parser_omp_sections (c_parser *parser)
| (1u << PRAGMA_OMP_CLAUSE_NUM_THREADS))
static tree
-c_parser_omp_parallel (c_parser *parser)
+c_parser_omp_parallel (location_t loc, c_parser *parser)
{
enum pragma_kind p_kind = PRAGMA_OMP_PARALLEL;
const char *p_name = "#pragma omp parallel";
@@ -8251,24 +8375,24 @@ c_parser_omp_parallel (c_parser *parser)
case PRAGMA_OMP_PARALLEL:
block = c_begin_omp_parallel ();
c_parser_statement (parser);
- stmt = c_finish_omp_parallel (clauses, block);
+ stmt = c_finish_omp_parallel (loc, clauses, block);
break;
case PRAGMA_OMP_PARALLEL_FOR:
block = c_begin_omp_parallel ();
- c_split_parallel_clauses (clauses, &par_clause, &ws_clause);
- c_parser_omp_for_loop (parser, ws_clause, &par_clause);
- stmt = c_finish_omp_parallel (par_clause, block);
+ c_split_parallel_clauses (loc, clauses, &par_clause, &ws_clause);
+ c_parser_omp_for_loop (loc, parser, ws_clause, &par_clause);
+ stmt = c_finish_omp_parallel (loc, par_clause, block);
OMP_PARALLEL_COMBINED (stmt) = 1;
break;
case PRAGMA_OMP_PARALLEL_SECTIONS:
block = c_begin_omp_parallel ();
- c_split_parallel_clauses (clauses, &par_clause, &ws_clause);
- stmt = c_parser_omp_sections_scope (parser);
+ c_split_parallel_clauses (loc, clauses, &par_clause, &ws_clause);
+ stmt = c_parser_omp_sections_scope (loc, parser);
if (stmt)
OMP_SECTIONS_CLAUSES (stmt) = ws_clause;
- stmt = c_finish_omp_parallel (par_clause, block);
+ stmt = c_finish_omp_parallel (loc, par_clause, block);
OMP_PARALLEL_COMBINED (stmt) = 1;
break;
@@ -8282,6 +8406,8 @@ c_parser_omp_parallel (c_parser *parser)
/* OpenMP 2.5:
# pragma omp single single-clause[optseq] new-line
structured-block
+
+ LOC is the location of the #pragma.
*/
#define OMP_SINGLE_CLAUSE_MASK \
@@ -8291,9 +8417,10 @@ c_parser_omp_parallel (c_parser *parser)
| (1u << PRAGMA_OMP_CLAUSE_NOWAIT))
static tree
-c_parser_omp_single (c_parser *parser)
+c_parser_omp_single (location_t loc, c_parser *parser)
{
tree stmt = make_node (OMP_SINGLE);
+ SET_EXPR_LOCATION (stmt, loc);
TREE_TYPE (stmt) = void_type_node;
OMP_SINGLE_CLAUSES (stmt)
@@ -8306,6 +8433,8 @@ c_parser_omp_single (c_parser *parser)
/* OpenMP 3.0:
# pragma omp task task-clause[optseq] new-line
+
+ LOC is the location of the #pragma.
*/
#define OMP_TASK_CLAUSE_MASK \
@@ -8317,7 +8446,7 @@ c_parser_omp_single (c_parser *parser)
| (1u << PRAGMA_OMP_CLAUSE_SHARED))
static tree
-c_parser_omp_task (c_parser *parser)
+c_parser_omp_task (location_t loc, c_parser *parser)
{
tree clauses, block;
@@ -8326,7 +8455,7 @@ c_parser_omp_task (c_parser *parser)
block = c_begin_omp_task ();
c_parser_statement (parser);
- return c_finish_omp_task (clauses, block);
+ return c_finish_omp_task (loc, clauses, block);
}
/* OpenMP 3.0:
@@ -8336,10 +8465,11 @@ c_parser_omp_task (c_parser *parser)
static void
c_parser_omp_taskwait (c_parser *parser)
{
+ location_t loc = c_parser_peek_token (parser)->location;
c_parser_consume_pragma (parser);
c_parser_skip_to_pragma_eol (parser);
- c_finish_omp_taskwait ();
+ c_finish_omp_taskwait (loc);
}
/* Main entry point to parsing most OpenMP pragmas. */
@@ -8364,38 +8494,38 @@ c_parser_omp_construct (c_parser *parser)
switch (p_kind)
{
case PRAGMA_OMP_ATOMIC:
- c_parser_omp_atomic (parser);
+ c_parser_omp_atomic (loc, parser);
return;
case PRAGMA_OMP_CRITICAL:
- stmt = c_parser_omp_critical (parser);
+ stmt = c_parser_omp_critical (loc, parser);
break;
case PRAGMA_OMP_FOR:
- stmt = c_parser_omp_for (parser);
+ stmt = c_parser_omp_for (loc, parser);
break;
case PRAGMA_OMP_MASTER:
- stmt = c_parser_omp_master (parser);
+ stmt = c_parser_omp_master (loc, parser);
break;
case PRAGMA_OMP_ORDERED:
- stmt = c_parser_omp_ordered (parser);
+ stmt = c_parser_omp_ordered (loc, parser);
break;
case PRAGMA_OMP_PARALLEL:
- stmt = c_parser_omp_parallel (parser);
+ stmt = c_parser_omp_parallel (loc, parser);
break;
case PRAGMA_OMP_SECTIONS:
- stmt = c_parser_omp_sections (parser);
+ stmt = c_parser_omp_sections (loc, parser);
break;
case PRAGMA_OMP_SINGLE:
- stmt = c_parser_omp_single (parser);
+ stmt = c_parser_omp_single (loc, parser);
break;
case PRAGMA_OMP_TASK:
- stmt = c_parser_omp_task (parser);
+ stmt = c_parser_omp_task (loc, parser);
break;
default:
gcc_unreachable ();
}
if (stmt)
- SET_EXPR_LOCATION (stmt, loc);
+ gcc_assert (EXPR_LOCATION (stmt) != UNKNOWN_LOCATION);
}
@@ -8406,8 +8536,10 @@ static void
c_parser_omp_threadprivate (c_parser *parser)
{
tree vars, t;
+ location_t loc;
c_parser_consume_pragma (parser);
+ loc = c_parser_peek_token (parser)->location;
vars = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ERROR, NULL);
/* Mark every variable in VARS to be assigned thread local storage. */
@@ -8415,18 +8547,24 @@ c_parser_omp_threadprivate (c_parser *parser)
{
tree v = TREE_PURPOSE (t);
+ /* FIXME diagnostics: Ideally we should keep individual
+ locations for all the variables in the var list to make the
+ following errors more precise. Perhaps
+ c_parser_omp_var_list_parens() should construct a list of
+ locations to go along with the var list. */
+
/* If V had already been marked threadprivate, it doesn't matter
whether it had been used prior to this point. */
if (TREE_CODE (v) != VAR_DECL)
- error ("%qD is not a variable", v);
+ error_at (loc, "%qD is not a variable", v);
else if (TREE_USED (v) && !C_DECL_THREADPRIVATE_P (v))
- error ("%qE declared %<threadprivate%> after first use", v);
+ error_at (loc, "%qE declared %<threadprivate%> after first use", v);
else if (! TREE_STATIC (v) && ! DECL_EXTERNAL (v))
- error ("automatic variable %qE cannot be %<threadprivate%>", v);
+ error_at (loc, "automatic variable %qE cannot be %<threadprivate%>", v);
else if (TREE_TYPE (v) == error_mark_node)
;
else if (! COMPLETE_TYPE_P (TREE_TYPE (v)))
- error ("%<threadprivate%> %qE has incomplete type", v);
+ error_at (loc, "%<threadprivate%> %qE has incomplete type", v);
else
{
if (! DECL_THREAD_LOCAL_P (v))
diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c
index 751c895d694..c91ee991dba 100644
--- a/gcc/c-pragma.c
+++ b/gcc/c-pragma.c
@@ -455,7 +455,8 @@ maybe_apply_pending_pragma_weaks (void)
if (TREE_VALUE (t) == NULL)
continue;
- decl = build_decl (FUNCTION_DECL, alias_id, default_function_type);
+ decl = build_decl (UNKNOWN_LOCATION,
+ FUNCTION_DECL, alias_id, default_function_type);
DECL_ARTIFICIAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
diff --git a/gcc/c-semantics.c b/gcc/c-semantics.c
index b6c3a27c5ab..2bfad472db0 100644
--- a/gcc/c-semantics.c
+++ b/gcc/c-semantics.c
@@ -103,12 +103,12 @@ pop_stmt_list (tree t)
/* Build a generic statement based on the given type of node and
arguments. Similar to `build_nt', except that we set
- EXPR_LOCATION to be the current source location. */
+ EXPR_LOCATION to LOC. */
/* ??? This should be obsolete with the lineno_stmt productions
in the grammar. */
tree
-build_stmt (enum tree_code code, ...)
+build_stmt (location_t loc, enum tree_code code, ...)
{
tree ret;
int length, i;
@@ -123,7 +123,7 @@ build_stmt (enum tree_code code, ...)
ret = make_node (code);
TREE_TYPE (ret) = void_type_node;
length = TREE_CODE_LENGTH (code);
- SET_EXPR_LOCATION (ret, input_location);
+ SET_EXPR_LOCATION (ret, loc);
/* TREE_SIDE_EFFECTS will already be set for statements with
implicit side effects. Here we make sure it is set for other
@@ -148,7 +148,8 @@ build_stmt (enum tree_code code, ...)
/* Create a CASE_LABEL_EXPR tree node and return it. */
tree
-build_case_label (tree low_value, tree high_value, tree label_decl)
+build_case_label (location_t loc,
+ tree low_value, tree high_value, tree label_decl)
{
- return build_stmt (CASE_LABEL_EXPR, low_value, high_value, label_decl);
+ return build_stmt (loc, CASE_LABEL_EXPR, low_value, high_value, label_decl);
}
diff --git a/gcc/c-tree.h b/gcc/c-tree.h
index 880cc1b877a..d6062177375 100644
--- a/gcc/c-tree.h
+++ b/gcc/c-tree.h
@@ -360,7 +360,7 @@ struct c_declarator {
enum c_declarator_kind kind;
/* Except for cdk_id, the contained declarator. For cdk_id, NULL. */
struct c_declarator *declarator;
- location_t id_loc; /* Currently only set for cdk_id. */
+ location_t id_loc; /* Currently only set for cdk_id, cdk_array. */
union {
/* For identifiers, an IDENTIFIER_NODE or NULL_TREE if an abstract
declarator. */
@@ -505,26 +505,27 @@ extern void c_init_decl_processing (void);
extern void c_dup_lang_specific_decl (tree);
extern void c_print_identifier (FILE *, tree, int);
extern int quals_from_declspecs (const struct c_declspecs *);
-extern struct c_declarator *build_array_declarator (tree, struct c_declspecs *,
+extern struct c_declarator *build_array_declarator (location_t, tree,
+ struct c_declspecs *,
bool, bool);
-extern tree build_enumerator (struct c_enum_contents *, tree, tree, location_t);
-extern tree check_for_loop_decls (void);
+extern tree build_enumerator (location_t, struct c_enum_contents *, tree, tree);
+extern tree check_for_loop_decls (location_t);
extern void mark_forward_parm_decls (void);
extern void declare_parm_level (void);
-extern void undeclared_variable (tree, location_t);
+extern void undeclared_variable (location_t, tree);
extern tree declare_label (tree);
extern tree define_label (location_t, tree);
extern void c_maybe_initialize_eh (void);
-extern void finish_decl (tree, tree, tree, tree);
+extern void finish_decl (tree, location_t, tree, tree, tree);
extern tree finish_enum (tree, tree, tree);
extern void finish_function (void);
-extern tree finish_struct (tree, tree, tree, bool, VEC(tree,heap) *);
+extern tree finish_struct (location_t, tree, tree, tree, bool, VEC(tree,heap) *);
extern struct c_arg_info *get_parm_info (bool);
extern tree grokfield (location_t, struct c_declarator *,
struct c_declspecs *, tree, tree *);
extern tree groktypename (struct c_type_name *, tree *, bool *);
extern tree grokparm (const struct c_parm *);
-extern tree implicitly_declare (tree);
+extern tree implicitly_declare (location_t, tree);
extern void keep_next_level (void);
extern void pending_xref_error (void);
extern void c_push_function_context (void);
@@ -536,16 +537,15 @@ extern tree c_builtin_function (tree);
extern tree c_builtin_function_ext_scope (tree);
extern void shadow_tag (const struct c_declspecs *);
extern void shadow_tag_warned (const struct c_declspecs *, int);
-extern tree start_enum (struct c_enum_contents *, tree, location_t);
+extern tree start_enum (location_t, struct c_enum_contents *, tree);
extern int start_function (struct c_declspecs *, struct c_declarator *, tree);
extern tree start_decl (struct c_declarator *, struct c_declspecs *, bool,
tree);
-extern tree start_struct (enum tree_code, tree, bool *, VEC(tree,heap) **,
- location_t);
+extern tree start_struct (location_t, enum tree_code, tree, bool *, VEC(tree,heap) **);
extern void store_parm_decls (void);
extern void store_parm_decls_from (struct c_arg_info *);
extern tree xref_tag (enum tree_code, tree);
-extern struct c_typespec parser_xref_tag (enum tree_code, tree, location_t);
+extern struct c_typespec parser_xref_tag (location_t, enum tree_code, tree);
extern int c_expand_decl (tree);
extern struct c_parm *build_c_parm (struct c_declspecs *, tree,
struct c_declarator *);
@@ -594,24 +594,25 @@ extern bool c_vla_type_p (const_tree);
extern bool c_mark_addressable (tree);
extern void c_incomplete_type_error (const_tree, const_tree);
extern tree c_type_promotes_to (tree);
-extern struct c_expr default_function_array_conversion (struct c_expr);
+extern struct c_expr default_function_array_conversion (location_t,
+ struct c_expr);
extern tree composite_type (tree, tree);
-extern tree build_component_ref (tree, tree);
-extern tree build_array_ref (tree, tree, location_t);
-extern tree build_external_ref (tree, int, location_t, tree *);
+extern tree build_component_ref (location_t, tree, tree);
+extern tree build_array_ref (location_t, tree, tree);
+extern tree build_external_ref (location_t, tree, int, tree *);
extern void pop_maybe_used (bool);
-extern struct c_expr c_expr_sizeof_expr (struct c_expr);
-extern struct c_expr c_expr_sizeof_type (struct c_type_name *);
-extern struct c_expr parser_build_unary_op (enum tree_code, struct c_expr,
- location_t);
+extern struct c_expr c_expr_sizeof_expr (location_t, struct c_expr);
+extern struct c_expr c_expr_sizeof_type (location_t, struct c_type_name *);
+extern struct c_expr parser_build_unary_op (location_t, enum tree_code,
+ struct c_expr);
extern struct c_expr parser_build_binary_op (location_t,
enum tree_code, struct c_expr,
struct c_expr);
extern tree build_conditional_expr (location_t, tree, bool, tree, tree);
-extern tree build_compound_expr (tree, tree);
-extern tree c_cast_expr (struct c_type_name *, tree, location_t);
-extern tree build_c_cast (tree, tree);
-extern void store_init_value (tree, tree, tree);
+extern tree build_compound_expr (location_t, tree, tree);
+extern tree c_cast_expr (location_t, struct c_type_name *, tree);
+extern tree build_c_cast (location_t, tree, tree);
+extern void store_init_value (location_t, tree, tree, tree);
extern void error_init (const char *);
extern void pedwarn_init (location_t, int opt, const char *);
extern void maybe_warn_string_init (tree, struct c_expr);
@@ -623,34 +624,34 @@ extern struct c_expr pop_init_level (int);
extern void set_init_index (tree, tree);
extern void set_init_label (tree);
extern void process_init_element (struct c_expr, bool);
-extern tree build_compound_literal (tree, tree, bool);
-extern void check_compound_literal_type (struct c_type_name *, location_t);
-extern tree c_start_case (tree);
+extern tree build_compound_literal (location_t, tree, tree, bool);
+extern void check_compound_literal_type (location_t, struct c_type_name *);
+extern tree c_start_case (location_t, location_t, tree);
extern void c_finish_case (tree);
-extern tree build_asm_expr (tree, tree, tree, tree, bool);
+extern tree build_asm_expr (location_t, tree, tree, tree, tree, bool);
extern tree build_asm_stmt (tree, tree);
extern int c_types_compatible_p (tree, tree);
extern tree c_begin_compound_stmt (bool);
-extern tree c_end_compound_stmt (tree, bool);
+extern tree c_end_compound_stmt (location_t, tree, bool);
extern void c_finish_if_stmt (location_t, tree, tree, tree, bool);
extern void c_finish_loop (location_t, tree, tree, tree, tree, tree, bool);
extern tree c_begin_stmt_expr (void);
-extern tree c_finish_stmt_expr (tree);
-extern tree c_process_expr_stmt (tree);
-extern tree c_finish_expr_stmt (tree);
-extern tree c_finish_return (tree, tree);
-extern tree c_finish_bc_stmt (tree *, bool);
-extern tree c_finish_goto_label (tree);
-extern tree c_finish_goto_ptr (tree);
+extern tree c_finish_stmt_expr (location_t, tree);
+extern tree c_process_expr_stmt (location_t, tree);
+extern tree c_finish_expr_stmt (location_t, tree);
+extern tree c_finish_return (location_t, tree, tree);
+extern tree c_finish_bc_stmt (location_t, tree *, bool);
+extern tree c_finish_goto_label (location_t, tree);
+extern tree c_finish_goto_ptr (location_t, tree);
extern void c_begin_vm_scope (unsigned int);
extern void c_end_vm_scope (unsigned int);
extern tree c_expr_to_decl (tree, bool *, bool *);
extern tree c_begin_omp_parallel (void);
-extern tree c_finish_omp_parallel (tree, tree);
+extern tree c_finish_omp_parallel (location_t, tree, tree);
extern tree c_begin_omp_task (void);
-extern tree c_finish_omp_task (tree, tree);
+extern tree c_finish_omp_task (location_t, tree, tree);
extern tree c_finish_omp_clauses (tree);
-extern tree c_build_va_arg (tree, tree, location_t);
+extern tree c_build_va_arg (location_t, tree, tree);
/* Set to 0 at beginning of a function definition, set to 1 if
a return statement that specifies a return value is seen. */
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 6c86b92de6d..978e95c4b45 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -98,7 +98,7 @@ static void push_member_name (tree);
static int spelling_length (void);
static char *print_spelling (char *);
static void warning_init (int, const char *);
-static tree digest_init (tree, tree, tree, bool, bool, int);
+static tree digest_init (location_t, tree, tree, tree, bool, bool, int);
static void output_init_element (tree, tree, bool, tree, tree, int, bool);
static void output_pending_init_elements (int);
static int set_designator (int);
@@ -1659,7 +1659,7 @@ decl_constant_value (tree decl)
/* Convert the array expression EXP to a pointer. */
static tree
-array_to_pointer_conversion (tree exp)
+array_to_pointer_conversion (location_t loc, tree exp)
{
tree orig_exp = exp;
tree type = TREE_TYPE (exp);
@@ -1679,13 +1679,13 @@ array_to_pointer_conversion (tree exp)
if (TREE_CODE (exp) == INDIRECT_REF)
return convert (ptrtype, TREE_OPERAND (exp, 0));
- adr = build_unary_op (EXPR_LOCATION (exp), ADDR_EXPR, exp, 1);
+ adr = build_unary_op (loc, ADDR_EXPR, exp, 1);
return convert (ptrtype, adr);
}
/* Convert the function expression EXP to a pointer. */
static tree
-function_to_pointer_conversion (tree exp)
+function_to_pointer_conversion (location_t loc, tree exp)
{
tree orig_exp = exp;
@@ -1696,15 +1696,17 @@ function_to_pointer_conversion (tree exp)
if (TREE_NO_WARNING (orig_exp))
TREE_NO_WARNING (exp) = 1;
- return build_unary_op (EXPR_LOCATION (exp), ADDR_EXPR, exp, 0);
+ return build_unary_op (loc, ADDR_EXPR, exp, 0);
}
/* Perform the default conversion of arrays and functions to pointers.
Return the result of converting EXP. For any other expression, just
- return EXP. */
+ return EXP.
+
+ LOC is the location of the expression. */
struct c_expr
-default_function_array_conversion (struct c_expr exp)
+default_function_array_conversion (location_t loc, struct c_expr exp)
{
tree orig_exp = exp.value;
tree type = TREE_TYPE (exp.value);
@@ -1739,11 +1741,11 @@ default_function_array_conversion (struct c_expr exp)
return exp;
}
- exp.value = array_to_pointer_conversion (exp.value);
+ exp.value = array_to_pointer_conversion (loc, exp.value);
}
break;
case FUNCTION_TYPE:
- exp.value = function_to_pointer_conversion (exp.value);
+ exp.value = function_to_pointer_conversion (loc, exp.value);
break;
default:
break;
@@ -1944,11 +1946,12 @@ lookup_field (tree decl, tree component)
return tree_cons (NULL_TREE, field, NULL_TREE);
}
-/* Make an expression to refer to the COMPONENT field of
- structure or union value DATUM. COMPONENT is an IDENTIFIER_NODE. */
+/* Make an expression to refer to the COMPONENT field of structure or
+ union value DATUM. COMPONENT is an IDENTIFIER_NODE. LOC is the
+ location of the COMPONENT_REF. */
tree
-build_component_ref (tree datum, tree component)
+build_component_ref (location_t loc, tree datum, tree component)
{
tree type = TREE_TYPE (datum);
enum tree_code code = TREE_CODE (type);
@@ -1973,7 +1976,7 @@ build_component_ref (tree datum, tree component)
if (!field)
{
- error ("%qT has no member named %qE", type, component);
+ error_at (loc, "%qT has no member named %qE", type, component);
return error_mark_node;
}
@@ -2006,6 +2009,7 @@ build_component_ref (tree datum, tree component)
ref = build3 (COMPONENT_REF, subtype, datum, subdatum,
NULL_TREE);
+ SET_EXPR_LOCATION (ref, loc);
if (TREE_READONLY (subdatum)
|| (use_datum_quals && TREE_READONLY (datum)))
TREE_READONLY (ref) = 1;
@@ -2025,8 +2029,9 @@ build_component_ref (tree datum, tree component)
return ref;
}
else if (code != ERROR_MARK)
- error ("request for member %qE in something not a structure or union",
- component);
+ error_at (loc,
+ "request for member %qE in something not a structure or union",
+ component);
return error_mark_node;
}
@@ -2113,7 +2118,7 @@ build_indirect_ref (location_t loc, tree ptr, const char *errorstring)
LOC is the location to use for the returned expression. */
tree
-build_array_ref (tree array, tree index, location_t loc)
+build_array_ref (location_t loc, tree array, tree index)
{
tree ret;
bool swapped = false;
@@ -2243,7 +2248,7 @@ build_array_ref (tree array, tree index, location_t loc)
for CONST_DECLs defined as enum constants. If the type of the
identifier is not available, *TYPE is set to NULL. */
tree
-build_external_ref (tree id, int fun, location_t loc, tree *type)
+build_external_ref (location_t loc, tree id, int fun, tree *type)
{
tree ref;
tree decl = lookup_name (id);
@@ -2260,14 +2265,14 @@ build_external_ref (tree id, int fun, location_t loc, tree *type)
}
else if (fun)
/* Implicit function declaration. */
- ref = implicitly_declare (id);
+ ref = implicitly_declare (loc, id);
else if (decl == error_mark_node)
/* Don't complain about something that's already been
complained about. */
return error_mark_node;
else
{
- undeclared_variable (id, loc);
+ undeclared_variable (loc, id);
return error_mark_node;
}
@@ -2393,7 +2398,7 @@ pop_maybe_used (bool used)
/* Return the result of sizeof applied to EXPR. */
struct c_expr
-c_expr_sizeof_expr (struct c_expr expr)
+c_expr_sizeof_expr (location_t loc, struct c_expr expr)
{
struct c_expr ret;
if (expr.value == error_mark_node)
@@ -2408,7 +2413,7 @@ c_expr_sizeof_expr (struct c_expr expr)
bool expr_const_operands = true;
tree folded_expr = c_fully_fold (expr.value, require_constant_value,
&expr_const_operands);
- ret.value = c_sizeof (TREE_TYPE (folded_expr));
+ ret.value = c_sizeof (loc, TREE_TYPE (folded_expr));
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
if (c_vla_type_p (TREE_TYPE (folded_expr)))
@@ -2417,6 +2422,7 @@ c_expr_sizeof_expr (struct c_expr expr)
ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
folded_expr, ret.value);
C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands;
+ SET_EXPR_LOCATION (ret.value, loc);
}
pop_maybe_used (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)));
}
@@ -2424,17 +2430,18 @@ c_expr_sizeof_expr (struct c_expr expr)
}
/* Return the result of sizeof applied to T, a structure for the type
- name passed to sizeof (rather than the type itself). */
+ name passed to sizeof (rather than the type itself). LOC is the
+ location of the original expression. */
struct c_expr
-c_expr_sizeof_type (struct c_type_name *t)
+c_expr_sizeof_type (location_t loc, struct c_type_name *t)
{
tree type;
struct c_expr ret;
tree type_expr = NULL_TREE;
bool type_expr_const = true;
type = groktypename (t, &type_expr, &type_expr_const);
- ret.value = c_sizeof (type);
+ ret.value = c_sizeof (loc, type);
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
@@ -2459,12 +2466,13 @@ c_expr_sizeof_type (struct c_type_name *t)
}
/* Build a function call to function FUNCTION with parameters PARAMS.
+ The function call is at LOC.
PARAMS is a list--a chain of TREE_LIST nodes--in which the
TREE_VALUE of each node is a parameter-expression.
FUNCTION's data type may be a function type or a pointer-to-function. */
tree
-build_function_call (tree function, tree params)
+build_function_call (location_t loc, tree function, tree params)
{
VEC(tree,gc) *vec;
tree ret;
@@ -2472,7 +2480,7 @@ build_function_call (tree function, tree params)
vec = VEC_alloc (tree, gc, list_length (params));
for (; params; params = TREE_CHAIN (params))
VEC_quick_push (tree, vec, TREE_VALUE (params));
- ret = build_function_call_vec (function, vec, NULL);
+ ret = build_function_call_vec (loc, function, vec, NULL);
VEC_free (tree, gc, vec);
return ret;
}
@@ -2486,7 +2494,7 @@ build_function_call (tree function, tree params)
PARAMS. */
tree
-build_function_call_vec (tree function, VEC(tree,gc) *params,
+build_function_call_vec (location_t loc, tree function, VEC(tree,gc) *params,
VEC(tree,gc) *origtypes)
{
tree fntype, fundecl = 0;
@@ -2506,7 +2514,7 @@ build_function_call_vec (tree function, VEC(tree,gc) *params,
resolve_overloaded_builtin and targetm.resolve_overloaded_builtin
handle all the type checking. The result is a complete expression
that implements this function call. */
- tem = resolve_overloaded_builtin (function, params);
+ tem = resolve_overloaded_builtin (loc, function, params);
if (tem)
return tem;
@@ -2514,7 +2522,7 @@ build_function_call_vec (tree function, VEC(tree,gc) *params,
fundecl = function;
}
if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
- function = function_to_pointer_conversion (function);
+ function = function_to_pointer_conversion (loc, function);
/* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF
expressions, like those used for ObjC messenger dispatches. */
@@ -2532,7 +2540,7 @@ build_function_call_vec (tree function, VEC(tree,gc) *params,
if (!(TREE_CODE (fntype) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
{
- error ("called object %qE is not a function", function);
+ error_at (loc, "called object %qE is not a function", function);
return error_mark_node;
}
@@ -2561,17 +2569,17 @@ build_function_call_vec (tree function, VEC(tree,gc) *params,
&& !comptypes (fntype, TREE_TYPE (tem)))
{
tree return_type = TREE_TYPE (fntype);
- tree trap = build_function_call (built_in_decls[BUILT_IN_TRAP],
+ tree trap = build_function_call (loc, built_in_decls[BUILT_IN_TRAP],
NULL_TREE);
int i;
/* This situation leads to run-time undefined behavior. We can't,
therefore, simply error unless we can prove that all possible
executions of the program must execute the code. */
- if (warning (0, "function called through a non-compatible type"))
+ if (warning_at (loc, 0, "function called through a non-compatible type"))
/* We can, however, treat "undefined" any way we please.
Call abort to encourage the user to fix the program. */
- inform (input_location, "if this code is reached, the program will abort");
+ inform (loc, "if this code is reached, the program will abort");
/* Before the abort, allow the function arguments to exit or
call longjmp. */
for (i = 0; i < nargs; i++)
@@ -2590,7 +2598,7 @@ build_function_call_vec (tree function, VEC(tree,gc) *params,
tree rhs;
if (AGGREGATE_TYPE_P (return_type))
- rhs = build_compound_literal (return_type,
+ rhs = build_compound_literal (loc, return_type,
build_constructor (return_type, 0),
false);
else
@@ -2856,7 +2864,8 @@ convert_arguments (tree typelist, VEC(tree,gc) *values,
and the actual arg is that enum type. */
;
else if (formal_prec != TYPE_PRECISION (type1))
- warning (OPT_Wtraditional_conversion, "passing argument %d of %qE "
+ warning (OPT_Wtraditional_conversion,
+ "passing argument %d of %qE "
"with different width due to prototype",
argnum, rname);
else if (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (type1))
@@ -2879,11 +2888,13 @@ convert_arguments (tree typelist, VEC(tree,gc) *values,
&& TYPE_UNSIGNED (valtype))
;
else if (TYPE_UNSIGNED (type))
- warning (OPT_Wtraditional_conversion, "passing argument %d of %qE "
+ warning (OPT_Wtraditional_conversion,
+ "passing argument %d of %qE "
"as unsigned due to prototype",
argnum, rname);
else
- warning (OPT_Wtraditional_conversion, "passing argument %d of %qE "
+ warning (OPT_Wtraditional_conversion,
+ "passing argument %d of %qE "
"as signed due to prototype", argnum, rname);
}
}
@@ -2957,7 +2968,7 @@ convert_arguments (tree typelist, VEC(tree,gc) *values,
*/
struct c_expr
-parser_build_unary_op (enum tree_code code, struct c_expr arg, location_t loc)
+parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg)
{
struct c_expr result;
@@ -2966,7 +2977,7 @@ parser_build_unary_op (enum tree_code code, struct c_expr arg, location_t loc)
result.original_type = NULL;
if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
- overflow_warning (result.value);
+ overflow_warning (loc, result.value);
return result;
}
@@ -3020,16 +3031,18 @@ parser_build_binary_op (location_t location, enum tree_code code,
{
if ((code1 == STRING_CST && !integer_zerop (arg2.value))
|| (code2 == STRING_CST && !integer_zerop (arg1.value)))
- warning (OPT_Waddress, "comparison with string literal results in unspecified behavior");
+ warning_at (location, OPT_Waddress,
+ "comparison with string literal results in unspecified behavior");
}
else if (TREE_CODE_CLASS (code) == tcc_comparison
&& (code1 == STRING_CST || code2 == STRING_CST))
- warning (OPT_Waddress, "comparison with string literal results in unspecified behavior");
+ warning_at (location, OPT_Waddress,
+ "comparison with string literal results in unspecified behavior");
if (TREE_OVERFLOW_P (result.value)
&& !TREE_OVERFLOW_P (arg1.value)
&& !TREE_OVERFLOW_P (arg2.value))
- overflow_warning (result.value);
+ overflow_warning (location, result.value);
/* Warn about comparisons of different enum types. */
if (warn_enum_compare
@@ -3478,7 +3491,8 @@ build_unary_op (location_t location,
return error_mark_node;
return build_binary_op (location, PLUS_EXPR,
(TREE_CODE (TREE_TYPE (op0)) == ARRAY_TYPE
- ? array_to_pointer_conversion (op0)
+ ? array_to_pointer_conversion (location,
+ op0)
: op0),
TREE_OPERAND (arg, 1), 1);
}
@@ -3755,7 +3769,7 @@ c_mark_addressable (tree exp)
IFEXP_BCP then the condition is a call to __builtin_constant_p, and
if folded to an integer constant then the unselected half may
contain arbitrary operations not normally permitted in constant
- expressions. */
+ expressions. Set the location of the expression to LOC. */
tree
build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
@@ -3983,7 +3997,7 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
result_type = void_type_node;
else
{
- error ("type mismatch in conditional expression");
+ error_at (colon_loc, "type mismatch in conditional expression");
return error_mark_node;
}
}
@@ -4032,14 +4046,17 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
if (ep_result_type)
ret = build1 (EXCESS_PRECISION_EXPR, ep_result_type, ret);
+ protected_set_expr_location (ret, colon_loc);
return ret;
}
/* Return a compound expression that performs two expressions and
- returns the value of the second of them. */
+ returns the value of the second of them.
+
+ LOC is the location of the COMPOUND_EXPR. */
tree
-build_compound_expr (tree expr1, tree expr2)
+build_compound_expr (location_t loc, tree expr1, tree expr2)
{
bool expr1_int_operands, expr2_int_operands;
tree eptype = NULL_TREE;
@@ -4075,8 +4092,8 @@ build_compound_expr (tree expr1, tree expr2)
&& CONVERT_EXPR_P (TREE_OPERAND (expr1, 1)))
; /* (void) a, (void) b, c */
else
- warning (OPT_Wunused_value,
- "left-hand operand of comma expression has no effect");
+ warning_at (loc, OPT_Wunused_value,
+ "left-hand operand of comma expression has no effect");
}
}
@@ -4085,7 +4102,7 @@ build_compound_expr (tree expr1, tree expr2)
`foo() + bar(), baz()' the result of the `+' operator is not used,
so we should issue a warning. */
else if (warn_unused_value)
- warn_if_unused_value (expr1, input_location);
+ warn_if_unused_value (expr1, loc);
if (expr2 == error_mark_node)
return error_mark_node;
@@ -4100,6 +4117,7 @@ build_compound_expr (tree expr1, tree expr2)
if (eptype)
ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
+ protected_set_expr_location (ret, loc);
return ret;
}
@@ -4190,10 +4208,11 @@ handle_warn_cast_qual (tree type, tree otype)
while (TREE_CODE (in_type) == POINTER_TYPE);
}
-/* Build an expression representing a cast to type TYPE of expression EXPR. */
+/* Build an expression representing a cast to type TYPE of expression EXPR.
+ LOC is the location of the cast-- typically the open paren of the cast. */
tree
-build_c_cast (tree type, tree expr)
+build_c_cast (location_t loc, tree type, tree expr)
{
tree value;
@@ -4215,13 +4234,13 @@ build_c_cast (tree type, tree expr)
if (TREE_CODE (type) == ARRAY_TYPE)
{
- error ("cast specifies array type");
+ error_at (loc, "cast specifies array type");
return error_mark_node;
}
if (TREE_CODE (type) == FUNCTION_TYPE)
{
- error ("cast specifies function type");
+ error_at (loc, "cast specifies function type");
return error_mark_node;
}
@@ -4236,7 +4255,7 @@ build_c_cast (tree type, tree expr)
{
if (TREE_CODE (type) == RECORD_TYPE
|| TREE_CODE (type) == UNION_TYPE)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids casting nonscalar to the same type");
}
else if (TREE_CODE (type) == UNION_TYPE)
@@ -4253,15 +4272,14 @@ build_c_cast (tree type, tree expr)
{
tree t;
- pedwarn (input_location, OPT_pedantic,
- "ISO C forbids casts to union type");
- t = digest_init (type,
+ pedwarn (loc, OPT_pedantic, "ISO C forbids casts to union type");
+ t = digest_init (loc, type,
build_constructor_single (type, field, value),
NULL_TREE, false, true, 0);
TREE_CONSTANT (t) = TREE_CONSTANT (value);
return t;
}
- error ("cast to union type from type not present in union");
+ error_at (loc, "cast to union type from type not present in union");
return error_mark_node;
}
else
@@ -4269,7 +4287,11 @@ build_c_cast (tree type, tree expr)
tree otype, ovalue;
if (type == void_type_node)
- return build1 (CONVERT_EXPR, type, value);
+ {
+ tree t = build1 (CONVERT_EXPR, type, value);
+ SET_EXPR_LOCATION (t, loc);
+ return t;
+ }
otype = TREE_TYPE (value);
@@ -4291,8 +4313,8 @@ build_c_cast (tree type, tree expr)
|| TREE_CODE (TREE_TYPE (otype)) == RECORD_TYPE)
&& TYPE_MODE (TREE_TYPE (otype)) == VOIDmode)
&& TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype)))
- warning (OPT_Wcast_align,
- "cast increases required alignment of target type");
+ warning_at (loc, OPT_Wcast_align,
+ "cast increases required alignment of target type");
if (TREE_CODE (type) == INTEGER_TYPE
&& TREE_CODE (otype) == POINTER_TYPE
@@ -4302,21 +4324,23 @@ build_c_cast (tree type, tree expr)
of cases such as SIG_*, warn about converting constant
pointers to integers. In some cases it may cause unwanted
sign extension, and a warning is appropriate. */
- warning (OPT_Wpointer_to_int_cast,
- "cast from pointer to integer of different size");
+ warning_at (loc, OPT_Wpointer_to_int_cast,
+ "cast from pointer to integer of different size");
if (TREE_CODE (value) == CALL_EXPR
&& TREE_CODE (type) != TREE_CODE (otype))
- warning (OPT_Wbad_function_cast, "cast from function call of type %qT "
- "to non-matching type %qT", otype, type);
+ warning_at (loc, OPT_Wbad_function_cast,
+ "cast from function call of type %qT "
+ "to non-matching type %qT", otype, type);
if (TREE_CODE (type) == POINTER_TYPE
&& TREE_CODE (otype) == INTEGER_TYPE
&& TYPE_PRECISION (type) != TYPE_PRECISION (otype)
/* Don't warn about converting any constant. */
&& !TREE_CONSTANT (value))
- warning (OPT_Wint_to_pointer_cast, "cast to pointer from integer "
- "of different size");
+ warning_at (loc,
+ OPT_Wint_to_pointer_cast, "cast to pointer from integer "
+ "of different size");
if (warn_strict_aliasing <= 2)
strict_aliasing_warning (otype, type, expr);
@@ -4329,7 +4353,7 @@ build_c_cast (tree type, tree expr)
&& TREE_CODE (otype) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
&& TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)
- pedwarn (input_location, OPT_pedantic, "ISO C forbids "
+ pedwarn (loc, OPT_pedantic, "ISO C forbids "
"conversion of function pointer to object pointer type");
if (pedantic
@@ -4338,7 +4362,7 @@ build_c_cast (tree type, tree expr)
&& TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
&& TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
&& !null_pointer_constant_p (value))
- pedwarn (input_location, OPT_pedantic, "ISO C forbids "
+ pedwarn (loc, OPT_pedantic, "ISO C forbids "
"conversion of object pointer to function pointer type");
ovalue = value;
@@ -4382,12 +4406,16 @@ build_c_cast (tree type, tree expr)
|| TREE_CODE (expr) == COMPLEX_CST)))
value = build1 (NOP_EXPR, type, value);
+ if (CAN_HAVE_LOCATION_P (value))
+ SET_EXPR_LOCATION (value, loc);
return value;
}
-/* Interpret a cast of expression EXPR to type TYPE. */
+/* Interpret a cast of expression EXPR to type TYPE. LOC is the
+ location of the open paren of the cast, or the position of the cast
+ expr. */
tree
-c_cast_expr (struct c_type_name *type_name, tree expr, location_t loc)
+c_cast_expr (location_t loc, struct c_type_name *type_name, tree expr)
{
tree type;
tree type_expr = NULL_TREE;
@@ -4402,11 +4430,12 @@ c_cast_expr (struct c_type_name *type_name, tree expr, location_t loc)
type = groktypename (type_name, &type_expr, &type_expr_const);
warn_strict_prototypes = saved_wsp;
- ret = build_c_cast (type, expr);
+ ret = build_c_cast (loc, type, expr);
if (type_expr)
{
ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret), type_expr, ret);
C_MAYBE_CONST_EXPR_NON_CONST (ret) = !type_expr_const;
+ SET_EXPR_LOCATION (ret, loc);
}
if (CAN_HAVE_LOCATION_P (ret) && !EXPR_HAS_LOCATION (ret))
@@ -4429,11 +4458,13 @@ c_cast_expr (struct c_type_name *type_name, tree expr, location_t loc)
If RHS_ORIGTYPE is not NULL_TREE, it is the original type of RHS,
which may differ from TREE_TYPE (RHS) for an enum value.
- LOCATION is the location of the MODIFYCODE operator. */
+ LOCATION is the location of the MODIFYCODE operator.
+ RHS_LOC is the location of the RHS. */
tree
build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
- enum tree_code modifycode, tree rhs, tree rhs_origtype)
+ enum tree_code modifycode,
+ location_t rhs_loc, tree rhs, tree rhs_origtype)
{
tree result;
tree newrhs;
@@ -4463,7 +4494,7 @@ build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
{
tree inner = build_modify_expr (location, C_MAYBE_CONST_EXPR_EXPR (lhs),
- lhs_origtype, modifycode, rhs,
+ lhs_origtype, modifycode, rhs_loc, rhs,
rhs_origtype);
if (inner == error_mark_node)
return error_mark_node;
@@ -4596,6 +4627,7 @@ build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
ERRTYPE says whether it is argument passing, assignment,
initialization or return.
+ LOCATION is the location of the RHS.
FUNCTION is a tree for the function being called.
PARMNUM is the number of the argument, for printing in error messages. */
@@ -4634,14 +4666,14 @@ convert_for_assignment (location_t location, tree type, tree rhs,
/* This macro is used to emit diagnostics to ensure that all format
strings are complete sentences, visible to gettext and checked at
compile time. */
-#define WARN_FOR_ASSIGNMENT(LOCATION, OPT, AR, AS, IN, RE) \
+#define WARN_FOR_ASSIGNMENT(LOCATION, OPT, AR, AS, IN, RE) \
do { \
switch (errtype) \
{ \
case ic_argpass: \
if (pedwarn (LOCATION, OPT, AR, parmnum, rname)) \
- inform ((fundecl && !DECL_IS_BUILTIN (fundecl)) \
- ? DECL_SOURCE_LOCATION (fundecl) : LOCATION, \
+ inform ((fundecl && !DECL_IS_BUILTIN (fundecl)) \
+ ? DECL_SOURCE_LOCATION (fundecl) : LOCATION, \
"expected %qT but argument is of type %qT", \
type, rhstype); \
break; \
@@ -4652,7 +4684,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
pedwarn (LOCATION, OPT, IN); \
break; \
case ic_return: \
- pedwarn (LOCATION, OPT, RE); \
+ pedwarn (LOCATION, OPT, RE); \
break; \
default: \
gcc_unreachable (); \
@@ -4723,7 +4755,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
an unprototyped function, it is compile-time undefined;
making it a constraint in that case was rejected in
DR#252. */
- error ("void value not ignored as it ought to be");
+ error_at (location, "void value not ignored as it ought to be");
return error_mark_node;
}
rhs = require_complete_type (rhs);
@@ -4737,12 +4769,13 @@ convert_for_assignment (location_t location, tree type, tree rhs,
{
if (!lvalue_p (rhs))
{
- error ("cannot pass rvalue to reference parameter");
+ error_at (location, "cannot pass rvalue to reference parameter");
return error_mark_node;
}
if (!c_mark_addressable (rhs))
return error_mark_node;
rhs = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (rhs)), rhs);
+ SET_EXPR_LOCATION (rhs, location);
/* We already know that these two types are compatible, but they
may not be exactly identical. In fact, `TREE_TYPE (type)' is
@@ -4750,9 +4783,13 @@ convert_for_assignment (location_t location, tree type, tree rhs,
likely to be va_list, a typedef to __builtin_va_list, which
is different enough that it will cause problems later. */
if (TREE_TYPE (TREE_TYPE (rhs)) != TREE_TYPE (type))
- rhs = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (type)), rhs);
+ {
+ rhs = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (type)), rhs);
+ SET_EXPR_LOCATION (rhs, location);
+ }
rhs = build1 (NOP_EXPR, type, rhs);
+ SET_EXPR_LOCATION (rhs, location);
return rhs;
}
/* Some types can interconvert without explicit casts. */
@@ -4859,7 +4896,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
function where an ordinary one is wanted, but not
vice-versa. */
if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr))
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE "
"makes qualified function "
"pointer from unqualified"),
@@ -4873,7 +4910,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
"pointer from unqualified"));
}
else if (TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl))
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE discards "
"qualifiers from pointer target type"),
G_("assignment discards qualifiers "
@@ -4887,7 +4924,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
}
if (!fundecl || !DECL_IN_SYSTEM_HEADER (fundecl))
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (location, OPT_pedantic,
"ISO C prohibits argument conversion to union type");
rhs = fold_convert (TREE_TYPE (memb), rhs);
@@ -4921,8 +4958,9 @@ convert_for_assignment (location_t location, tree type, tree rhs,
where NULL is typically defined in C to be '(void *) 0'. */
if (VOID_TYPE_P (ttr) && rhs != null_pointer_node && !VOID_TYPE_P (ttl))
- warning (OPT_Wc___compat, "request for implicit conversion from "
- "%qT to %qT not permitted in C++", rhstype, type);
+ warning_at (location, OPT_Wc___compat,
+ "request for implicit conversion "
+ "from %qT to %qT not permitted in C++", rhstype, type);
/* Check if the right-hand side has a format attribute but the
left-hand side doesn't. */
@@ -4932,25 +4970,25 @@ convert_for_assignment (location_t location, tree type, tree rhs,
switch (errtype)
{
case ic_argpass:
- warning (OPT_Wmissing_format_attribute,
- "argument %d of %qE might be "
- "a candidate for a format attribute",
- parmnum, rname);
+ warning_at (location, OPT_Wmissing_format_attribute,
+ "argument %d of %qE might be "
+ "a candidate for a format attribute",
+ parmnum, rname);
break;
case ic_assign:
- warning (OPT_Wmissing_format_attribute,
- "assignment left-hand side might be "
- "a candidate for a format attribute");
+ warning_at (location, OPT_Wmissing_format_attribute,
+ "assignment left-hand side might be "
+ "a candidate for a format attribute");
break;
case ic_init:
- warning (OPT_Wmissing_format_attribute,
- "initialization left-hand side might be "
- "a candidate for a format attribute");
+ warning_at (location, OPT_Wmissing_format_attribute,
+ "initialization left-hand side might be "
+ "a candidate for a format attribute");
break;
case ic_return:
- warning (OPT_Wmissing_format_attribute,
- "return type might be "
- "a candidate for a format attribute");
+ warning_at (location, OPT_Wmissing_format_attribute,
+ "return type might be "
+ "a candidate for a format attribute");
break;
default:
gcc_unreachable ();
@@ -4972,7 +5010,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
(VOID_TYPE_P (ttr)
&& !null_pointer_constant
&& TREE_CODE (ttl) == FUNCTION_TYPE)))
- WARN_FOR_ASSIGNMENT (input_location, OPT_pedantic,
+ WARN_FOR_ASSIGNMENT (location, OPT_pedantic,
G_("ISO C forbids passing argument %d of "
"%qE between function pointer "
"and %<void *%>"),
@@ -4993,7 +5031,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
qualifier are acceptable if the 'volatile' has been added
in by the Objective-C EH machinery. */
if (!objc_type_quals_match (ttl, ttr))
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE discards "
"qualifiers from pointer target type"),
G_("assignment discards qualifiers "
@@ -5010,7 +5048,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
;
/* If there is a mismatch, do warn. */
else if (warn_pointer_sign)
- WARN_FOR_ASSIGNMENT (input_location, OPT_Wpointer_sign,
+ WARN_FOR_ASSIGNMENT (location, OPT_Wpointer_sign,
G_("pointer targets in passing argument "
"%d of %qE differ in signedness"),
G_("pointer targets in assignment "
@@ -5028,7 +5066,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
it is okay to use a const or volatile function
where an ordinary one is wanted, but not vice-versa. */
if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr))
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE makes "
"qualified function pointer "
"from unqualified"),
@@ -5043,7 +5081,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
else
/* Avoid warning about the volatile ObjC EH puts on decls. */
if (!objc_ok)
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE from "
"incompatible pointer type"),
G_("assignment from incompatible pointer type"),
@@ -5057,7 +5095,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
{
/* ??? This should not be an error when inlining calls to
unprototyped functions. */
- error ("invalid use of non-lvalue array");
+ error_at (location, "invalid use of non-lvalue array");
return error_mark_node;
}
else if (codel == POINTER_TYPE && coder == INTEGER_TYPE)
@@ -5066,7 +5104,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
or one that results from arithmetic, even including
a cast to integer type. */
if (!null_pointer_constant)
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE makes "
"pointer from integer without a cast"),
G_("assignment makes pointer from integer "
@@ -5080,7 +5118,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
}
else if (codel == INTEGER_TYPE && coder == POINTER_TYPE)
{
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE makes integer "
"from pointer without a cast"),
G_("assignment makes integer from pointer "
@@ -5104,22 +5142,24 @@ convert_for_assignment (location_t location, tree type, tree rhs,
switch (errtype)
{
case ic_argpass:
- error ("incompatible type for argument %d of %qE", parmnum, rname);
+ error_at (location, "incompatible type for argument %d of %qE", parmnum, rname);
inform ((fundecl && !DECL_IS_BUILTIN (fundecl))
? DECL_SOURCE_LOCATION (fundecl) : input_location,
"expected %qT but argument is of type %qT", type, rhstype);
break;
case ic_assign:
- error ("incompatible types when assigning to type %qT from type %qT",
- type, rhstype);
+ error_at (location, "incompatible types when assigning to type %qT from "
+ "type %qT", type, rhstype);
break;
case ic_init:
- error ("incompatible types when initializing type %qT using type %qT",
- type, rhstype);
+ error_at (location,
+ "incompatible types when initializing type %qT using type %qT",
+ type, rhstype);
break;
case ic_return:
- error ("incompatible types when returning type %qT but %qT was expected",
- rhstype, type);
+ error_at (location,
+ "incompatible types when returning type %qT but %qT was "
+ "expected", rhstype, type);
break;
default:
gcc_unreachable ();
@@ -5155,10 +5195,12 @@ valid_compound_expr_initializer (tree value, tree endtype)
store it in the declaration DECL,
and print any error messages that are appropriate.
If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
- If the init is invalid, store an ERROR_MARK. */
+ If the init is invalid, store an ERROR_MARK.
+
+ INIT_LOC is the location of the initial value. */
void
-store_init_value (tree decl, tree init, tree origtype)
+store_init_value (location_t init_loc, tree decl, tree init, tree origtype)
{
tree value, type;
bool npc = false;
@@ -5173,7 +5215,8 @@ store_init_value (tree decl, tree init, tree origtype)
if (init)
npc = null_pointer_constant_p (init);
- value = digest_init (type, init, origtype, npc, true, TREE_STATIC (decl));
+ value = digest_init (init_loc, type, init, origtype, npc,
+ true, TREE_STATIC (decl));
/* Store the expression if valid; else report error. */
@@ -5414,12 +5457,15 @@ maybe_warn_string_init (tree type, struct c_expr expr)
unparenthesized or we should not warn here for it being parenthesized.
For other types of INIT, STRICT_STRING is not used.
+ INIT_LOC is the location of the INIT.
+
REQUIRE_CONSTANT requests an error if non-constant initializers or
elements are seen. */
static tree
-digest_init (tree type, tree init, tree origtype, bool null_pointer_constant,
- bool strict_string, int require_constant)
+digest_init (location_t init_loc, tree type, tree init, tree origtype,
+ bool null_pointer_constant, bool strict_string,
+ int require_constant)
{
enum tree_code code = TREE_CODE (type);
tree inside_init = init;
@@ -5469,7 +5515,7 @@ digest_init (tree type, tree init, tree origtype, bool null_pointer_constant,
maybe_warn_string_init (type, expr);
if (TYPE_DOMAIN (type) && !TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
- pedwarn_init (input_location, OPT_pedantic,
+ pedwarn_init (init_loc, OPT_pedantic,
"initialization of a flexible array member");
if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
@@ -5511,7 +5557,7 @@ digest_init (tree type, tree init, tree origtype, bool null_pointer_constant,
TREE_STRING_LENGTH (inside_init)
- (TYPE_PRECISION (typ1)
/ BITS_PER_UNIT)))
- pedwarn_init (input_location, 0,
+ pedwarn_init (init_loc, 0,
"initializer-string for array of chars is too long");
return inside_init;
@@ -5582,7 +5628,8 @@ digest_init (tree type, tree init, tree origtype, bool null_pointer_constant,
{
if (TREE_CODE (inside_init) == STRING_CST
|| TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
- inside_init = array_to_pointer_conversion (inside_init);
+ inside_init = array_to_pointer_conversion
+ (init_loc, inside_init);
else
{
error_init ("invalid use of non-lvalue array");
@@ -5627,7 +5674,7 @@ digest_init (tree type, tree init, tree origtype, bool null_pointer_constant,
if (inside_init == error_mark_node)
error_init ("initializer element is not constant");
else
- pedwarn_init (input_location, OPT_pedantic,
+ pedwarn_init (init_loc, OPT_pedantic,
"initializer element is not constant");
if (flag_pedantic_errors)
inside_init = error_mark_node;
@@ -5640,13 +5687,13 @@ digest_init (tree type, tree init, tree origtype, bool null_pointer_constant,
inside_init = error_mark_node;
}
else if (require_constant && !maybe_const)
- pedwarn_init (input_location, 0,
+ pedwarn_init (init_loc, 0,
"initializer element is not a constant expression");
/* Added to enable additional -Wmissing-format-attribute warnings. */
if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
- inside_init = convert_for_assignment (input_location, type,
- inside_init, origtype,
+ inside_init = convert_for_assignment (init_loc, type, inside_init,
+ origtype,
ic_init, null_pointer_constant,
NULL_TREE, NULL_TREE, 0);
return inside_init;
@@ -5661,13 +5708,13 @@ digest_init (tree type, tree init, tree origtype, bool null_pointer_constant,
if (TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE
&& (TREE_CODE (init) == STRING_CST
|| TREE_CODE (init) == COMPOUND_LITERAL_EXPR))
- inside_init = init = array_to_pointer_conversion (init);
+ inside_init = init = array_to_pointer_conversion (init_loc, init);
if (semantic_type)
inside_init = build1 (EXCESS_PRECISION_EXPR, semantic_type,
inside_init);
inside_init
- = convert_for_assignment (input_location, type, inside_init, origtype,
- ic_init, null_pointer_constant,
+ = convert_for_assignment (init_loc, type, inside_init, origtype,
+ ic_init, null_pointer_constant,
NULL_TREE, NULL_TREE, 0);
/* Check to see if we have already given an error message. */
@@ -5686,7 +5733,7 @@ digest_init (tree type, tree init, tree origtype, bool null_pointer_constant,
inside_init = error_mark_node;
}
else if (require_constant && !maybe_const)
- pedwarn_init (input_location, 0,
+ pedwarn_init (init_loc, 0,
"initializer element is not a constant expression");
return inside_init;
@@ -7092,7 +7139,7 @@ output_init_element (tree value, tree origtype, bool strict_string, tree type,
&& INTEGRAL_TYPE_P (TREE_TYPE (type)))
&& !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)),
TYPE_MAIN_VARIANT (type)))
- value = array_to_pointer_conversion (value);
+ value = array_to_pointer_conversion (input_location, value);
if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR
&& require_constant_value && !flag_isoc99 && pending)
@@ -7171,8 +7218,8 @@ output_init_element (tree value, tree origtype, bool strict_string, tree type,
if (semantic_type)
value = build1 (EXCESS_PRECISION_EXPR, semantic_type, value);
- value = digest_init (type, value, origtype, npc, strict_string,
- require_constant_value);
+ value = digest_init (input_location, type, value, origtype, npc,
+ strict_string, require_constant_value);
if (value == error_mark_node)
{
constructor_erroneous = 1;
@@ -7831,8 +7878,8 @@ build_asm_stmt (tree cv_qualifier, tree args)
string in the asm expression -- asm("blah") and asm("blah" : )
are subtly different. We use a ASM_EXPR node to represent this. */
tree
-build_asm_expr (tree string, tree outputs, tree inputs, tree clobbers,
- bool simple)
+build_asm_expr (location_t loc, tree string, tree outputs, tree inputs,
+ tree clobbers, bool simple)
{
tree tail;
tree args;
@@ -7916,7 +7963,7 @@ build_asm_expr (tree string, tree outputs, tree inputs, tree clobbers,
TREE_VALUE (tail) = input;
}
- args = build_stmt (ASM_EXPR, string, outputs, inputs, clobbers);
+ args = build_stmt (loc, ASM_EXPR, string, outputs, inputs, clobbers);
/* asm statements without outputs, including simple ones, are treated
as volatile. */
@@ -7926,10 +7973,11 @@ build_asm_expr (tree string, tree outputs, tree inputs, tree clobbers,
return args;
}
-/* Generate a goto statement to LABEL. */
+/* Generate a goto statement to LABEL. LOC is the location of the
+ GOTO. */
tree
-c_finish_goto_label (tree label)
+c_finish_goto_label (location_t loc, tree label)
{
tree decl = lookup_label (label);
if (!decl)
@@ -7937,13 +7985,14 @@ c_finish_goto_label (tree label)
if (C_DECL_UNJUMPABLE_STMT_EXPR (decl))
{
- error ("jump into statement expression");
+ error_at (loc, "jump into statement expression");
return NULL_TREE;
}
if (C_DECL_UNJUMPABLE_VM (decl))
{
- error ("jump into scope of identifier with variably modified type");
+ error_at (loc,
+ "jump into scope of identifier with variably modified type");
return NULL_TREE;
}
@@ -7971,33 +8020,43 @@ c_finish_goto_label (tree label)
}
TREE_USED (decl) = 1;
- return add_stmt (build1 (GOTO_EXPR, void_type_node, decl));
+ {
+ tree t = build1 (GOTO_EXPR, void_type_node, decl);
+ SET_EXPR_LOCATION (t, loc);
+ return add_stmt (t);
+ }
}
-/* Generate a computed goto statement to EXPR. */
+/* Generate a computed goto statement to EXPR. LOC is the location of
+ the GOTO. */
tree
-c_finish_goto_ptr (tree expr)
+c_finish_goto_ptr (location_t loc, tree expr)
{
- pedwarn (input_location, OPT_pedantic, "ISO C forbids %<goto *expr;%>");
+ tree t;
+ pedwarn (loc, OPT_pedantic, "ISO C forbids %<goto *expr;%>");
expr = c_fully_fold (expr, false, NULL);
expr = convert (ptr_type_node, expr);
- return add_stmt (build1 (GOTO_EXPR, void_type_node, expr));
+ t = build1 (GOTO_EXPR, void_type_node, expr);
+ SET_EXPR_LOCATION (t, loc);
+ return add_stmt (t);
}
/* Generate a C `return' statement. RETVAL is the expression for what
- to return, or a null pointer for `return;' with no value. If
- ORIGTYPE is not NULL_TREE, it is the original type of RETVAL. */
+ to return, or a null pointer for `return;' with no value. LOC is
+ the location of the return statement. If ORIGTYPE is not NULL_TREE, it
+ is the original type of RETVAL. */
tree
-c_finish_return (tree retval, tree origtype)
+c_finish_return (location_t loc, tree retval, tree origtype)
{
tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt;
bool no_warning = false;
bool npc = false;
if (TREE_THIS_VOLATILE (current_function_decl))
- warning (0, "function declared %<noreturn%> has a %<return%> statement");
+ warning_at (loc, 0,
+ "function declared %<noreturn%> has a %<return%> statement");
if (retval)
{
@@ -8019,7 +8078,7 @@ c_finish_return (tree retval, tree origtype)
if ((warn_return_type || flag_isoc99)
&& valtype != 0 && TREE_CODE (valtype) != VOID_TYPE)
{
- pedwarn_c99 (input_location, flag_isoc99 ? 0 : OPT_Wreturn_type,
+ pedwarn_c99 (loc, flag_isoc99 ? 0 : OPT_Wreturn_type,
"%<return%> with no value, in "
"function returning non-void");
no_warning = true;
@@ -8029,17 +8088,17 @@ c_finish_return (tree retval, tree origtype)
{
current_function_returns_null = 1;
if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
- pedwarn (input_location, 0,
+ pedwarn (loc, 0,
"%<return%> with a value, in function returning void");
else
- pedwarn (input_location, OPT_pedantic, "ISO C forbids "
+ pedwarn (loc, OPT_pedantic, "ISO C forbids "
"%<return%> with expression, in function returning void");
}
else
{
- tree t = convert_for_assignment (input_location, valtype, retval,
- origtype, ic_return, npc,
- NULL_TREE, NULL_TREE, 0);
+ tree t = convert_for_assignment (loc, valtype, retval, origtype,
+ ic_return,
+ npc, NULL_TREE, NULL_TREE, 0);
tree res = DECL_RESULT (current_function_decl);
tree inner;
@@ -8092,7 +8151,8 @@ c_finish_return (tree retval, tree origtype)
&& !DECL_EXTERNAL (inner)
&& !TREE_STATIC (inner)
&& DECL_CONTEXT (inner) == current_function_decl)
- warning (0, "function returns address of local variable");
+ warning_at (loc,
+ 0, "function returns address of local variable");
break;
default:
@@ -8103,12 +8163,13 @@ c_finish_return (tree retval, tree origtype)
}
retval = build2 (MODIFY_EXPR, TREE_TYPE (res), res, t);
+ SET_EXPR_LOCATION (retval, loc);
if (warn_sequence_point)
verify_sequence_points (retval);
}
- ret_stmt = build_stmt (RETURN_EXPR, retval);
+ ret_stmt = build_stmt (loc, RETURN_EXPR, retval);
TREE_NO_WARNING (ret_stmt) |= no_warning;
return add_stmt (ret_stmt);
}
@@ -8151,10 +8212,13 @@ struct c_switch {
struct c_switch *c_switch_stack;
/* Start a C switch statement, testing expression EXP. Return the new
- SWITCH_EXPR. */
+ SWITCH_EXPR. SWITCH_LOC is the location of the `switch'.
+ SWITCH_COND_LOC is the location of the switch's condition. */
tree
-c_start_case (tree exp)
+c_start_case (location_t switch_loc,
+ location_t switch_cond_loc,
+ tree exp)
{
tree orig_type = error_mark_node;
struct c_switch *cs;
@@ -8167,7 +8231,7 @@ c_start_case (tree exp)
{
if (orig_type != error_mark_node)
{
- error ("switch quantity not an integer");
+ error_at (switch_cond_loc, "switch quantity not an integer");
orig_type = error_mark_node;
}
exp = integer_zero_node;
@@ -8179,8 +8243,9 @@ c_start_case (tree exp)
if (!in_system_header
&& (type == long_integer_type_node
|| type == long_unsigned_type_node))
- warning (OPT_Wtraditional, "%<long%> switch expression not "
- "converted to %<int%> in ISO C");
+ warning_at (switch_cond_loc,
+ OPT_Wtraditional, "%<long%> switch expression not "
+ "converted to %<int%> in ISO C");
exp = c_fully_fold (exp, false, NULL);
exp = default_conversion (exp);
@@ -8193,6 +8258,7 @@ c_start_case (tree exp)
/* Add this new SWITCH_EXPR to the stack. */
cs = XNEW (struct c_switch);
cs->switch_expr = build3 (SWITCH_EXPR, orig_type, exp, NULL_TREE, NULL_TREE);
+ SET_EXPR_LOCATION (cs->switch_expr, switch_loc);
cs->orig_type = orig_type;
cs->cases = splay_tree_new (case_compare, NULL, NULL);
cs->blocked_stmt_expr = 0;
@@ -8203,10 +8269,10 @@ c_start_case (tree exp)
return add_stmt (cs->switch_expr);
}
-/* Process a case label. */
+/* Process a case label at location LOC. */
tree
-do_case (tree low_value, tree high_value)
+do_case (location_t loc, tree low_value, tree high_value)
{
tree label = NULL_TREE;
@@ -8229,7 +8295,7 @@ do_case (tree low_value, tree high_value)
if (c_switch_stack && !c_switch_stack->blocked_stmt_expr
&& !c_switch_stack->blocked_vm)
{
- label = c_add_case_label (c_switch_stack->cases,
+ label = c_add_case_label (loc, c_switch_stack->cases,
SWITCH_COND (c_switch_stack->switch_expr),
c_switch_stack->orig_type,
low_value, high_value);
@@ -8239,25 +8305,26 @@ do_case (tree low_value, tree high_value)
else if (c_switch_stack && c_switch_stack->blocked_stmt_expr)
{
if (low_value)
- error ("case label in statement expression not containing "
- "enclosing switch statement");
+ error_at (loc, "case label in statement expression not containing "
+ "enclosing switch statement");
else
- error ("%<default%> label in statement expression not containing "
- "enclosing switch statement");
+ error_at (loc, "%<default%> label in statement expression not containing "
+ "enclosing switch statement");
}
else if (c_switch_stack && c_switch_stack->blocked_vm)
{
if (low_value)
- error ("case label in scope of identifier with variably modified "
- "type not containing enclosing switch statement");
+ error_at (loc, "case label in scope of identifier with variably "
+ "modified type not containing enclosing switch statement");
else
- error ("%<default%> label in scope of identifier with variably "
- "modified type not containing enclosing switch statement");
+ error_at (loc, "%<default%> label in scope of identifier with "
+ "variably modified type not containing enclosing switch "
+ "statement");
}
else if (low_value)
- error ("case label not within a switch statement");
+ error_at (loc, "case label not within a switch statement");
else
- error ("%<default%> label not within a switch statement");
+ error_at (loc, "%<default%> label not within a switch statement");
return label;
}
@@ -8278,10 +8345,7 @@ c_finish_case (tree body)
gcc_assert (!cs->blocked_stmt_expr);
/* Emit warnings as needed. */
- if (EXPR_HAS_LOCATION (cs->switch_expr))
- switch_location = EXPR_LOCATION (cs->switch_expr);
- else
- switch_location = input_location;
+ switch_location = EXPR_LOCATION (cs->switch_expr);
c_do_switch_warnings (cs->cases, switch_location,
TREE_TYPE (cs->switch_expr),
SWITCH_COND (cs->switch_expr));
@@ -8418,7 +8482,7 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
}
tree
-c_finish_bc_stmt (tree *label_p, bool is_break)
+c_finish_bc_stmt (location_t loc, tree *label_p, bool is_break)
{
bool skip;
tree label = *label_p;
@@ -8435,7 +8499,7 @@ c_finish_bc_stmt (tree *label_p, bool is_break)
if (!label)
{
if (!skip)
- *label_p = label = create_artificial_label ();
+ *label_p = label = create_artificial_label (loc);
}
else if (TREE_CODE (label) == LABEL_DECL)
;
@@ -8443,14 +8507,14 @@ c_finish_bc_stmt (tree *label_p, bool is_break)
{
case 0:
if (is_break)
- error ("break statement not within loop or switch");
+ error_at (loc, "break statement not within loop or switch");
else
- error ("continue statement not within a loop");
+ error_at (loc, "continue statement not within a loop");
return NULL_TREE;
case 1:
gcc_assert (is_break);
- error ("break statement used with OpenMP for loop");
+ error_at (loc, "break statement used with OpenMP for loop");
return NULL_TREE;
default:
@@ -8469,25 +8533,25 @@ c_finish_bc_stmt (tree *label_p, bool is_break)
/* A helper routine for c_process_expr_stmt and c_finish_stmt_expr. */
static void
-emit_side_effect_warnings (tree expr)
+emit_side_effect_warnings (location_t loc, tree expr)
{
if (expr == error_mark_node)
;
else if (!TREE_SIDE_EFFECTS (expr))
{
if (!VOID_TYPE_P (TREE_TYPE (expr)) && !TREE_NO_WARNING (expr))
- warning (OPT_Wunused_value, "%Hstatement with no effect",
- EXPR_HAS_LOCATION (expr) ? EXPR_LOCUS (expr) : &input_location);
+ warning_at (loc, OPT_Wunused_value, "statement with no effect");
}
else
- warn_if_unused_value (expr, input_location);
+ warn_if_unused_value (expr, loc);
}
/* Process an expression as if it were a complete statement. Emit
- diagnostics, but do not call ADD_STMT. */
+ diagnostics, but do not call ADD_STMT. LOC is the location of the
+ statement. */
tree
-c_process_expr_stmt (tree expr)
+c_process_expr_stmt (location_t loc, tree expr)
{
if (!expr)
return NULL_TREE;
@@ -8500,33 +8564,34 @@ c_process_expr_stmt (tree expr)
if (TREE_TYPE (expr) != error_mark_node
&& !COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (expr))
&& TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
- error ("expression statement has incomplete type");
+ error_at (loc, "expression statement has incomplete type");
/* If we're not processing a statement expression, warn about unused values.
Warnings for statement expressions will be emitted later, once we figure
out which is the result. */
if (!STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
&& warn_unused_value)
- emit_side_effect_warnings (expr);
+ emit_side_effect_warnings (loc, expr);
/* If the expression is not of a type to which we cannot assign a line
number, wrap the thing in a no-op NOP_EXPR. */
if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
- expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
-
- if (CAN_HAVE_LOCATION_P (expr))
- SET_EXPR_LOCATION (expr, input_location);
+ {
+ expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
+ SET_EXPR_LOCATION (expr, loc);
+ }
return expr;
}
-/* Emit an expression as a statement. */
+/* Emit an expression as a statement. LOC is the location of the
+ expression. */
tree
-c_finish_expr_stmt (tree expr)
+c_finish_expr_stmt (location_t loc, tree expr)
{
if (expr)
- return add_stmt (c_process_expr_stmt (expr));
+ return add_stmt (c_process_expr_stmt (loc, expr));
else
return NULL;
}
@@ -8569,14 +8634,17 @@ c_begin_stmt_expr (void)
return ret;
}
+/* LOC is the location of the compound statement to which this body
+ belongs. */
+
tree
-c_finish_stmt_expr (tree body)
+c_finish_stmt_expr (location_t loc, tree body)
{
tree last, type, tmp, val;
tree *last_p;
struct c_label_list *dlist, *glist, *glist_prev = NULL;
- body = c_end_compound_stmt (body, true);
+ body = c_end_compound_stmt (loc, body, true);
if (c_switch_stack)
{
gcc_assert (c_switch_stack->blocked_stmt_expr != 0);
@@ -8625,7 +8693,13 @@ c_finish_stmt_expr (tree body)
if (warn_unused_value)
{
for (i = tsi_start (last); !tsi_one_before_end_p (i); tsi_next (&i))
- emit_side_effect_warnings (tsi_stmt (i));
+ {
+ location_t tloc;
+ tree t = tsi_stmt (i);
+
+ tloc = EXPR_HAS_LOCATION (t) ? EXPR_LOCATION (t) : loc;
+ emit_side_effect_warnings (tloc, t);
+ }
}
else
i = tsi_last (last);
@@ -8682,7 +8756,11 @@ c_finish_stmt_expr (tree body)
*last_p = build2 (MODIFY_EXPR, void_type_node, tmp, val);
SET_EXPR_LOCUS (*last_p, EXPR_LOCUS (last));
- return build4 (TARGET_EXPR, type, tmp, body, NULL_TREE, NULL_TREE);
+ {
+ tree t = build4 (TARGET_EXPR, type, tmp, body, NULL_TREE, NULL_TREE);
+ SET_EXPR_LOCATION (t, loc);
+ return t;
+ }
}
/* Begin the scope of an identifier of variably modified type, scope
@@ -8771,8 +8849,12 @@ c_begin_compound_stmt (bool do_scope)
return stmt;
}
+/* End a compound statement. STMT is the statement. LOC is the
+ location of the compound statement-- this is usually the location
+ of the opening brace. */
+
tree
-c_end_compound_stmt (tree stmt, bool do_scope)
+c_end_compound_stmt (location_t loc, tree stmt, bool do_scope)
{
tree block = NULL;
@@ -8784,7 +8866,7 @@ c_end_compound_stmt (tree stmt, bool do_scope)
}
stmt = pop_stmt_list (stmt);
- stmt = c_build_bind_expr (block, stmt);
+ stmt = c_build_bind_expr (loc, block, stmt);
/* If this compound statement is nested immediately inside a statement
expression, then force a BIND_EXPR to be created. Otherwise we'll
@@ -8797,6 +8879,7 @@ c_end_compound_stmt (tree stmt, bool do_scope)
{
stmt = build3 (BIND_EXPR, void_type_node, NULL, stmt, NULL);
TREE_SIDE_EFFECTS (stmt) = 1;
+ SET_EXPR_LOCATION (stmt, loc);
}
return stmt;
@@ -8807,14 +8890,14 @@ c_end_compound_stmt (tree stmt, bool do_scope)
meant to apply to normal control flow transfer. */
void
-push_cleanup (tree ARG_UNUSED (decl), tree cleanup, bool eh_only)
+push_cleanup (tree decl, tree cleanup, bool eh_only)
{
enum tree_code code;
tree stmt, list;
bool stmt_expr;
code = eh_only ? TRY_CATCH_EXPR : TRY_FINALLY_EXPR;
- stmt = build_stmt (code, NULL, cleanup);
+ stmt = build_stmt (DECL_SOURCE_LOCATION (decl), code, NULL, cleanup);
add_stmt (stmt);
stmt_expr = STATEMENT_LIST_STMT_EXPR (cur_stmt_list);
list = push_stmt_list ();
@@ -9749,19 +9832,21 @@ c_begin_omp_parallel (void)
return block;
}
-/* Generate OMP_PARALLEL, with CLAUSES and BLOCK as its compound statement. */
+/* Generate OMP_PARALLEL, with CLAUSES and BLOCK as its compound
+ statement. LOC is the location of the OMP_PARALLEL. */
tree
-c_finish_omp_parallel (tree clauses, tree block)
+c_finish_omp_parallel (location_t loc, tree clauses, tree block)
{
tree stmt;
- block = c_end_compound_stmt (block, true);
+ block = c_end_compound_stmt (loc, block, true);
stmt = make_node (OMP_PARALLEL);
TREE_TYPE (stmt) = void_type_node;
OMP_PARALLEL_CLAUSES (stmt) = clauses;
OMP_PARALLEL_BODY (stmt) = block;
+ SET_EXPR_LOCATION (stmt, loc);
return add_stmt (stmt);
}
@@ -9779,19 +9864,21 @@ c_begin_omp_task (void)
return block;
}
-/* Generate OMP_TASK, with CLAUSES and BLOCK as its compound statement. */
+/* Generate OMP_TASK, with CLAUSES and BLOCK as its compound
+ statement. LOC is the location of the #pragma. */
tree
-c_finish_omp_task (tree clauses, tree block)
+c_finish_omp_task (location_t loc, tree clauses, tree block)
{
tree stmt;
- block = c_end_compound_stmt (block, true);
+ block = c_end_compound_stmt (loc, block, true);
stmt = make_node (OMP_TASK);
TREE_TYPE (stmt) = void_type_node;
OMP_TASK_CLAUSES (stmt) = clauses;
OMP_TASK_BODY (stmt) = block;
+ SET_EXPR_LOCATION (stmt, loc);
return add_stmt (stmt);
}
@@ -9837,7 +9924,8 @@ c_finish_omp_clauses (tree clauses)
if (AGGREGATE_TYPE_P (TREE_TYPE (t))
|| POINTER_TYPE_P (TREE_TYPE (t)))
{
- error ("%qE has invalid type for %<reduction%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE has invalid type for %<reduction%>", t);
remove = true;
}
else if (FLOAT_TYPE_P (TREE_TYPE (t)))
@@ -9871,8 +9959,9 @@ c_finish_omp_clauses (tree clauses)
}
if (r_name)
{
- error ("%qE has invalid type for %<reduction(%s)%>",
- t, r_name);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE has invalid type for %<reduction(%s)%>",
+ t, r_name);
remove = true;
}
}
@@ -9887,7 +9976,8 @@ c_finish_omp_clauses (tree clauses)
t = OMP_CLAUSE_DECL (c);
if (TREE_CODE (t) != VAR_DECL || !DECL_THREAD_LOCAL_P (t))
{
- error ("%qE must be %<threadprivate%> for %<copyin%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE must be %<threadprivate%> for %<copyin%>", t);
remove = true;
}
goto check_dup_generic;
@@ -9896,14 +9986,16 @@ c_finish_omp_clauses (tree clauses)
t = OMP_CLAUSE_DECL (c);
if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
{
- error ("%qE is not a variable in clause %qs", t, name);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in clause %qs", t, name);
remove = true;
}
else if (bitmap_bit_p (&generic_head, DECL_UID (t))
|| bitmap_bit_p (&firstprivate_head, DECL_UID (t))
|| bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
{
- error ("%qE appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE appears more than once in data clauses", t);
remove = true;
}
else
@@ -9917,13 +10009,15 @@ c_finish_omp_clauses (tree clauses)
need_implicitly_determined = true;
if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
{
- error ("%qE is not a variable in clause %<firstprivate%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in clause %<firstprivate%>", t);
remove = true;
}
else if (bitmap_bit_p (&generic_head, DECL_UID (t))
|| bitmap_bit_p (&firstprivate_head, DECL_UID (t)))
{
- error ("%qE appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE appears more than once in data clauses", t);
remove = true;
}
else
@@ -9937,13 +10031,15 @@ c_finish_omp_clauses (tree clauses)
need_implicitly_determined = true;
if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
{
- error ("%qE is not a variable in clause %<lastprivate%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in clause %<lastprivate%>", t);
remove = true;
}
else if (bitmap_bit_p (&generic_head, DECL_UID (t))
|| bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
{
- error ("%qE appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE appears more than once in data clauses", t);
remove = true;
}
else
@@ -9997,8 +10093,9 @@ c_finish_omp_clauses (tree clauses)
}
if (share_name)
{
- error ("%qE is predetermined %qs for %qs",
- t, share_name, name);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is predetermined %qs for %qs",
+ t, share_name, name);
remove = true;
}
}
@@ -10082,10 +10179,10 @@ c_build_qualified_type (tree type, int type_quals)
/* Build a VA_ARG_EXPR for the C parser. */
tree
-c_build_va_arg (tree expr, tree type, location_t loc)
+c_build_va_arg (location_t loc, tree expr, tree type)
{
if (warn_cxx_compat && TREE_CODE (type) == ENUMERAL_TYPE)
warning_at (loc, OPT_Wc___compat,
"C++ requires promoted type, not enum type, in %<va_arg%>");
- return build_va_arg (expr, type);
+ return build_va_arg (loc, expr, type);
}
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 3346d2c80cc..62b5c4515d1 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -1410,7 +1410,8 @@ add_stack_protection_conflicts (void)
static void
create_stack_guard (void)
{
- tree guard = build_decl (VAR_DECL, NULL, ptr_type_node);
+ tree guard = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ VAR_DECL, NULL, ptr_type_node);
TREE_THIS_VOLATILE (guard) = 1;
TREE_USED (guard) = 1;
expand_one_stack_var (guard);
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 907488c1431..310e5f9cef9 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1429,11 +1429,12 @@ cgraph_build_static_cdtor (char which, tree body, int priority)
sprintf (which_buf, "%c_%.5d_%d", which, priority, counter++);
name = get_file_function_name (which_buf);
- decl = build_decl (FUNCTION_DECL, name,
+ decl = build_decl (input_location, FUNCTION_DECL, name,
build_function_type (void_type_node, void_list_node));
current_function_decl = decl;
- resdecl = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
+ resdecl = build_decl (input_location,
+ RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (resdecl) = 1;
DECL_RESULT (decl) = resdecl;
DECL_CONTEXT (resdecl) = decl;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index ec335762d16..9129fc39114 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -6529,15 +6529,20 @@ ix86_build_builtin_va_list_abi (enum calling_abi abi)
return build_pointer_type (char_type_node);
record = (*lang_hooks.types.make_type) (RECORD_TYPE);
- type_decl = build_decl (TYPE_DECL, get_identifier ("__va_list_tag"), record);
+ type_decl = build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("__va_list_tag"), record);
- f_gpr = build_decl (FIELD_DECL, get_identifier ("gp_offset"),
+ f_gpr = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, get_identifier ("gp_offset"),
unsigned_type_node);
- f_fpr = build_decl (FIELD_DECL, get_identifier ("fp_offset"),
+ f_fpr = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, get_identifier ("fp_offset"),
unsigned_type_node);
- f_ovf = build_decl (FIELD_DECL, get_identifier ("overflow_arg_area"),
+ f_ovf = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, get_identifier ("overflow_arg_area"),
ptr_type_node);
- f_sav = build_decl (FIELD_DECL, get_identifier ("reg_save_area"),
+ f_sav = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, get_identifier ("reg_save_area"),
ptr_type_node);
va_list_gpr_counter_field = f_gpr;
@@ -6929,8 +6934,8 @@ ix86_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p,
bool need_temp;
tree int_addr, sse_addr;
- lab_false = create_artificial_label ();
- lab_over = create_artificial_label ();
+ lab_false = create_artificial_label (UNKNOWN_LOCATION);
+ lab_over = create_artificial_label (UNKNOWN_LOCATION);
examine_argument (nat_mode, type, 0, &needed_intregs, &needed_sseregs);
@@ -7512,7 +7517,8 @@ ix86_file_end (void)
{
tree decl;
- decl = build_decl (FUNCTION_DECL, get_identifier (name),
+ decl = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, get_identifier (name),
error_mark_node);
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
@@ -10257,7 +10263,8 @@ get_dllimport_decl (tree decl)
*loc = h = GGC_NEW (struct tree_map);
h->hash = in.hash;
h->base.from = decl;
- h->to = to = build_decl (VAR_DECL, NULL, ptr_type_node);
+ h->to = to = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, NULL, ptr_type_node);
DECL_ARTIFICIAL (to) = 1;
DECL_IGNORED_P (to) = 1;
DECL_EXTERNAL (to) = 1;
@@ -25923,7 +25930,8 @@ ix86_veclibabi_svml (enum built_in_function fn, tree type_out, tree type_in)
fntype = build_function_type_list (type_out, type_in, type_in, NULL);
/* Build a function declaration for the vectorized function. */
- new_fndecl = build_decl (FUNCTION_DECL, get_identifier (name), fntype);
+ new_fndecl = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, get_identifier (name), fntype);
TREE_PUBLIC (new_fndecl) = 1;
DECL_EXTERNAL (new_fndecl) = 1;
DECL_IS_NOVOPS (new_fndecl) = 1;
@@ -26007,7 +26015,8 @@ ix86_veclibabi_acml (enum built_in_function fn, tree type_out, tree type_in)
fntype = build_function_type_list (type_out, type_in, type_in, NULL);
/* Build a function declaration for the vectorized function. */
- new_fndecl = build_decl (FUNCTION_DECL, get_identifier (name), fntype);
+ new_fndecl = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, get_identifier (name), fntype);
TREE_PUBLIC (new_fndecl) = 1;
DECL_EXTERNAL (new_fndecl) = 1;
DECL_IS_NOVOPS (new_fndecl) = 1;
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 47bc71e4df1..ebdc696218b 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -418,7 +418,8 @@ coverage_counter_alloc (unsigned counter, unsigned num)
tree gcov_type_array_type
= build_array_type (gcov_type_node, NULL_TREE);
tree_ctr_tables[counter]
- = build_decl (VAR_DECL, NULL_TREE, gcov_type_array_type);
+ = build_decl (BUILTINS_LOCATION,
+ VAR_DECL, NULL_TREE, gcov_type_array_type);
TREE_STATIC (tree_ctr_tables[counter]) = 1;
ASM_GENERATE_INTERNAL_LABEL (buf, "LPBX", counter + 1);
DECL_NAME (tree_ctr_tables[counter]) = get_identifier (buf);
@@ -639,10 +640,12 @@ build_fn_info_type (unsigned int counters)
tree array_type;
/* ident */
- fields = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ fields = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
/* checksum */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
@@ -651,7 +654,8 @@ build_fn_info_type (unsigned int counters)
array_type = build_array_type (get_gcov_unsigned_t (), array_type);
/* counters */
- field = build_decl (FIELD_DECL, NULL_TREE, array_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, array_type);
TREE_CHAIN (field) = fields;
fields = field;
@@ -714,12 +718,14 @@ build_ctr_info_type (void)
tree gcov_merge_fn_type;
/* counters */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
/* values */
- field = build_decl (FIELD_DECL, NULL_TREE, gcov_ptr_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, gcov_ptr_type);
TREE_CHAIN (field) = fields;
fields = field;
@@ -728,7 +734,8 @@ build_ctr_info_type (void)
build_function_type_list (void_type_node,
gcov_ptr_type, get_gcov_unsigned_t (),
NULL_TREE);
- field = build_decl (FIELD_DECL, NULL_TREE,
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE,
build_pointer_type (gcov_merge_fn_type));
TREE_CHAIN (field) = fields;
fields = field;
@@ -780,7 +787,8 @@ build_ctr_info_value (unsigned int counter, tree type)
value = tree_cons (fields, null_pointer_node, value);
fields = TREE_CHAIN (fields);
- fn = build_decl (FUNCTION_DECL,
+ fn = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL,
get_identifier (ctr_merge_functions[counter]),
TREE_TYPE (TREE_TYPE (fields)));
DECL_EXTERNAL (fn) = 1;
@@ -825,20 +833,23 @@ build_gcov_info (void)
const_type = build_qualified_type (type, TYPE_QUAL_CONST);
/* Version ident */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field, build_int_cstu (TREE_TYPE (field), GCOV_VERSION),
value);
/* next -- NULL */
- field = build_decl (FIELD_DECL, NULL_TREE, build_pointer_type (const_type));
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, build_pointer_type (const_type));
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field, null_pointer_node, value);
/* stamp */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field, build_int_cstu (TREE_TYPE (field), local_tick),
@@ -847,7 +858,8 @@ build_gcov_info (void)
/* Filename */
string_type = build_pointer_type (build_qualified_type (char_type_node,
TYPE_QUAL_CONST));
- field = build_decl (FIELD_DECL, NULL_TREE, string_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, string_type);
TREE_CHAIN (field) = fields;
fields = field;
da_file_name_len = strlen (da_file_name);
@@ -882,7 +894,8 @@ build_gcov_info (void)
fn_info_value = null_pointer_node;
/* number of functions */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field,
@@ -890,13 +903,15 @@ build_gcov_info (void)
value);
/* fn_info table */
- field = build_decl (FIELD_DECL, NULL_TREE, fn_info_ptr_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, fn_info_ptr_type);
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field, fn_info_value, value);
/* counter_mask */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field,
@@ -917,7 +932,8 @@ build_gcov_info (void)
ctr_info_value = build_constructor_from_list (ctr_info_ary_type,
nreverse (ctr_info_value));
- field = build_decl (FIELD_DECL, NULL_TREE, ctr_info_ary_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, ctr_info_ary_type);
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field, ctr_info_value, value);
@@ -947,7 +963,8 @@ create_coverage (void)
t = build_gcov_info ();
- gcov_info = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE (t));
+ gcov_info = build_decl (BUILTINS_LOCATION,
+ VAR_DECL, NULL_TREE, TREE_TYPE (t));
TREE_STATIC (gcov_info) = 1;
ASM_GENERATE_INTERNAL_LABEL (name_buf, "LPBX", 0);
DECL_NAME (gcov_info) = get_identifier (name_buf);
@@ -959,7 +976,8 @@ create_coverage (void)
/* Build a decl for __gcov_init. */
t = build_pointer_type (TREE_TYPE (gcov_info));
t = build_function_type_list (void_type_node, t, NULL);
- t = build_decl (FUNCTION_DECL, get_identifier ("__gcov_init"), t);
+ t = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, get_identifier ("__gcov_init"), t);
TREE_PUBLIC (t) = 1;
DECL_EXTERNAL (t) = 1;
gcov_init = t;
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 76f83c60a53..ec8cef035ed 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,86 @@
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * typeck.c (cp_build_binary_op): Pass location to overflow_warning.
+ (build_modify_expr): New arg.
+ * semantics.c (finish_unary_op_expr): Pass location to
+ overflow_warning.
+ (handle_omp_for_class_iterator): Pass location to build_modify_expr.
+ * typeck.c (cxx_sizeof_or_alignof_type): Pass location to
+ c_sizeof_or_alignof_type.
+ (build_array_ref): New argument.
+ (build_compound_expr): Same.
+ (build_const_cast): Same.
+ (build_ptrmemfunc): Pass location to build_c_cast.
+ * init.c (avoid_placement_new_aliasing): Pass location to
+ build_stmt.
+ (build_vec_delete_1): Pass location to cp_build_modify_expr,
+ build_compound_expr.
+ * class.c (build_vtbl_ref_1): Pass location to build_array_ref.
+ * decl.c (poplevel): Pass location to c_build_bind_expr.
+ (finish_case_label): Pass location to build_case_label.
+ (finish_constructor_body): Same.
+ (finish_destructor_body): Pass location to build_stmt.
+ (cxx_maybe_build_cleanup): Same, but to build_compound_expr.
+ * call.c (build_new_op): Pass location to build_array_ref.
+ (build_x_va_arg): Pass location to build_va_arg.
+ * except.c (expand_end_catch_block): Pass location to
+ build_stmt.
+ * cp-tree.h (build_array_ref): New argument.
+ (build_compound_expr): Same.
+ (build_c_cast): Same.
+ * cp-gimplify.c (gimplify_if_stmt): Pass location on down.
+ (gimplify_switch_stmt): Same.
+ * typeck2.c (split_nonconstant_init_1): Same.
+ * pt.c (tsubst_copy): Same.
+ * semantics.c (add_decl_expr): Same.
+ (do_poplevel): Same.
+ (push_cleanup): Same.
+ (finish_goto_stmt): Same.
+ (finish_expr_stmt): Same.
+ (begin_if_stmt): Same.
+ (begin_while_stmt): Same.
+ (begin_do_stmt): Same.
+ (finish_return_stmt): Same.
+ (begin_for_stmt): Same.
+ (finish_break_stmt): Same.
+ (finish_continue_stmt): Same.
+ (begin_switch_stmt): Same.
+ (begin_try_block): Same.
+ (begin_handler): Same.
+ (finish_asm_stmt): Same.
+ (finish_label_stmt): Same.
+ (finish_stmt_expr_expr): Same.
+ (finalize_nrv_r): Same.
+ (finish_omp_atomic): Same.
+ * name-lookup.c (do_using_directive): Same.
+ * decl2.c (grok_array_decl): Same.
+ * parser.c (cp_parser_cast_expression): Same.
+ (cp_parser_selection_statement): Same.
+ (cp_parser_implicitly_scoped_statement): Same.
+ (cp_parser_objc_selector_expression): Same.
+ (cp_parser_objc_synchronized_statement): Same.
+ (cp_parser_objc_throw_statement): Same.
+ (cp_parser_omp_critical): Same.
+ (cp_parser_omp_master): Same.
+ * typeck.c (build_function_call): Add location argument.
+ * init.c: Add location argument to all build_decl calls.
+ * class.c: Same.
+ * method.c: Same.
+ * rtti.c: Same.
+ * tree.c: Same.
+ * pt.c: Same.
+ * semantics.c: Same.
+ * lex.c: Same.
+ * decl2.c: Same.
+ * cp-gimplify.c: Same.
+ * decl.c: Same.
+ (cp_make_fname_decl): Add location argument. Pass location ot
+ build_decl.
+ (finish_case_label): Same.
+ * cp-tree.h (finish_case_label): Add location argument.
+ * parser.c (cp_parser_label_for_labeled_statement): Pass location to
+ finish_case_label.
+
2009-06-09 Jason Merrill <jason@redhat.com>
PR c++/40381
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index db45ab0a30c..f33d64573dd 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4398,7 +4398,7 @@ build_new_op (enum tree_code code, int flags, tree arg1, tree arg2, tree arg3,
return cp_build_unary_op (code, arg1, candidates != 0, complain);
case ARRAY_REF:
- return build_array_ref (arg1, arg2, input_location);
+ return build_array_ref (input_location, arg1, arg2);
case COND_EXPR:
return build_conditional_expr (arg1, arg2, arg3, complain);
@@ -5102,7 +5102,7 @@ build_x_va_arg (tree expr, tree type)
return expr;
}
- return build_va_arg (expr, type);
+ return build_va_arg (input_location, expr, type);
}
/* TYPE has been given to va_arg. Apply the default conversions which
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 20ceb6540c4..94b75ca6153 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -626,7 +626,7 @@ build_vtbl_ref_1 (tree instance, tree idx)
vtbl = build_vfield_ref (instance, basetype);
- aref = build_array_ref (vtbl, idx, input_location);
+ aref = build_array_ref (input_location, vtbl, idx);
TREE_CONSTANT (aref) |= TREE_CONSTANT (vtbl) && TREE_CONSTANT (idx);
return aref;
@@ -3636,7 +3636,8 @@ build_base_field (record_layout_info rli, tree binfo,
CLASSTYPE_EMPTY_P (t) = 0;
/* Create the FIELD_DECL. */
- decl = build_decl (FIELD_DECL, NULL_TREE, CLASSTYPE_AS_BASE (basetype));
+ decl = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, CLASSTYPE_AS_BASE (basetype));
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
DECL_FIELD_CONTEXT (decl) = t;
@@ -4428,7 +4429,8 @@ create_vtable_ptr (tree t, tree* virtuals_p)
stores cannot alias stores to void*! */
tree field;
- field = build_decl (FIELD_DECL, get_vfield_name (t), vtbl_ptr_type_node);
+ field = build_decl (input_location,
+ FIELD_DECL, get_vfield_name (t), vtbl_ptr_type_node);
DECL_VIRTUAL_P (field) = 1;
DECL_ARTIFICIAL (field) = 1;
DECL_FIELD_CONTEXT (field) = t;
@@ -5008,7 +5010,8 @@ layout_class_type (tree t, tree *virtuals_p)
{
tree padding_field;
- padding_field = build_decl (FIELD_DECL,
+ padding_field = build_decl (input_location,
+ FIELD_DECL,
NULL_TREE,
char_type_node);
DECL_BIT_FIELD (padding_field) = 1;
@@ -5096,7 +5099,8 @@ layout_class_type (tree t, tree *virtuals_p)
for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
if (TREE_CODE (field) == FIELD_DECL)
{
- *next_field = build_decl (FIELD_DECL,
+ *next_field = build_decl (input_location,
+ FIELD_DECL,
DECL_NAME (field),
TREE_TYPE (field));
DECL_CONTEXT (*next_field) = base_t;
@@ -5137,7 +5141,8 @@ layout_class_type (tree t, tree *virtuals_p)
/* Make sure not to create any structures with zero size. */
if (integer_zerop (rli_size_unit_so_far (rli)) && CLASSTYPE_EMPTY_P (t))
place_field (rli,
- build_decl (FIELD_DECL, NULL_TREE, char_type_node));
+ build_decl (input_location,
+ FIELD_DECL, NULL_TREE, char_type_node));
/* Let the back end lay out the type. */
finish_record_layout (rli, /*free_p=*/true);
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 466415752ea..29f4f382e5c 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -50,7 +50,7 @@ static tree bc_label[2];
static tree
begin_bc_block (enum bc_t bc)
{
- tree label = create_artificial_label ();
+ tree label = create_artificial_label (input_location);
TREE_CHAIN (label) = bc_label[bc];
bc_label[bc] = label;
return label;
@@ -169,9 +169,9 @@ genericize_if_stmt (tree *stmt_p)
else_ = ELSE_CLAUSE (stmt);
if (!then_)
- then_ = build_empty_stmt ();
+ then_ = build_empty_stmt (locus);
if (!else_)
- else_ = build_empty_stmt ();
+ else_ = build_empty_stmt (locus);
if (integer_nonzerop (cond) && !TREE_SIDE_EFFECTS (else_))
stmt = then_;
@@ -226,7 +226,7 @@ gimplify_cp_loop (tree cond, tree body, tree incr, bool cond_is_first)
back through the main gimplifier to lower it. Given that we
have to gimplify the loop body NOW so that we can resolve
break/continue stmts, seems easier to just expand to gotos. */
- top = gimple_build_label (create_artificial_label ());
+ top = gimple_build_label (create_artificial_label (stmt_locus));
/* If we have an exit condition, then we build an IF with gotos either
out of the loop, or to the top of it. If there's no exit condition,
@@ -247,7 +247,8 @@ gimplify_cp_loop (tree cond, tree body, tree incr, bool cond_is_first)
{
if (incr)
{
- entry = gimple_build_label (create_artificial_label ());
+ entry = gimple_build_label
+ (create_artificial_label (stmt_locus));
stmt = gimple_build_goto (gimple_label_label (entry));
}
else
@@ -334,7 +335,7 @@ gimplify_switch_stmt (tree *stmt_p, gimple_seq *pre_p)
body = SWITCH_STMT_BODY (stmt);
if (!body)
- body = build_empty_stmt ();
+ body = build_empty_stmt (stmt_locus);
t = build3 (SWITCH_EXPR, SWITCH_STMT_TYPE (stmt),
SWITCH_STMT_COND (stmt), body, NULL_TREE);
@@ -939,7 +940,7 @@ cxx_omp_clause_apply_fn (tree fn, tree arg1, tree arg2)
append_to_statement_list (t, &ret);
}
- lab = create_artificial_label ();
+ lab = create_artificial_label (input_location);
t = build1 (LABEL_EXPR, void_type_node, lab);
append_to_statement_list (t, &ret);
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index e31726cfdb1..19d61bfe208 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4380,7 +4380,7 @@ extern tree reshape_init (tree, tree);
extern bool defer_mark_used_calls;
extern GTY(()) VEC(tree, gc) *deferred_mark_used_calls;
-extern tree finish_case_label (tree, tree);
+extern tree finish_case_label (location_t, tree, tree);
extern tree cxx_maybe_build_cleanup (tree);
/* in decl2.c */
@@ -4542,7 +4542,8 @@ extern tree type_uses_auto (tree);
extern void append_type_to_template_for_access_check (tree, tree, tree);
extern tree splice_late_return_type (tree, tree);
extern bool is_auto (const_tree);
-extern tree process_template_parm (tree, tree, bool, bool);
+extern tree process_template_parm (tree, location_t, tree,
+ bool, bool);
extern tree end_template_parm_list (tree);
extern void end_template_decl (void);
extern bool check_default_tmpl_args (tree, tree, int, int, int);
@@ -4933,7 +4934,7 @@ extern tree build_x_indirect_ref (tree, const char *,
tsubst_flags_t);
extern tree cp_build_indirect_ref (tree, const char *,
tsubst_flags_t);
-extern tree build_array_ref (tree, tree, location_t);
+extern tree build_array_ref (location_t, tree, tree);
extern tree get_member_function_from_ptrfunc (tree *, tree);
extern tree cp_build_function_call (tree, tree, tsubst_flags_t);
extern tree cp_build_function_call_vec (tree, VEC(tree,gc) **,
@@ -4953,12 +4954,12 @@ extern tree build_x_conditional_expr (tree, tree, tree,
extern tree build_x_compound_expr_from_list (tree, const char *);
extern tree build_x_compound_expr_from_vec (VEC(tree,gc) *, const char *);
extern tree build_x_compound_expr (tree, tree, tsubst_flags_t);
-extern tree build_compound_expr (tree, tree);
+extern tree build_compound_expr (location_t, tree, tree);
extern tree cp_build_compound_expr (tree, tree, tsubst_flags_t);
extern tree build_static_cast (tree, tree, tsubst_flags_t);
extern tree build_reinterpret_cast (tree, tree, tsubst_flags_t);
extern tree build_const_cast (tree, tree, tsubst_flags_t);
-extern tree build_c_cast (tree, tree);
+extern tree build_c_cast (location_t, tree, tree);
extern tree cp_build_c_cast (tree, tree, tsubst_flags_t);
extern tree build_x_modify_expr (tree, enum tree_code, tree,
tsubst_flags_t);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index bf99b3d193a..22c426b3247 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -94,7 +94,7 @@ static tree get_atexit_node (void);
static tree get_dso_handle_node (void);
static tree start_cleanup_fn (void);
static void end_cleanup_fn (void);
-static tree cp_make_fname_decl (tree, int);
+static tree cp_make_fname_decl (location_t, tree, int);
static void initialize_predefined_identifiers (void);
static tree check_special_function_return_type
(special_function_kind, tree, tree);
@@ -743,7 +743,7 @@ poplevel (int keep, int reverse, int functionbody)
have pushed a statement list level. Pop that, create a new
BIND_EXPR for the block, and insert it into the stream. */
stmt = pop_stmt_list (current_binding_level->statement_list);
- stmt = c_build_bind_expr (block, stmt);
+ stmt = c_build_bind_expr (input_location, block, stmt);
add_stmt (stmt);
}
@@ -842,7 +842,7 @@ create_implicit_typedef (tree name, tree type)
{
tree decl;
- decl = build_decl (TYPE_DECL, name, type);
+ decl = build_decl (input_location, TYPE_DECL, name, type);
DECL_ARTIFICIAL (decl) = 1;
/* There are other implicit type declarations, like the one *within*
a class that allows you to write `S::S'. We must distinguish
@@ -2368,7 +2368,7 @@ make_label_decl (tree id, int local_p)
void **slot;
tree decl;
- decl = build_decl (LABEL_DECL, id, void_type_node);
+ decl = build_decl (input_location, LABEL_DECL, id, void_type_node);
DECL_CONTEXT (decl) = current_function_decl;
DECL_MODE (decl) = VOIDmode;
@@ -2795,7 +2795,7 @@ pop_switch (void)
is a bad place for one. */
tree
-finish_case_label (tree low_value, tree high_value)
+finish_case_label (location_t loc, tree low_value, tree high_value)
{
tree cond, r;
struct cp_binding_level *p;
@@ -2806,8 +2806,8 @@ finish_case_label (tree low_value, tree high_value)
/* For templates, just add the case label; we'll do semantic
analysis at instantiation-time. */
- label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
- return add_stmt (build_case_label (low_value, high_value, label));
+ label = build_decl (loc, LABEL_DECL, NULL_TREE, NULL_TREE);
+ return add_stmt (build_case_label (loc, low_value, high_value, label));
}
/* Find the condition on which this switch statement depends. */
@@ -2818,7 +2818,7 @@ finish_case_label (tree low_value, tree high_value)
if (!check_switch_goto (switch_stack->level))
return error_mark_node;
- r = c_add_case_label (switch_stack->cases, cond,
+ r = c_add_case_label (loc, switch_stack->cases, cond,
SWITCH_STMT_TYPE (switch_stack->switch_stmt),
low_value, high_value);
@@ -2915,7 +2915,7 @@ build_typename_type (tree context, tree name, tree fullname,
TYPENAME_IS_CLASS_P (t) = ti.class_p;
/* Build the corresponding TYPE_DECL. */
- d = build_decl (TYPE_DECL, name, t);
+ d = build_decl (input_location, TYPE_DECL, name, t);
TYPE_NAME (TREE_TYPE (d)) = d;
TYPE_STUB_DECL (TREE_TYPE (d)) = d;
DECL_CONTEXT (d) = FROB_CONTEXT (context);
@@ -3113,7 +3113,7 @@ make_unbound_class_template (tree context, tree name, tree parm_list,
SET_TYPE_STRUCTURAL_EQUALITY (t);
/* Build the corresponding TEMPLATE_DECL. */
- d = build_decl (TEMPLATE_DECL, name, t);
+ d = build_decl (input_location, TEMPLATE_DECL, name, t);
TYPE_NAME (TREE_TYPE (d)) = d;
TYPE_STUB_DECL (TREE_TYPE (d)) = d;
DECL_CONTEXT (d) = FROB_CONTEXT (context);
@@ -3150,7 +3150,7 @@ record_builtin_type (enum rid rid_index,
up built-in types by name. */
if (tname)
{
- tdecl = build_decl (TYPE_DECL, tname, type);
+ tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, tname, type);
DECL_ARTIFICIAL (tdecl) = 1;
SET_IDENTIFIER_GLOBAL_VALUE (tname, tdecl);
}
@@ -3158,7 +3158,7 @@ record_builtin_type (enum rid rid_index,
{
if (!tdecl)
{
- tdecl = build_decl (TYPE_DECL, rname, type);
+ tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, rname, type);
DECL_ARTIFICIAL (tdecl) = 1;
}
SET_IDENTIFIER_GLOBAL_VALUE (rname, tdecl);
@@ -3218,7 +3218,8 @@ record_builtin_java_type (const char* name, int size)
static void
record_unknown_type (tree type, const char* name)
{
- tree decl = pushdecl (build_decl (TYPE_DECL, get_identifier (name), type));
+ tree decl = pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, get_identifier (name), type));
/* Make sure the "unknown type" typedecl gets ignored for debug info. */
DECL_IGNORED_P (decl) = 1;
TYPE_DECL_SUPPRESS_DEBUG (decl) = 1;
@@ -3492,20 +3493,21 @@ cp_fname_init (const char* name, tree *type_p)
return init;
}
-/* Create the VAR_DECL for __FUNCTION__ etc. ID is the name to give the
- decl, NAME is the initialization string and TYPE_DEP indicates whether
- NAME depended on the type of the function. We make use of that to detect
- __PRETTY_FUNCTION__ inside a template fn. This is being done
- lazily at the point of first use, so we mustn't push the decl now. */
+/* Create the VAR_DECL for __FUNCTION__ etc. ID is the name to give
+ the decl, LOC is the location to give the decl, NAME is the
+ initialization string and TYPE_DEP indicates whether NAME depended
+ on the type of the function. We make use of that to detect
+ __PRETTY_FUNCTION__ inside a template fn. This is being done lazily
+ at the point of first use, so we mustn't push the decl now. */
static tree
-cp_make_fname_decl (tree id, int type_dep)
+cp_make_fname_decl (location_t loc, tree id, int type_dep)
{
const char *const name = (type_dep && processing_template_decl
? NULL : fname_as_string (type_dep));
tree type;
tree init = cp_fname_init (name, &type);
- tree decl = build_decl (VAR_DECL, id, type);
+ tree decl = build_decl (loc, VAR_DECL, id, type);
if (name)
free (CONST_CAST (char *, name));
@@ -5898,7 +5900,7 @@ declare_global_var (tree name, tree type)
tree decl;
push_to_top_level ();
- decl = build_decl (VAR_DECL, name, type);
+ decl = build_decl (input_location, VAR_DECL, name, type);
TREE_PUBLIC (decl) = 1;
DECL_EXTERNAL (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
@@ -6952,7 +6954,7 @@ grokvardecl (tree type,
|| TYPE_P (scope)))
decl = build_lang_decl (VAR_DECL, name, type);
else
- decl = build_decl (VAR_DECL, name, type);
+ decl = build_decl (input_location, VAR_DECL, name, type);
if (explicit_scope && TREE_CODE (explicit_scope) == NAMESPACE_DECL)
set_decl_namespace (decl, explicit_scope, 0);
@@ -7063,10 +7065,11 @@ build_ptrmemfunc_type (tree type)
/* ... and not really a class type. */
SET_CLASS_TYPE_P (t, 0);
- field = build_decl (FIELD_DECL, pfn_identifier, type);
+ field = build_decl (input_location, FIELD_DECL, pfn_identifier, type);
fields = field;
- field = build_decl (FIELD_DECL, delta_identifier, delta_type_node);
+ field = build_decl (input_location, FIELD_DECL, delta_identifier,
+ delta_type_node);
TREE_CHAIN (field) = fields;
fields = field;
@@ -8804,7 +8807,7 @@ grokdeclarator (const cp_declarator *declarator,
if (decl_context == FIELD)
decl = build_lang_decl (TYPE_DECL, unqualified_id, type);
else
- decl = build_decl (TYPE_DECL, unqualified_id, type);
+ decl = build_decl (input_location, TYPE_DECL, unqualified_id, type);
if (id_declarator && declarator->u.id.qualifying_scope) {
error ("%Jtypedef name may not be a nested-name-specifier", decl);
TREE_TYPE (decl) = error_mark_node;
@@ -9310,7 +9313,8 @@ grokdeclarator (const cp_declarator *declarator,
}
else
{
- decl = build_decl (FIELD_DECL, unqualified_id, type);
+ decl = build_decl (input_location,
+ FIELD_DECL, unqualified_id, type);
DECL_NONADDRESSABLE_P (decl) = bitfield;
if (bitfield && !unqualified_id)
TREE_NO_WARNING (decl) = 1;
@@ -11387,7 +11391,7 @@ build_enumerator (tree name, tree value, tree enumtype)
else
/* It's a global enum, or it's local to a function. (Note local to
a function could mean local to a class method. */
- decl = build_decl (CONST_DECL, name, type);
+ decl = build_decl (input_location, CONST_DECL, name, type);
DECL_CONTEXT (decl) = FROB_CONTEXT (context);
TREE_CONSTANT (decl) = 1;
@@ -11614,7 +11618,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
{
tree resdecl;
- resdecl = build_decl (RESULT_DECL, 0, restype);
+ resdecl = build_decl (input_location, RESULT_DECL, 0, restype);
DECL_ARTIFICIAL (resdecl) = 1;
DECL_IGNORED_P (resdecl) = 1;
DECL_RESULT (decl1) = resdecl;
@@ -11857,7 +11861,8 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
|| (DECL_CONSTRUCTOR_P (decl1)
&& targetm.cxx.cdtor_returns_this ()))
{
- cdtor_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ cdtor_label = build_decl (input_location,
+ LABEL_DECL, NULL_TREE, NULL_TREE);
DECL_CONTEXT (cdtor_label) = current_function_decl;
}
@@ -12039,13 +12044,13 @@ finish_constructor_body (void)
&& (! TYPE_FOR_JAVA (current_class_type)))
{
/* Any return from a constructor will end up here. */
- add_stmt (build_stmt (LABEL_EXPR, cdtor_label));
+ add_stmt (build_stmt (input_location, LABEL_EXPR, cdtor_label));
val = DECL_ARGUMENTS (current_function_decl);
val = build2 (MODIFY_EXPR, TREE_TYPE (val),
DECL_RESULT (current_function_decl), val);
/* Return the address of the object. */
- exprstmt = build_stmt (RETURN_EXPR, val);
+ exprstmt = build_stmt (input_location, RETURN_EXPR, val);
add_stmt (exprstmt);
}
}
@@ -12087,7 +12092,7 @@ finish_destructor_body (void)
/* Any return from a destructor will end up here; that way all base
and member cleanups will be run when the function returns. */
- add_stmt (build_stmt (LABEL_EXPR, cdtor_label));
+ add_stmt (build_stmt (input_location, LABEL_EXPR, cdtor_label));
/* In a virtual destructor, we must call delete. */
if (DECL_VIRTUAL_P (current_function_decl))
@@ -12125,7 +12130,7 @@ finish_destructor_body (void)
val = build2 (MODIFY_EXPR, TREE_TYPE (val),
DECL_RESULT (current_function_decl), val);
/* Return the address of the object. */
- exprstmt = build_stmt (RETURN_EXPR, val);
+ exprstmt = build_stmt (input_location, RETURN_EXPR, val);
add_stmt (exprstmt);
}
}
@@ -12709,7 +12714,7 @@ cxx_maybe_build_cleanup (tree decl)
call = build_delete (TREE_TYPE (addr), addr,
sfk_complete_destructor, flags, 0);
if (cleanup)
- cleanup = build_compound_expr (cleanup, call);
+ cleanup = build_compound_expr (input_location, cleanup, call);
else
cleanup = call;
}
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b4f4404d1ed..c540c08e932 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -132,7 +132,8 @@ build_memfn_type (tree fntype, tree ctype, cp_cv_quals quals)
tree
cp_build_parm_decl (tree name, tree type)
{
- tree parm = build_decl (PARM_DECL, name, type);
+ tree parm = build_decl (input_location,
+ PARM_DECL, name, type);
/* DECL_ARG_TYPE is only used by the back end and the back end never
sees templates. */
if (!processing_template_decl)
@@ -354,7 +355,7 @@ grok_array_decl (tree array_expr, tree index_exp)
if (array_expr == error_mark_node || index_exp == error_mark_node)
error ("ambiguous conversion for array subscript");
- expr = build_array_ref (array_expr, index_exp, input_location);
+ expr = build_array_ref (input_location, array_expr, index_exp);
}
if (processing_template_decl && expr != error_mark_node)
return build_min_non_dep (ARRAY_REF, expr, orig_array_expr, orig_index_exp,
@@ -1287,7 +1288,8 @@ build_anon_union_vars (tree type, tree object)
{
tree base;
- decl = build_decl (VAR_DECL, DECL_NAME (field), TREE_TYPE (field));
+ decl = build_decl (input_location,
+ VAR_DECL, DECL_NAME (field), TREE_TYPE (field));
DECL_ANON_UNION_VAR_P (decl) = 1;
base = get_base_address (object);
@@ -2495,7 +2497,8 @@ get_guard (tree decl)
/* We use a type that is big enough to contain a mutex as well
as an integer counter. */
guard_type = targetm.cxx.guard_type ();
- guard = build_decl (VAR_DECL, sname, guard_type);
+ guard = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, sname, guard_type);
/* The guard should have the same linkage as what it guards. */
TREE_PUBLIC (guard) = TREE_PUBLIC (decl);
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index 99c70361045..92def0f72d0 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -521,7 +521,7 @@ expand_end_catch_block (void)
tree
begin_eh_spec_block (void)
{
- tree r = build_stmt (EH_SPEC_BLOCK, NULL_TREE, NULL_TREE);
+ tree r = build_stmt (input_location, EH_SPEC_BLOCK, NULL_TREE, NULL_TREE);
add_stmt (r);
EH_SPEC_STMTS (r) = push_stmt_list ();
return r;
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index a99983e18ee..26089965d0c 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2399,7 +2399,8 @@ build_java_class_ref (tree type)
class_decl = IDENTIFIER_GLOBAL_VALUE (name);
if (class_decl == NULL_TREE)
{
- class_decl = build_decl (VAR_DECL, name, TREE_TYPE (jclass_node));
+ class_decl = build_decl (input_location,
+ VAR_DECL, name, TREE_TYPE (jclass_node));
TREE_STATIC (class_decl) = 1;
DECL_EXTERNAL (class_decl) = 1;
TREE_PUBLIC (class_decl) = 1;
@@ -2465,15 +2466,17 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
fold_convert (ptype, base)));
tmp = fold_build1 (NEGATE_EXPR, sizetype, size_exp);
body = build_compound_expr
- (body, cp_build_modify_expr (tbase, NOP_EXPR,
+ (input_location,
+ body, cp_build_modify_expr (tbase, NOP_EXPR,
build2 (POINTER_PLUS_EXPR, ptype, tbase, tmp),
tf_warning_or_error));
body = build_compound_expr
- (body, build_delete (ptype, tbase, sfk_complete_destructor,
+ (input_location,
+ body, build_delete (ptype, tbase, sfk_complete_destructor,
LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 1));
loop = build1 (LOOP_EXPR, void_type_node, body);
- loop = build_compound_expr (tbase_init, loop);
+ loop = build_compound_expr (input_location, tbase_init, loop);
no_destructor:
/* If the delete flag is one, or anything else with the low bit set,
@@ -2520,7 +2523,7 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
else if (!body)
body = deallocate_expr;
else
- body = build_compound_expr (body, deallocate_expr);
+ body = build_compound_expr (input_location, body, deallocate_expr);
if (!body)
body = integer_zero_node;
@@ -2553,11 +2556,11 @@ create_temporary_var (tree type)
{
tree decl;
- decl = build_decl (VAR_DECL, NULL_TREE, type);
+ decl = build_decl (input_location,
+ VAR_DECL, NULL_TREE, type);
TREE_USED (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
- DECL_SOURCE_LOCATION (decl) = input_location;
DECL_CONTEXT (decl) = current_function_decl;
return decl;
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 66377ff1564..bf507411d6f 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -454,7 +454,8 @@ unqualified_name_lookup_error (tree name)
if (current_function_decl)
{
tree decl;
- decl = build_decl (VAR_DECL, name, error_mark_node);
+ decl = build_decl (input_location,
+ VAR_DECL, name, error_mark_node);
DECL_CONTEXT (decl) = current_function_decl;
push_local_binding (name, decl, 0);
/* Mark the variable as used so that we do not get warnings
@@ -511,7 +512,8 @@ build_lang_decl (enum tree_code code, tree name, tree type)
{
tree t;
- t = build_decl (code, name, type);
+ t = build_decl (input_location,
+ code, name, type);
retrofit_lang_decl (t);
/* All nesting of C++ functions is lexical; there is never a "static
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 410503d05e1..0ceff668cd7 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -126,7 +126,8 @@ make_thunk (tree function, bool this_adjusting,
gcc_assert (TYPE_SIZE (DECL_CONTEXT (function))
&& TYPE_BEING_DEFINED (DECL_CONTEXT (function)));
- thunk = build_decl (FUNCTION_DECL, NULL_TREE, TREE_TYPE (function));
+ thunk = build_decl (DECL_SOURCE_LOCATION (function),
+ FUNCTION_DECL, NULL_TREE, TREE_TYPE (function));
DECL_LANG_SPECIFIC (thunk) = DECL_LANG_SPECIFIC (function);
cxx_dup_lang_specific_decl (thunk);
DECL_THUNKS (thunk) = NULL_TREE;
@@ -262,7 +263,8 @@ static GTY (()) int thunk_labelno;
tree
make_alias_for (tree function, tree newid)
{
- tree alias = build_decl (FUNCTION_DECL, newid, TREE_TYPE (function));
+ tree alias = build_decl (DECL_SOURCE_LOCATION (function),
+ FUNCTION_DECL, newid, TREE_TYPE (function));
DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (function);
cxx_dup_lang_specific_decl (alias);
DECL_CONTEXT (alias) = NULL;
@@ -428,7 +430,8 @@ use_thunk (tree thunk_fndecl, bool emit_p)
current_function_decl = thunk_fndecl;
DECL_RESULT (thunk_fndecl)
- = build_decl (RESULT_DECL, 0, integer_type_node);
+ = build_decl (DECL_SOURCE_LOCATION (thunk_fndecl),
+ RESULT_DECL, 0, integer_type_node);
fnname = IDENTIFIER_POINTER (DECL_NAME (thunk_fndecl));
/* The back end expects DECL_INITIAL to contain a BLOCK, so we
create one. */
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 215750f5b40..f6b22bb6793 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3491,7 +3491,7 @@ do_using_directive (tree name_space)
gcc_assert (TREE_CODE (name_space) == NAMESPACE_DECL);
if (building_stmt_tree ())
- add_stmt (build_stmt (USING_STMT, name_space));
+ add_stmt (build_stmt (input_location, USING_STMT, name_space));
name_space = ORIGINAL_NAMESPACE (name_space);
if (!toplevel_bindings_p ())
@@ -5415,7 +5415,7 @@ cp_emit_debug_info_for_using (tree t, tree context)
if (TREE_CODE (t) != TEMPLATE_DECL)
{
if (building_stmt_tree ())
- add_stmt (build_stmt (USING_STMT, t));
+ add_stmt (build_stmt (input_location, USING_STMT, t));
else
(*debug_hooks->imported_module_or_decl) (t, NULL_TREE, context, false);
}
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index b988850d206..07f0375e26e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -6135,7 +6135,7 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p, bool cast_p,
return error_mark_node;
/* Perform the cast. */
- expr = build_c_cast (type, expr);
+ expr = build_c_cast (input_location, type, expr);
return expr;
}
else
@@ -7093,7 +7093,7 @@ cp_parser_label_for_labeled_statement (cp_parser* parser)
expr_hi = NULL_TREE;
if (parser->in_switch_statement_p)
- finish_case_label (expr, expr_hi);
+ finish_case_label (token->location, expr, expr_hi);
else
error ("%Hcase label %qE not within a switch statement",
&token->location, expr);
@@ -7105,7 +7105,7 @@ cp_parser_label_for_labeled_statement (cp_parser* parser)
cp_lexer_consume_token (parser->lexer);
if (parser->in_switch_statement_p)
- finish_case_label (NULL_TREE, NULL_TREE);
+ finish_case_label (token->location, NULL_TREE, NULL_TREE);
else
error ("%Hcase label not within a switch statement", &token->location);
break;
@@ -7326,7 +7326,7 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p)
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
{
location_t loc = cp_lexer_peek_token (parser->lexer)->location;
- add_stmt (build_empty_stmt ());
+ add_stmt (build_empty_stmt (loc));
cp_lexer_consume_token (parser->lexer);
if (!cp_lexer_next_token_is_keyword (parser->lexer, RID_ELSE))
warning_at (loc, OPT_Wempty_body, "suggest braces around "
@@ -7349,10 +7349,12 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p)
/* Parse the else-clause. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
{
- warning_at (cp_lexer_peek_token (parser->lexer)->location,
+ location_t loc;
+ loc = cp_lexer_peek_token (parser->lexer)->location;
+ warning_at (loc,
OPT_Wempty_body, "suggest braces around "
"empty body in an %<else%> statement");
- add_stmt (build_empty_stmt ());
+ add_stmt (build_empty_stmt (loc));
cp_lexer_consume_token (parser->lexer);
}
else
@@ -7860,8 +7862,9 @@ cp_parser_implicitly_scoped_statement (cp_parser* parser, bool *if_p)
/* Mark if () ; with a special NOP_EXPR. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
{
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_lexer_consume_token (parser->lexer);
- statement = add_stmt (build_empty_stmt ());
+ statement = add_stmt (build_empty_stmt (loc));
}
/* if a compound is opened, we simply parse the statement directly. */
else if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
@@ -9680,14 +9683,17 @@ cp_parser_template_parameter_list (cp_parser* parser)
tree parameter;
bool is_non_type;
bool is_parameter_pack;
+ location_t parm_loc;
/* Parse the template-parameter. */
+ parm_loc = cp_lexer_peek_token (parser->lexer)->location;
parameter = cp_parser_template_parameter (parser,
&is_non_type,
&is_parameter_pack);
/* Add it to the list. */
if (parameter != error_mark_node)
parameter_list = process_template_parm (parameter_list,
+ parm_loc,
parameter,
is_non_type,
is_parameter_pack);
@@ -15862,7 +15868,8 @@ cp_parser_member_declaration (cp_parser* parser)
know it is an anonymous aggregate. */
fixup_anonymous_aggr (type);
/* And make the corresponding data member. */
- decl = build_decl (FIELD_DECL, NULL_TREE, type);
+ decl = build_decl (decl_spec_token_start->location,
+ FIELD_DECL, NULL_TREE, type);
/* Add it to the class. */
finish_member_declaration (decl);
}
@@ -19432,6 +19439,7 @@ cp_parser_objc_selector_expression (cp_parser* parser)
tree sel_seq = NULL_TREE;
bool maybe_unary_selector_p = true;
cp_token *token;
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_lexer_consume_token (parser->lexer); /* Eat '@selector'. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>");
@@ -19483,7 +19491,7 @@ cp_parser_objc_selector_expression (cp_parser* parser)
finish_selector:
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
- return objc_build_selector_expr (sel_seq);
+ return objc_build_selector_expr (loc, sel_seq);
}
/* Parse a list of identifiers.
@@ -20256,6 +20264,7 @@ cp_parser_objc_synchronized_statement (cp_parser *parser) {
static tree
cp_parser_objc_throw_statement (cp_parser *parser) {
tree expr = NULL_TREE;
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_parser_require_keyword (parser, RID_AT_THROW, "%<@throw%>");
@@ -20264,7 +20273,7 @@ cp_parser_objc_throw_statement (cp_parser *parser) {
cp_parser_consume_semicolon_at_end_of_statement (parser);
- return objc_build_throw_stmt (expr);
+ return objc_build_throw_stmt (loc, expr);
}
/* Parse an Objective-C statement. */
@@ -20418,7 +20427,7 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind,
cp_parser_name_lookup_error (parser, name, decl, NULL, token->location);
else if (kind != 0)
{
- tree u = build_omp_clause (kind);
+ tree u = build_omp_clause (token->location, kind);
OMP_CLAUSE_DECL (u) = decl;
OMP_CLAUSE_CHAIN (u) = list;
list = u;
@@ -20496,7 +20505,7 @@ cp_parser_omp_clause_collapse (cp_parser *parser, tree list, location_t location
}
check_no_duplicate_clause (list, OMP_CLAUSE_COLLAPSE, "collapse", location);
- c = build_omp_clause (OMP_CLAUSE_COLLAPSE);
+ c = build_omp_clause (loc, OMP_CLAUSE_COLLAPSE);
OMP_CLAUSE_CHAIN (c) = list;
OMP_CLAUSE_COLLAPSE_EXPR (c) = num;
@@ -20554,7 +20563,7 @@ cp_parser_omp_clause_default (cp_parser *parser, tree list, location_t location)
return list;
check_no_duplicate_clause (list, OMP_CLAUSE_DEFAULT, "default", location);
- c = build_omp_clause (OMP_CLAUSE_DEFAULT);
+ c = build_omp_clause (location, OMP_CLAUSE_DEFAULT);
OMP_CLAUSE_CHAIN (c) = list;
OMP_CLAUSE_DEFAULT_KIND (c) = kind;
@@ -20582,7 +20591,7 @@ cp_parser_omp_clause_if (cp_parser *parser, tree list, location_t location)
check_no_duplicate_clause (list, OMP_CLAUSE_IF, "if", location);
- c = build_omp_clause (OMP_CLAUSE_IF);
+ c = build_omp_clause (location, OMP_CLAUSE_IF);
OMP_CLAUSE_IF_EXPR (c) = t;
OMP_CLAUSE_CHAIN (c) = list;
@@ -20600,7 +20609,7 @@ cp_parser_omp_clause_nowait (cp_parser *parser ATTRIBUTE_UNUSED,
check_no_duplicate_clause (list, OMP_CLAUSE_NOWAIT, "nowait", location);
- c = build_omp_clause (OMP_CLAUSE_NOWAIT);
+ c = build_omp_clause (location, OMP_CLAUSE_NOWAIT);
OMP_CLAUSE_CHAIN (c) = list;
return c;
}
@@ -20628,7 +20637,7 @@ cp_parser_omp_clause_num_threads (cp_parser *parser, tree list,
check_no_duplicate_clause (list, OMP_CLAUSE_NUM_THREADS,
"num_threads", location);
- c = build_omp_clause (OMP_CLAUSE_NUM_THREADS);
+ c = build_omp_clause (location, OMP_CLAUSE_NUM_THREADS);
OMP_CLAUSE_NUM_THREADS_EXPR (c) = t;
OMP_CLAUSE_CHAIN (c) = list;
@@ -20647,7 +20656,7 @@ cp_parser_omp_clause_ordered (cp_parser *parser ATTRIBUTE_UNUSED,
check_no_duplicate_clause (list, OMP_CLAUSE_ORDERED,
"ordered", location);
- c = build_omp_clause (OMP_CLAUSE_ORDERED);
+ c = build_omp_clause (location, OMP_CLAUSE_ORDERED);
OMP_CLAUSE_CHAIN (c) = list;
return c;
}
@@ -20729,7 +20738,7 @@ cp_parser_omp_clause_schedule (cp_parser *parser, tree list, location_t location
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"))
return list;
- c = build_omp_clause (OMP_CLAUSE_SCHEDULE);
+ c = build_omp_clause (location, OMP_CLAUSE_SCHEDULE);
if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
{
@@ -20817,7 +20826,7 @@ cp_parser_omp_clause_untied (cp_parser *parser ATTRIBUTE_UNUSED,
check_no_duplicate_clause (list, OMP_CLAUSE_UNTIED, "untied", location);
- c = build_omp_clause (OMP_CLAUSE_UNTIED);
+ c = build_omp_clause (location, OMP_CLAUSE_UNTIED);
OMP_CLAUSE_CHAIN (c) = list;
return c;
}
@@ -21110,7 +21119,7 @@ cp_parser_omp_critical (cp_parser *parser, cp_token *pragma_tok)
cp_parser_require_pragma_eol (parser, pragma_tok);
stmt = cp_parser_omp_structured_block (parser);
- return c_finish_omp_critical (stmt, name);
+ return c_finish_omp_critical (input_location, stmt, name);
}
/* OpenMP 2.5:
@@ -21487,7 +21496,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
{
/* Add lastprivate (decl) clause to OMP_FOR_CLAUSES,
change it to shared (decl) in OMP_PARALLEL_CLAUSES. */
- tree l = build_omp_clause (OMP_CLAUSE_LASTPRIVATE);
+ tree l = build_omp_clause (loc, OMP_CLAUSE_LASTPRIVATE);
OMP_CLAUSE_DECL (l) = real_decl;
OMP_CLAUSE_CHAIN (l) = clauses;
CP_OMP_CLAUSE_INFO (l) = CP_OMP_CLAUSE_INFO (*c);
@@ -21525,7 +21534,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
}
if (c == NULL)
{
- c = build_omp_clause (OMP_CLAUSE_PRIVATE);
+ c = build_omp_clause (loc, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_DECL (c) = decl;
c = finish_omp_clauses (c);
if (c)
@@ -21692,7 +21701,8 @@ static tree
cp_parser_omp_master (cp_parser *parser, cp_token *pragma_tok)
{
cp_parser_require_pragma_eol (parser, pragma_tok);
- return c_finish_omp_master (cp_parser_omp_structured_block (parser));
+ return c_finish_omp_master (input_location,
+ cp_parser_omp_structured_block (parser));
}
/* OpenMP 2.5:
@@ -21702,8 +21712,9 @@ cp_parser_omp_master (cp_parser *parser, cp_token *pragma_tok)
static tree
cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok)
{
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_parser_require_pragma_eol (parser, pragma_tok);
- return c_finish_omp_ordered (cp_parser_omp_structured_block (parser));
+ return c_finish_omp_ordered (loc, cp_parser_omp_structured_block (parser));
}
/* OpenMP 2.5:
@@ -21838,6 +21849,7 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok)
tree stmt, clauses, par_clause, ws_clause, block;
unsigned int mask = OMP_PARALLEL_CLAUSE_MASK;
unsigned int save;
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
if (cp_lexer_next_token_is_keyword (parser->lexer, RID_FOR))
{
@@ -21873,12 +21885,12 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok)
break;
case PRAGMA_OMP_PARALLEL_FOR:
- c_split_parallel_clauses (clauses, &par_clause, &ws_clause);
+ c_split_parallel_clauses (loc, clauses, &par_clause, &ws_clause);
cp_parser_omp_for_loop (parser, ws_clause, &par_clause);
break;
case PRAGMA_OMP_PARALLEL_SECTIONS:
- c_split_parallel_clauses (clauses, &par_clause, &ws_clause);
+ c_split_parallel_clauses (loc, clauses, &par_clause, &ws_clause);
stmt = cp_parser_omp_sections_scope (parser);
if (stmt)
OMP_SECTIONS_CLAUSES (stmt) = ws_clause;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 91bd0d1a32c..7fe40122566 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -383,7 +383,8 @@ push_inline_template_parms_recursive (tree parmlist, int levels)
It is ugly that we recreate this here; the original
version built in process_template_parm is no longer
available. */
- tree decl = build_decl (CONST_DECL, DECL_NAME (parm),
+ tree decl = build_decl (DECL_SOURCE_LOCATION (parm),
+ CONST_DECL, DECL_NAME (parm),
TREE_TYPE (parm));
DECL_ARTIFICIAL (decl) = 1;
TREE_CONSTANT (decl) = 1;
@@ -2931,7 +2932,8 @@ reduce_template_parm_level (tree index, tree type, int levels, tree args,
tree orig_decl = TEMPLATE_PARM_DECL (index);
tree decl, t;
- decl = build_decl (TREE_CODE (orig_decl), DECL_NAME (orig_decl), type);
+ decl = build_decl (DECL_SOURCE_LOCATION (orig_decl),
+ TREE_CODE (orig_decl), DECL_NAME (orig_decl), type);
TREE_CONSTANT (decl) = TREE_CONSTANT (orig_decl);
TREE_READONLY (decl) = TREE_READONLY (orig_decl);
DECL_ARTIFICIAL (decl) = 1;
@@ -2958,10 +2960,11 @@ reduce_template_parm_level (tree index, tree type, int levels, tree args,
/* Process information from new template parameter PARM and append it to the
LIST being built. This new parameter is a non-type parameter iff
IS_NON_TYPE is true. This new parameter is a parameter
- pack iff IS_PARAMETER_PACK is true. */
+ pack iff IS_PARAMETER_PACK is true. The location of PARM is in
+ PARM_LOC. */
tree
-process_template_parm (tree list, tree parm, bool is_non_type,
+process_template_parm (tree list, location_t parm_loc, tree parm, bool is_non_type,
bool is_parameter_pack)
{
tree decl = 0;
@@ -3030,7 +3033,8 @@ process_template_parm (tree list, tree parm, bool is_non_type,
/* A template parameter is not modifiable. */
TREE_CONSTANT (parm) = 1;
TREE_READONLY (parm) = 1;
- decl = build_decl (CONST_DECL, DECL_NAME (parm), TREE_TYPE (parm));
+ decl = build_decl (parm_loc,
+ CONST_DECL, DECL_NAME (parm), TREE_TYPE (parm));
TREE_CONSTANT (decl) = 1;
TREE_READONLY (decl) = 1;
DECL_INITIAL (parm) = DECL_INITIAL (decl)
@@ -3059,7 +3063,8 @@ process_template_parm (tree list, tree parm, bool is_non_type,
{
t = cxx_make_type (TEMPLATE_TYPE_PARM);
/* parm is either IDENTIFIER_NODE or NULL_TREE. */
- decl = build_decl (TYPE_DECL, parm, t);
+ decl = build_decl (parm_loc,
+ TYPE_DECL, parm, t);
}
TYPE_NAME (t) = decl;
@@ -8112,7 +8117,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
TREE_CHAIN (r) = NULL_TREE;
TREE_TYPE (r) = new_type;
DECL_TEMPLATE_RESULT (r)
- = build_decl (TYPE_DECL, DECL_NAME (decl), new_type);
+ = build_decl (DECL_SOURCE_LOCATION (decl),
+ TYPE_DECL, DECL_NAME (decl), new_type);
DECL_TEMPLATE_PARMS (r)
= tsubst_template_parms (DECL_TEMPLATE_PARMS (t), args,
complain);
@@ -10605,7 +10611,7 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree initv,
}
if (c == NULL)
{
- c = build_omp_clause (OMP_CLAUSE_PRIVATE);
+ c = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_DECL (c) = decl;
c = finish_omp_clauses (c);
if (c)
@@ -10890,7 +10896,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
break;
case CASE_LABEL_EXPR:
- finish_case_label (RECUR (CASE_LOW (t)),
+ finish_case_label (EXPR_LOCATION (t),
+ RECUR (CASE_LOW (t)),
RECUR (CASE_HIGH (t)));
break;
@@ -17150,7 +17157,8 @@ make_auto (void)
/* ??? Is it worth caching this for multiple autos at the same level? */
au = cxx_make_type (TEMPLATE_TYPE_PARM);
- TYPE_NAME (au) = build_decl (TYPE_DECL, get_identifier ("auto"), au);
+ TYPE_NAME (au) = build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("auto"), au);
TYPE_STUB_DECL (au) = TYPE_NAME (au);
TEMPLATE_TYPE_PARM_INDEX (au) = build_template_parm_index
(0, processing_template_decl + 1, processing_template_decl + 1,
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 9246fc2854d..c26caa9cb3d 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -1161,7 +1161,8 @@ create_pseudo_type_info (int tk, const char *real_name, ...)
sprintf (pseudo_name + strlen (pseudo_name), "%d", tk - TK_FIXED);
/* First field is the pseudo type_info base class. */
- fields = build_decl (FIELD_DECL, NULL_TREE,
+ fields = build_decl (input_location,
+ FIELD_DECL, NULL_TREE,
VEC_index (tinfo_s, tinfo_descs,
TK_TYPE_INFO_TYPE)->type);
@@ -1290,9 +1291,12 @@ get_pseudo_ti_index (tree type)
push_abi_namespace ();
create_pseudo_type_info
(ix, "__vmi_class_type_info",
- build_decl (FIELD_DECL, NULL_TREE, integer_type_node),
- build_decl (FIELD_DECL, NULL_TREE, integer_type_node),
- build_decl (FIELD_DECL, NULL_TREE, base_array),
+ build_decl (input_location,
+ FIELD_DECL, NULL_TREE, integer_type_node),
+ build_decl (input_location,
+ FIELD_DECL, NULL_TREE, integer_type_node),
+ build_decl (input_location,
+ FIELD_DECL, NULL_TREE, base_array),
NULL);
pop_abi_namespace ();
break;
@@ -1324,10 +1328,12 @@ create_tinfo_types (void)
{
tree field, fields;
- field = build_decl (FIELD_DECL, NULL_TREE, const_ptr_type_node);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, const_ptr_type_node);
fields = field;
- field = build_decl (FIELD_DECL, NULL_TREE, const_string_type_node);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, const_string_type_node);
TREE_CHAIN (field) = fields;
fields = field;
@@ -1353,7 +1359,8 @@ create_tinfo_types (void)
/* Single public non-virtual base class. Add pointer to base class.
This is really a descendant of __class_type_info. */
create_pseudo_type_info (TK_SI_CLASS_TYPE, "__si_class_type_info",
- build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, type_info_ptr_type),
NULL);
/* Base class internal helper. Pointer to base type, offset to base,
@@ -1361,10 +1368,12 @@ create_tinfo_types (void)
{
tree field, fields;
- field = build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, type_info_ptr_type);
fields = field;
- field = build_decl (FIELD_DECL, NULL_TREE, integer_types[itk_long]);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, integer_types[itk_long]);
TREE_CHAIN (field) = fields;
fields = field;
@@ -1381,8 +1390,10 @@ create_tinfo_types (void)
and pointer to the pointed to type. This is really a descendant of
__pbase_type_info. */
create_pseudo_type_info (TK_POINTER_TYPE, "__pointer_type_info",
- build_decl (FIELD_DECL, NULL_TREE, integer_type_node),
- build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, integer_type_node),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, type_info_ptr_type),
NULL);
/* Pointer to member data type_info. Add qualifications flags,
@@ -1390,9 +1401,12 @@ create_tinfo_types (void)
This is really a descendant of __pbase_type_info. */
create_pseudo_type_info (TK_POINTER_MEMBER_TYPE,
"__pointer_to_member_type_info",
- build_decl (FIELD_DECL, NULL_TREE, integer_type_node),
- build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type),
- build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, integer_type_node),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, type_info_ptr_type),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, type_info_ptr_type),
NULL);
pop_abi_namespace ();
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index adb6023aecf..bacb09a1262 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -420,7 +420,7 @@ maybe_cleanup_point_expr_void (tree expr)
void
add_decl_expr (tree decl)
{
- tree r = build_stmt (DECL_EXPR, decl);
+ tree r = build_stmt (input_location, DECL_EXPR, decl);
if (DECL_INITIAL (decl)
|| (DECL_SIZE (decl) && TREE_SIDE_EFFECTS (DECL_SIZE (decl))))
r = maybe_cleanup_point_expr_void (r);
@@ -441,7 +441,7 @@ do_poplevel (tree stmt_list)
if (!processing_template_decl)
{
- stmt_list = c_build_bind_expr (block, stmt_list);
+ stmt_list = c_build_bind_expr (input_location, block, stmt_list);
/* ??? See c_end_compound_stmt re statement expressions. */
}
@@ -466,7 +466,7 @@ do_pushlevel (scope_kind sk)
void
push_cleanup (tree decl, tree cleanup, bool eh_only)
{
- tree stmt = build_stmt (CLEANUP_STMT, NULL, cleanup, decl);
+ tree stmt = build_stmt (input_location, CLEANUP_STMT, NULL, cleanup, decl);
CLEANUP_EH_ONLY (stmt) = eh_only;
add_stmt (stmt);
CLEANUP_BODY (stmt) = push_stmt_list ();
@@ -561,7 +561,7 @@ finish_goto_stmt (tree destination)
check_goto (destination);
- return add_stmt (build_stmt (GOTO_EXPR, destination));
+ return add_stmt (build_stmt (input_location, GOTO_EXPR, destination));
}
/* COND is the condition-expression for an if, while, etc.,
@@ -624,7 +624,7 @@ finish_expr_stmt (tree expr)
if (TREE_CODE (expr) != CLEANUP_POINT_EXPR)
{
if (TREE_CODE (expr) != EXPR_STMT)
- expr = build_stmt (EXPR_STMT, expr);
+ expr = build_stmt (input_location, EXPR_STMT, expr);
expr = maybe_cleanup_point_expr_void (expr);
}
@@ -645,7 +645,7 @@ begin_if_stmt (void)
{
tree r, scope;
scope = do_pushlevel (sk_block);
- r = build_stmt (IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
+ r = build_stmt (input_location, IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
TREE_CHAIN (r) = scope;
begin_cond (&IF_COND (r));
return r;
@@ -707,7 +707,7 @@ tree
begin_while_stmt (void)
{
tree r;
- r = build_stmt (WHILE_STMT, NULL_TREE, NULL_TREE);
+ r = build_stmt (input_location, WHILE_STMT, NULL_TREE, NULL_TREE);
add_stmt (r);
WHILE_BODY (r) = do_pushlevel (sk_block);
begin_cond (&WHILE_COND (r));
@@ -739,7 +739,7 @@ finish_while_stmt (tree while_stmt)
tree
begin_do_stmt (void)
{
- tree r = build_stmt (DO_STMT, NULL_TREE, NULL_TREE);
+ tree r = build_stmt (input_location, DO_STMT, NULL_TREE, NULL_TREE);
add_stmt (r);
DO_BODY (r) = push_stmt_list ();
return r;
@@ -801,7 +801,7 @@ finish_return_stmt (tree expr)
}
}
- r = build_stmt (RETURN_EXPR, expr);
+ r = build_stmt (input_location, RETURN_EXPR, expr);
TREE_NO_WARNING (r) |= no_warning;
r = maybe_cleanup_point_expr_void (r);
r = add_stmt (r);
@@ -817,7 +817,7 @@ begin_for_stmt (void)
{
tree r;
- r = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
+ r = build_stmt (input_location, FOR_STMT, NULL_TREE, NULL_TREE,
NULL_TREE, NULL_TREE);
if (flag_new_for_scope > 0)
@@ -908,7 +908,7 @@ finish_for_stmt (tree for_stmt)
tree
finish_break_stmt (void)
{
- return add_stmt (build_stmt (BREAK_STMT));
+ return add_stmt (build_stmt (input_location, BREAK_STMT));
}
/* Finish a continue-statement. */
@@ -916,7 +916,7 @@ finish_break_stmt (void)
tree
finish_continue_stmt (void)
{
- return add_stmt (build_stmt (CONTINUE_STMT));
+ return add_stmt (build_stmt (input_location, CONTINUE_STMT));
}
/* Begin a switch-statement. Returns a new SWITCH_STMT if
@@ -927,7 +927,7 @@ begin_switch_stmt (void)
{
tree r, scope;
- r = build_stmt (SWITCH_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
+ r = build_stmt (input_location, SWITCH_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
scope = do_pushlevel (sk_block);
TREE_CHAIN (r) = scope;
@@ -997,7 +997,7 @@ finish_switch_stmt (tree switch_stmt)
tree
begin_try_block (void)
{
- tree r = build_stmt (TRY_BLOCK, NULL_TREE, NULL_TREE);
+ tree r = build_stmt (input_location, TRY_BLOCK, NULL_TREE, NULL_TREE);
add_stmt (r);
TRY_STMTS (r) = push_stmt_list ();
return r;
@@ -1087,7 +1087,7 @@ begin_handler (void)
{
tree r;
- r = build_stmt (HANDLER, NULL_TREE, NULL_TREE);
+ r = build_stmt (input_location, HANDLER, NULL_TREE, NULL_TREE);
add_stmt (r);
/* Create a binding level for the eh_info and the exception object
@@ -1307,7 +1307,7 @@ finish_asm_stmt (int volatile_p, tree string, tree output_operands,
}
}
- r = build_stmt (ASM_EXPR, string,
+ r = build_stmt (input_location, ASM_EXPR, string,
output_operands, input_operands,
clobbers);
ASM_VOLATILE_P (r) = volatile_p || noutputs == 0;
@@ -1325,7 +1325,7 @@ finish_label_stmt (tree name)
if (decl == error_mark_node)
return error_mark_node;
- add_stmt (build_stmt (LABEL_EXPR, decl));
+ add_stmt (build_stmt (input_location, LABEL_EXPR, decl));
return decl;
}
@@ -1718,7 +1718,7 @@ finish_stmt_expr_expr (tree expr, tree stmt_expr)
if (processing_template_decl)
{
- expr = build_stmt (EXPR_STMT, expr);
+ expr = build_stmt (input_location, EXPR_STMT, expr);
expr = add_stmt (expr);
/* Mark the last statement so that we can recognize it as such at
template-instantiation time. */
@@ -1990,7 +1990,7 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual,
if (TREE_CODE (fn) == FUNCTION_DECL
&& (DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
|| DECL_BUILT_IN_CLASS (fn) == BUILT_IN_MD))
- result = resolve_overloaded_builtin (fn, *args);
+ result = resolve_overloaded_builtin (input_location, fn, *args);
if (!result)
/* A call to a namespace-scope function. */
@@ -2137,7 +2137,7 @@ finish_unary_op_expr (enum tree_code code, tree expr)
TREE_NEGATED_INT (result) = 1;
}
if (TREE_OVERFLOW_P (result) && !TREE_OVERFLOW_P (expr))
- overflow_warning (result);
+ overflow_warning (input_location, result);
return result;
}
@@ -2250,7 +2250,8 @@ finish_template_type_parm (tree aggr, tree identifier)
tree
finish_template_template_parm (tree aggr, tree identifier)
{
- tree decl = build_decl (TYPE_DECL, identifier, NULL_TREE);
+ tree decl = build_decl (input_location,
+ TYPE_DECL, identifier, NULL_TREE);
tree tmpl = build_lang_decl (TEMPLATE_DECL, identifier, NULL_TREE);
DECL_TEMPLATE_PARMS (tmpl) = current_template_parms;
DECL_TEMPLATE_RESULT (tmpl) = decl;
@@ -3330,7 +3331,7 @@ finalize_nrv_r (tree* tp, int* walk_subtrees, void* data)
init = build2 (INIT_EXPR, void_type_node, dp->result,
DECL_INITIAL (dp->var));
else
- init = build_empty_stmt ();
+ init = build_empty_stmt (EXPR_LOCATION (*tp));
DECL_INITIAL (dp->var) = NULL_TREE;
SET_EXPR_LOCUS (init, EXPR_LOCUS (*tp));
*tp = init;
@@ -4136,7 +4137,7 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv,
TREE_CODE (cond), decl, diff,
tf_warning_or_error);
incr = build_modify_expr (elocus, decl, NULL_TREE, PLUS_EXPR,
- incr, NULL_TREE);
+ elocus, incr, NULL_TREE);
orig_body = *body;
*body = push_stmt_list ();
@@ -4427,7 +4428,7 @@ finish_omp_atomic (enum tree_code code, tree lhs, tree rhs)
}
if (!dependent_p)
{
- stmt = c_finish_omp_atomic (code, lhs, rhs);
+ stmt = c_finish_omp_atomic (input_location, code, lhs, rhs);
if (stmt == error_mark_node)
return;
}
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index b40ef10d0e9..7c48a3257b3 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -302,7 +302,8 @@ build_target_expr (tree decl, tree value)
static tree
build_local_temp (tree type)
{
- tree slot = build_decl (VAR_DECL, NULL_TREE, type);
+ tree slot = build_decl (input_location,
+ VAR_DECL, NULL_TREE, type);
DECL_ARTIFICIAL (slot) = 1;
DECL_IGNORED_P (slot) = 1;
DECL_CONTEXT (slot) = current_function_decl;
@@ -1421,7 +1422,8 @@ bind_template_template_parm (tree t, tree newargs)
tree t2;
t2 = cxx_make_type (BOUND_TEMPLATE_TEMPLATE_PARM);
- decl = build_decl (TYPE_DECL, DECL_NAME (decl), NULL_TREE);
+ decl = build_decl (input_location,
+ TYPE_DECL, DECL_NAME (decl), NULL_TREE);
/* These nodes have to be created to reflect new TYPE_DECL and template
arguments. */
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index b384feae1a4..1ad75065d6e 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1349,7 +1349,7 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain)
return value;
}
- return c_sizeof_or_alignof_type (complete_type (type),
+ return c_sizeof_or_alignof_type (input_location, complete_type (type),
op == SIZEOF_EXPR,
complain);
}
@@ -2573,7 +2573,7 @@ cp_build_indirect_ref (tree ptr, const char *errorstring,
LOC is the location to use in building the array reference. */
tree
-build_array_ref (tree array, tree idx, location_t loc)
+build_array_ref (location_t loc, tree array, tree idx)
{
tree ret;
@@ -2593,7 +2593,7 @@ build_array_ref (tree array, tree idx, location_t loc)
{
case COMPOUND_EXPR:
{
- tree value = build_array_ref (TREE_OPERAND (array, 1), idx, loc);
+ tree value = build_array_ref (loc, TREE_OPERAND (array, 1), idx);
ret = build2 (COMPOUND_EXPR, TREE_TYPE (value),
TREE_OPERAND (array, 0), value);
SET_EXPR_LOCATION (ret, loc);
@@ -2603,9 +2603,9 @@ build_array_ref (tree array, tree idx, location_t loc)
case COND_EXPR:
ret = build_conditional_expr
(TREE_OPERAND (array, 0),
- build_array_ref (TREE_OPERAND (array, 1), idx, loc),
- build_array_ref (TREE_OPERAND (array, 2), idx, loc),
- tf_warning_or_error);
+ build_array_ref (loc, TREE_OPERAND (array, 1), idx),
+ build_array_ref (loc, TREE_OPERAND (array, 2), idx),
+ tf_warning_or_error);
protected_set_expr_location (ret, loc);
return ret;
@@ -2864,14 +2864,16 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function)
/* Used by the C-common bits. */
tree
-build_function_call (tree function, tree params)
+build_function_call (location_t loc ATTRIBUTE_UNUSED,
+ tree function, tree params)
{
return cp_build_function_call (function, params, tf_warning_or_error);
}
/* Used by the C-common bits. */
tree
-build_function_call_vec (tree function, VEC(tree,gc) *params,
+build_function_call_vec (location_t loc ATTRIBUTE_UNUSED,
+ tree function, VEC(tree,gc) *params,
VEC(tree,gc) *origtypes ATTRIBUTE_UNUSED)
{
VEC(tree,gc) *orig_params = params;
@@ -4067,7 +4069,7 @@ cp_build_binary_op (location_t location,
if (TREE_OVERFLOW_P (result)
&& !TREE_OVERFLOW_P (op0)
&& !TREE_OVERFLOW_P (op1))
- overflow_warning (result);
+ overflow_warning (location, result);
return result;
}
@@ -5079,7 +5081,7 @@ build_x_compound_expr (tree op1, tree op2, tsubst_flags_t complain)
/* Like cp_build_compound_expr, but for the c-common bits. */
tree
-build_compound_expr (tree lhs, tree rhs)
+build_compound_expr (location_t loc ATTRIBUTE_UNUSED, tree lhs, tree rhs)
{
return cp_build_compound_expr (lhs, rhs, tf_warning_or_error);
}
@@ -5836,7 +5838,7 @@ build_const_cast (tree type, tree expr, tsubst_flags_t complain)
/* Like cp_build_c_cast, but for the c-common bits. */
tree
-build_c_cast (tree type, tree expr)
+build_c_cast (location_t loc ATTRIBUTE_UNUSED, tree type, tree expr)
{
return cp_build_c_cast (type, expr, tf_warning_or_error);
}
@@ -5953,7 +5955,8 @@ cp_build_c_cast (tree type, tree expr, tsubst_flags_t complain)
tree
build_modify_expr (location_t location ATTRIBUTE_UNUSED,
tree lhs, tree lhs_origtype ATTRIBUTE_UNUSED,
- enum tree_code modifycode, tree rhs,
+ enum tree_code modifycode,
+ location_t rhs_location ATTRIBUTE_UNUSED, tree rhs,
tree rhs_origtype ATTRIBUTE_UNUSED)
{
return cp_build_modify_expr (lhs, modifycode, rhs, tf_warning_or_error);
@@ -6501,7 +6504,7 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p)
/* Handle null pointer to member function conversions. */
if (integer_zerop (pfn))
{
- pfn = build_c_cast (type, integer_zero_node);
+ pfn = build_c_cast (input_location, type, integer_zero_node);
return build_ptrmemfunc1 (to_type,
integer_zero_node,
pfn);
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index e66842733a0..8bec2217189 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -516,7 +516,7 @@ split_nonconstant_init_1 (tree dest, tree init)
NULL_TREE);
code = build2 (INIT_EXPR, inner_type, sub, value);
- code = build_stmt (EXPR_STMT, code);
+ code = build_stmt (input_location, EXPR_STMT, code);
add_stmt (code);
continue;
}
@@ -530,7 +530,7 @@ split_nonconstant_init_1 (tree dest, tree init)
tree cons = copy_node (init);
CONSTRUCTOR_ELTS (init) = NULL;
code = build2 (MODIFY_EXPR, type, dest, cons);
- code = build_stmt (EXPR_STMT, code);
+ code = build_stmt (input_location, EXPR_STMT, code);
add_stmt (code);
}
break;
diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c
index 7e3fc82c9de..fcd87185018 100644
--- a/gcc/dwarf2asm.c
+++ b/gcc/dwarf2asm.c
@@ -871,7 +871,7 @@ dw2_output_indirect_constant_1 (splay_tree_node node,
sym = (const char *) node->key;
id = (tree) node->value;
- decl = build_decl (VAR_DECL, id, ptr_type_node);
+ decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, id, ptr_type_node);
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
DECL_INITIAL (decl) = decl;
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 98fb243b612..e452c28c2a5 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -2242,7 +2242,8 @@ get_spill_slot_decl (bool force_build_p)
if (d || !force_build_p)
return d;
- d = build_decl (VAR_DECL, get_identifier ("%sfp"), void_type_node);
+ d = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ VAR_DECL, get_identifier ("%sfp"), void_type_node);
DECL_ARTIFICIAL (d) = 1;
DECL_IGNORED_P (d) = 1;
TREE_USED (d) = 1;
diff --git a/gcc/except.c b/gcc/except.c
index ff45a7e6d72..8ec252bbab3 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -221,11 +221,13 @@ init_eh (void)
sjlj_fc_type_node = lang_hooks.types.make_type (RECORD_TYPE);
- f_prev = build_decl (FIELD_DECL, get_identifier ("__prev"),
+ f_prev = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__prev"),
build_pointer_type (sjlj_fc_type_node));
DECL_FIELD_CONTEXT (f_prev) = sjlj_fc_type_node;
- f_cs = build_decl (FIELD_DECL, get_identifier ("__call_site"),
+ f_cs = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__call_site"),
integer_type_node);
DECL_FIELD_CONTEXT (f_cs) = sjlj_fc_type_node;
@@ -233,14 +235,17 @@ init_eh (void)
tmp = build_array_type (lang_hooks.types.type_for_mode
(targetm.unwind_word_mode (), 1),
tmp);
- f_data = build_decl (FIELD_DECL, get_identifier ("__data"), tmp);
+ f_data = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__data"), tmp);
DECL_FIELD_CONTEXT (f_data) = sjlj_fc_type_node;
- f_per = build_decl (FIELD_DECL, get_identifier ("__personality"),
+ f_per = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__personality"),
ptr_type_node);
DECL_FIELD_CONTEXT (f_per) = sjlj_fc_type_node;
- f_lsda = build_decl (FIELD_DECL, get_identifier ("__lsda"),
+ f_lsda = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__lsda"),
ptr_type_node);
DECL_FIELD_CONTEXT (f_lsda) = sjlj_fc_type_node;
@@ -260,7 +265,8 @@ init_eh (void)
#endif
tmp = build_index_type (tmp);
tmp = build_array_type (ptr_type_node, tmp);
- f_jbuf = build_decl (FIELD_DECL, get_identifier ("__jbuf"), tmp);
+ f_jbuf = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__jbuf"), tmp);
#ifdef DONT_USE_BUILTIN_SETJMP
/* We don't know what the alignment requirements of the
runtime's jmp_buf has. Overestimate. */
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 16f7415b549..321d5f6918d 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -5076,7 +5076,7 @@ make_tree (tree type, rtx x)
/* else fall through. */
default:
- t = build_decl (VAR_DECL, NULL_TREE, type);
+ t = build_decl (RTL_LOCATION (x), VAR_DECL, NULL_TREE, type);
/* If TYPE is a POINTER_TYPE, X might be Pmode with TYPE_MODE being
ptr_mode. So convert. */
diff --git a/gcc/expr.c b/gcc/expr.c
index f287c9f4f62..ec1800e63a2 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -1424,7 +1424,7 @@ init_block_move_fn (const char *asmspec)
const_ptr_type_node, sizetype,
NULL_TREE);
- fn = build_decl (FUNCTION_DECL, fn, args);
+ fn = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, fn, args);
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
@@ -2714,7 +2714,7 @@ init_block_clear_fn (const char *asmspec)
integer_type_node, sizetype,
NULL_TREE);
- fn = build_decl (FUNCTION_DECL, fn, args);
+ fn = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, fn, args);
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
@@ -5498,7 +5498,8 @@ store_constructor (tree exp, rtx target, int cleared, HOST_WIDE_INT size)
expand_normal (hi_index);
unsignedp = TYPE_UNSIGNED (domain);
- index = build_decl (VAR_DECL, NULL_TREE, domain);
+ index = build_decl (EXPR_LOCATION (exp),
+ VAR_DECL, NULL_TREE, domain);
index_r
= gen_reg_rtx (promote_mode (domain, DECL_MODE (index),
@@ -7537,7 +7538,8 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
with non-BLKmode values. */
gcc_assert (GET_MODE (ret) != BLKmode);
- val = build_decl (VAR_DECL, NULL, TREE_TYPE (exp));
+ val = build_decl (EXPR_LOCATION (exp),
+ VAR_DECL, NULL, TREE_TYPE (exp));
DECL_ARTIFICIAL (val) = 1;
DECL_IGNORED_P (val) = 1;
TREE_OPERAND (exp, 0) = val;
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index c9025f1a8d0..ea0de36e862 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,59 @@
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * trans-array.c (gfc_trans_allocate_array_storage): Pass
+ location on down.
+ (gfc_trans_array_constructor_value): Same.
+ (gfc_trans_scalarized_loop_end): Same.
+ (gfc_conv_ss_startstride): Same.
+ (gfc_trans_g77_array): Same.
+ (gfc_trans_dummy_array_bias): Same.
+ (gfc_conv_array_parameter): Same.
+ (structure_alloc_comps): Same.
+ * trans-expr.c (gfc_conv_function_call): Same.
+ (fill_with_spaces): Same.
+ (gfc_trans_string_copy): Same.
+ (gfc_trans_scalar_assign): Same.
+ * trans-stmt.c (gfc_trans_goto): Same.
+ (gfc_trans_if_1): Same.
+ (gfc_trans_simple_do): Same.
+ (gfc_trans_do): Same.
+ (gfc_trans_do_while): Same.
+ (gfc_trans_logical_select): Same.
+ (gfc_trans_select): Same.
+ (gfc_trans_forall_loop): Same.
+ (gfc_trans_nested_forall_loop): Same.
+ (generate_loop_for_temp_to_lhs): Same.
+ (generate_loop_for_rhs_to_temp): Same.
+ (gfc_trans_forall_1): Same.
+ (gfc_trans_where_assign): Same.
+ (gfc_trans_where_3): Same.
+ (gfc_trans_allocate): Same.
+ * trans.c (gfc_finish_block): Same.
+ (gfc_trans_runtime_check): Same.
+ (gfc_call_malloc): Same.
+ (gfc_allocate_with_status): Same.
+ (gfc_call_free): Same.
+ (gfc_deallocate_with_status): Same.
+ (gfc_call_realloc): Same.
+ (gfc_trans_code): Same.
+ * trans-decl.c (gfc_init_default_dt): Same.
+ (gfc_generate_constructors): Same.
+ * trans-io.c (gfc_trans_io_runtime_check): Same.
+ * trans-intrinsic.c (gfc_conv_intrinsic_ctime): Same.
+ (gfc_conv_intrinsic_fdate): Same.
+ (gfc_conv_intrinsic_ttynam): Same.
+ (gfc_conv_intrinsic_minmax): Same.
+ (gfc_conv_intrinsic_minmax_char): Same.
+ (gfc_conv_intrinsic_anyall): Same.
+ (gfc_conv_intrinsic_count): Same.
+ (gfc_conv_intrinsic_arith): Same.
+ (gfc_conv_intrinsic_minmaxloc): Same.
+ (gfc_conv_intrinsic_minmaxval): Same.
+ (gfc_conv_intrinsic_rrspacing): Same.
+ (gfc_conv_intrinsic_array_transfer): Same.
+ (gfc_conv_intrinsic_trim): Same.
+ (gfc_conv_intrinsic_repeat): Same.
+
2009-06-12 Janus Weil <janus@gcc.gnu.org>
PR fortran/40176
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 5a371b8036f..cf38fc371be 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -635,7 +635,8 @@ gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post,
was_packed = fold_build2 (EQ_EXPR, boolean_type_node,
packed, source_data);
tmp = gfc_finish_block (&do_copying);
- tmp = build3_v (COND_EXPR, was_packed, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, was_packed, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (pre, tmp);
tmp = fold_convert (pvoid_type_node, packed);
@@ -1442,7 +1443,8 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type,
shadow_loopvar, end));
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
/* The main loop body. */
@@ -2776,12 +2778,13 @@ gfc_trans_scalarized_loop_end (gfc_loopinfo * loop, int n,
TREE_TYPE (stmt) = void_type_node;
OMP_FOR_BODY (stmt) = loopbody = gfc_finish_block (pbody);
- OMP_FOR_CLAUSES (stmt) = build_omp_clause (OMP_CLAUSE_SCHEDULE);
+ OMP_FOR_CLAUSES (stmt) = build_omp_clause (input_location,
+ OMP_CLAUSE_SCHEDULE);
OMP_CLAUSE_SCHEDULE_KIND (OMP_FOR_CLAUSES (stmt))
= OMP_CLAUSE_SCHEDULE_STATIC;
if (ompws_flags & OMPWS_NOWAIT)
OMP_CLAUSE_CHAIN (OMP_FOR_CLAUSES (stmt))
- = build_omp_clause (OMP_CLAUSE_NOWAIT);
+ = build_omp_clause (input_location, OMP_CLAUSE_NOWAIT);
/* Initialize the loopvar. */
TREE_VEC_ELT (init, 0) = build2_v (MODIFY_EXPR, loop->loopvar[n],
@@ -2818,7 +2821,7 @@ gfc_trans_scalarized_loop_end (gfc_loopinfo * loop, int n,
loop->loopvar[n], loop->to[n]);
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
/* The main body. */
@@ -3337,7 +3340,7 @@ gfc_conv_ss_startstride (gfc_loopinfo * loop)
|| ss->expr->symtree->n.sym->attr.not_always_present)
tmp = build3_v (COND_EXPR,
gfc_conv_expr_present (ss->expr->symtree->n.sym),
- tmp, build_empty_stmt ());
+ tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
@@ -4391,7 +4394,7 @@ gfc_trans_g77_array (gfc_symbol * sym, tree body)
if (sym->attr.optional || sym->attr.not_always_present)
{
tmp = gfc_conv_expr_present (sym);
- stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&block, stmt);
@@ -4675,7 +4678,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body)
if (optional_arg)
{
tmp = gfc_conv_expr_present (sym);
- stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&block, stmt);
@@ -4704,12 +4707,13 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body)
tmp = build_fold_indirect_ref (dumdesc);
tmp = gfc_conv_descriptor_data_get (tmp);
tmp = fold_build2 (NE_EXPR, boolean_type_node, tmp, tmpdesc);
- stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt (input_location));
if (optional_arg)
{
tmp = gfc_conv_expr_present (sym);
- stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ stmt = build3_v (COND_EXPR, tmp, stmt,
+ build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&block, stmt);
}
@@ -5603,7 +5607,7 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77,
tmp = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
gfc_conv_expr_present (sym), tmp);
- tmp = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &se->post);
@@ -5807,7 +5811,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
tmp = gfc_finish_block (&fnblock);
if (null_cond != NULL_TREE)
- tmp = build3_v (COND_EXPR, null_cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, null_cond, tmp,
+ build_empty_stmt (input_location));
return tmp;
}
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index 6cf9d5b0979..f4bbb467bc9 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -278,8 +278,8 @@ build_field (segment_info *h, tree union_type, record_layout_info rli)
unsigned HOST_WIDE_INT desired_align, known_align;
name = get_identifier (h->sym->name);
- field = build_decl (FIELD_DECL, name, h->field);
- gfc_set_decl_location (field, &h->sym->declared_at);
+ field = build_decl (h->sym->declared_at.lb->location,
+ FIELD_DECL, name, h->field);
known_align = (offset & -offset) * BITS_PER_UNIT;
if (known_align == 0 || known_align > BIGGEST_ALIGNMENT)
known_align = BIGGEST_ALIGNMENT;
@@ -349,7 +349,8 @@ build_equiv_decl (tree union_type, bool is_init, bool is_saved)
}
snprintf (name, sizeof (name), "equiv.%d", serial++);
- decl = build_decl (VAR_DECL, get_identifier (name), union_type);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (name), union_type);
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
@@ -412,7 +413,8 @@ build_common_decl (gfc_common_head *com, tree union_type, bool is_init)
/* If there is no backend_decl for the common block, build it. */
if (decl == NULL_TREE)
{
- decl = build_decl (VAR_DECL, get_identifier (com->name), union_type);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (com->name), union_type);
SET_DECL_ASSEMBLER_NAME (decl, gfc_sym_mangled_common_id (com));
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
@@ -527,8 +529,8 @@ get_init_field (segment_info *head, tree union_type, tree *field_init,
tmp = build_range_type (gfc_array_index_type,
gfc_index_zero_node, tmp);
tmp = build_array_type (type, tmp);
- field = build_decl (FIELD_DECL, NULL_TREE, tmp);
- gfc_set_decl_location (field, &gfc_current_locus);
+ field = build_decl (gfc_current_locus.lb->location,
+ FIELD_DECL, NULL_TREE, tmp);
known_align = BIGGEST_ALIGNMENT;
@@ -675,9 +677,9 @@ create_common (gfc_common_head *com, segment_info *head, bool saw_equiv)
{
tree var_decl;
- var_decl = build_decl (VAR_DECL, DECL_NAME (s->field),
+ var_decl = build_decl (s->sym->declared_at.lb->location,
+ VAR_DECL, DECL_NAME (s->field),
TREE_TYPE (s->field));
- gfc_set_decl_location (var_decl, &s->sym->declared_at);
TREE_PUBLIC (var_decl) = TREE_PUBLIC (decl);
TREE_STATIC (var_decl) = TREE_STATIC (decl);
TREE_USED (var_decl) = TREE_USED (decl);
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index a491c0b1f21..c647e92a372 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -203,7 +203,8 @@ gfc_build_label_decl (tree label_id)
label_name = NULL;
/* Build the LABEL_DECL node. Labels have no type. */
- label_decl = build_decl (LABEL_DECL, label_id, void_type_node);
+ label_decl = build_decl (input_location,
+ LABEL_DECL, label_id, void_type_node);
DECL_CONTEXT (label_decl) = current_function_decl;
DECL_MODE (label_decl) = VOIDmode;
@@ -750,7 +751,8 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
DECL_IGNORED_P (GFC_TYPE_ARRAY_UBOUND (type, dim)) = 0;
}
}
- TYPE_NAME (type) = type_decl = build_decl (TYPE_DECL, NULL, gtype);
+ TYPE_NAME (type) = type_decl = build_decl (input_location,
+ TYPE_DECL, NULL, gtype);
DECL_ORIGINAL_TYPE (type_decl) = gtype;
}
}
@@ -842,7 +844,8 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy)
}
ASM_FORMAT_PRIVATE_NAME (name, IDENTIFIER_POINTER (DECL_NAME (dummy)), 0);
- decl = build_decl (VAR_DECL, get_identifier (name), type);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (name), type);
DECL_ARTIFICIAL (decl) = 1;
TREE_PUBLIC (decl) = 0;
@@ -892,7 +895,7 @@ gfc_nonlocal_dummy_array_decl (gfc_symbol *sym)
return;
dummy = GFC_DECL_SAVED_DESCRIPTOR (sym->backend_decl);
- decl = build_decl (VAR_DECL, DECL_NAME (dummy),
+ decl = build_decl (input_location, VAR_DECL, DECL_NAME (dummy),
TREE_TYPE (sym->backend_decl));
DECL_ARTIFICIAL (decl) = 0;
TREE_USED (decl) = 1;
@@ -926,7 +929,8 @@ gfc_create_string_length (gfc_symbol * sym)
/* Also prefix the mangled name. */
strcpy (&name[1], sym->name);
name[0] = '.';
- length = build_decl (VAR_DECL, get_identifier (name),
+ length = build_decl (input_location,
+ VAR_DECL, get_identifier (name),
gfc_charlen_type_node);
DECL_ARTIFICIAL (length) = 1;
TREE_USED (length) = 1;
@@ -955,9 +959,11 @@ gfc_add_assign_aux_vars (gfc_symbol * sym)
decl = sym->backend_decl;
gfc_allocate_lang_decl (decl);
GFC_DECL_ASSIGN (decl) = 1;
- length = build_decl (VAR_DECL, create_tmp_var_name (sym->name),
+ length = build_decl (input_location,
+ VAR_DECL, create_tmp_var_name (sym->name),
gfc_charlen_type_node);
- addr = build_decl (VAR_DECL, create_tmp_var_name (sym->name),
+ addr = build_decl (input_location,
+ VAR_DECL, create_tmp_var_name (sym->name),
pvoid_type_node);
gfc_finish_var_decl (length, sym);
gfc_finish_var_decl (addr, sym);
@@ -1079,9 +1085,8 @@ gfc_get_symbol_decl (gfc_symbol * sym)
length = gfc_create_string_length (sym);
/* Create the decl for the variable. */
- decl = build_decl (VAR_DECL, gfc_sym_identifier (sym), gfc_sym_type (sym));
-
- gfc_set_decl_location (decl, &sym->declared_at);
+ decl = build_decl (sym->declared_at.lb->location,
+ VAR_DECL, gfc_sym_identifier (sym), gfc_sym_type (sym));
/* Symbols from modules should have their assembler names mangled.
This is done here rather than in gfc_finish_var_decl because it
@@ -1150,7 +1155,8 @@ gfc_get_symbol_decl (gfc_symbol * sym)
{
tree span;
GFC_DECL_SUBREF_ARRAY_P (decl) = 1;
- span = build_decl (VAR_DECL, create_tmp_var_name ("span"),
+ span = build_decl (input_location,
+ VAR_DECL, create_tmp_var_name ("span"),
gfc_array_index_type);
gfc_finish_var_decl (span, sym);
TREE_STATIC (span) = TREE_STATIC (decl);
@@ -1222,7 +1228,8 @@ get_proc_pointer_decl (gfc_symbol *sym)
if (decl)
return decl;
- decl = build_decl (VAR_DECL, get_identifier (sym->name),
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (sym->name),
build_pointer_type (gfc_get_function_type (sym)));
if ((sym->ns->proc_name
@@ -1380,7 +1387,8 @@ gfc_get_extern_function_decl (gfc_symbol * sym)
}
type = gfc_get_function_type (sym);
- fndecl = build_decl (FUNCTION_DECL, name, type);
+ fndecl = build_decl (input_location,
+ FUNCTION_DECL, name, type);
SET_DECL_ASSEMBLER_NAME (fndecl, mangled_name);
/* If the return type is a pointer, avoid alias issues by setting
@@ -1461,7 +1469,8 @@ build_function_decl (gfc_symbol * sym)
== NAMESPACE_DECL);
type = gfc_get_function_type (sym);
- fndecl = build_decl (FUNCTION_DECL, gfc_sym_identifier (sym), type);
+ fndecl = build_decl (input_location,
+ FUNCTION_DECL, gfc_sym_identifier (sym), type);
/* Perform name mangling if this is a top level or module procedure. */
if (current_function_decl == NULL_TREE)
@@ -1505,7 +1514,8 @@ build_function_decl (gfc_symbol * sym)
type = void_type_node;
}
- result_decl = build_decl (RESULT_DECL, result_decl, type);
+ result_decl = build_decl (input_location,
+ RESULT_DECL, result_decl, type);
DECL_ARTIFICIAL (result_decl) = 1;
DECL_IGNORED_P (result_decl) = 1;
DECL_CONTEXT (result_decl) = fndecl;
@@ -1578,7 +1588,8 @@ create_function_arglist (gfc_symbol * sym)
if (sym->attr.entry_master)
{
type = TREE_VALUE (typelist);
- parm = build_decl (PARM_DECL, get_identifier ("__entry"), type);
+ parm = build_decl (input_location,
+ PARM_DECL, get_identifier ("__entry"), type);
DECL_CONTEXT (parm) = fndecl;
DECL_ARG_TYPE (parm) = type;
@@ -1600,7 +1611,8 @@ create_function_arglist (gfc_symbol * sym)
tree len_type = TREE_VALUE (TREE_CHAIN (typelist));
gcc_assert (len_type == gfc_charlen_type_node);
- length = build_decl (PARM_DECL,
+ length = build_decl (input_location,
+ PARM_DECL,
get_identifier (".__result"),
len_type);
if (!sym->ts.cl->length)
@@ -1622,7 +1634,8 @@ create_function_arglist (gfc_symbol * sym)
if (sym->ts.cl->backend_decl == NULL)
{
- tree len = build_decl (VAR_DECL,
+ tree len = build_decl (input_location,
+ VAR_DECL,
get_identifier ("..__result"),
gfc_charlen_type_node);
DECL_ARTIFICIAL (len) = 1;
@@ -1642,7 +1655,8 @@ create_function_arglist (gfc_symbol * sym)
}
}
- parm = build_decl (PARM_DECL, get_identifier ("__result"), type);
+ parm = build_decl (input_location,
+ PARM_DECL, get_identifier ("__result"), type);
DECL_CONTEXT (parm) = fndecl;
DECL_ARG_TYPE (parm) = TREE_VALUE (typelist);
@@ -1684,7 +1698,8 @@ create_function_arglist (gfc_symbol * sym)
strcpy (&name[1], f->sym->name);
name[0] = '_';
- length = build_decl (PARM_DECL, get_identifier (name), len_type);
+ length = build_decl (input_location,
+ PARM_DECL, get_identifier (name), len_type);
hidden_arglist = chainon (hidden_arglist, length);
DECL_CONTEXT (length) = fndecl;
@@ -1739,7 +1754,8 @@ create_function_arglist (gfc_symbol * sym)
type = build_pointer_type (type);
/* Build the argument declaration. */
- parm = build_decl (PARM_DECL, gfc_sym_identifier (f->sym), type);
+ parm = build_decl (input_location,
+ PARM_DECL, gfc_sym_identifier (f->sym), type);
/* Fill in arg stuff. */
DECL_CONTEXT (parm) = fndecl;
@@ -1929,7 +1945,8 @@ build_entry_thunks (gfc_namespace * ns)
tree union_decl, field;
tree master_type = TREE_TYPE (ns->proc_name->backend_decl);
- union_decl = build_decl (VAR_DECL, get_identifier ("__result"),
+ union_decl = build_decl (input_location,
+ VAR_DECL, get_identifier ("__result"),
TREE_TYPE (master_type));
DECL_ARTIFICIAL (union_decl) = 1;
DECL_EXTERNAL (union_decl) = 0;
@@ -2144,10 +2161,12 @@ gfc_get_fake_result_decl (gfc_symbol * sym, int parent_flag)
IDENTIFIER_POINTER (DECL_NAME (this_function_decl)));
if (!sym->attr.mixed_entry_master && sym->attr.function)
- decl = build_decl (VAR_DECL, get_identifier (name),
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (name),
gfc_sym_type (sym));
else
- decl = build_decl (VAR_DECL, get_identifier (name),
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (name),
TREE_TYPE (TREE_TYPE (this_function_decl)));
DECL_ARTIFICIAL (decl) = 1;
DECL_EXTERNAL (decl) = 0;
@@ -2207,7 +2226,8 @@ gfc_build_library_function_decl (tree name, tree rettype, int nargs, ...)
/* Build the function type and decl. */
fntype = build_function_type (rettype, arglist);
- fndecl = build_decl (FUNCTION_DECL, name, fntype);
+ fndecl = build_decl (input_location,
+ FUNCTION_DECL, name, fntype);
/* Mark this decl as external. */
DECL_EXTERNAL (fndecl) = 1;
@@ -2888,7 +2908,7 @@ gfc_init_default_dt (gfc_symbol * sym, tree body)
{
present = gfc_conv_expr_present (sym);
tmp = build3 (COND_EXPR, TREE_TYPE (tmp), present,
- tmp, build_empty_stmt ());
+ tmp, build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&fnblock, tmp);
gfc_free_expr (e);
@@ -2923,7 +2943,7 @@ init_intent_out_dt (gfc_symbol * proc_sym, tree body)
present = gfc_conv_expr_present (f->sym);
tmp = build3 (COND_EXPR, TREE_TYPE (tmp), present,
- tmp, build_empty_stmt ());
+ tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&fnblock, tmp);
}
@@ -3311,7 +3331,8 @@ gfc_trans_use_stmts (gfc_namespace * ns)
if (entry->namespace_decl == NULL)
{
entry->namespace_decl
- = build_decl (NAMESPACE_DECL,
+ = build_decl (input_location,
+ NAMESPACE_DECL,
get_identifier (use_stmt->module_name),
void_type_node);
DECL_EXTERNAL (entry->namespace_decl) = 1;
@@ -3488,7 +3509,8 @@ gfc_emit_parameter_debug_info (gfc_symbol *sym)
return;
/* Create the decl for the variable or constant. */
- decl = build_decl (sym->attr.flavor == FL_PARAMETER ? CONST_DECL : VAR_DECL,
+ decl = build_decl (input_location,
+ sym->attr.flavor == FL_PARAMETER ? CONST_DECL : VAR_DECL,
gfc_sym_identifier (sym), gfc_sym_type (sym));
if (sym->attr.flavor == FL_PARAMETER)
TREE_READONLY (decl) = 1;
@@ -3875,7 +3897,8 @@ create_main_function (tree fndecl)
build_pointer_type (pchar_type_node),
NULL_TREE);
main_identifier_node = get_identifier ("main");
- ftn_main = build_decl (FUNCTION_DECL, main_identifier_node, tmp);
+ ftn_main = build_decl (input_location, FUNCTION_DECL,
+ main_identifier_node, tmp);
DECL_EXTERNAL (ftn_main) = 0;
TREE_PUBLIC (ftn_main) = 1;
TREE_STATIC (ftn_main) = 1;
@@ -3883,7 +3906,8 @@ create_main_function (tree fndecl)
= tree_cons (get_identifier("externally_visible"), NULL_TREE, NULL_TREE);
/* Setup the result declaration (for "return 0"). */
- result_decl = build_decl (RESULT_DECL, NULL_TREE, integer_type_node);
+ result_decl = build_decl (input_location,
+ RESULT_DECL, NULL_TREE, integer_type_node);
DECL_ARTIFICIAL (result_decl) = 1;
DECL_IGNORED_P (result_decl) = 1;
DECL_CONTEXT (result_decl) = ftn_main;
@@ -3897,7 +3921,7 @@ create_main_function (tree fndecl)
typelist = TYPE_ARG_TYPES (TREE_TYPE (ftn_main));
tmp = TREE_VALUE (typelist);
- argc = build_decl (PARM_DECL, get_identifier ("argc"), tmp);
+ argc = build_decl (input_location, PARM_DECL, get_identifier ("argc"), tmp);
DECL_CONTEXT (argc) = ftn_main;
DECL_ARG_TYPE (argc) = TREE_VALUE (typelist);
TREE_READONLY (argc) = 1;
@@ -3906,7 +3930,7 @@ create_main_function (tree fndecl)
typelist = TREE_CHAIN (typelist);
tmp = TREE_VALUE (typelist);
- argv = build_decl (PARM_DECL, get_identifier ("argv"), tmp);
+ argv = build_decl (input_location, PARM_DECL, get_identifier ("argv"), tmp);
DECL_CONTEXT (argv) = ftn_main;
DECL_ARG_TYPE (argv) = TREE_VALUE (typelist);
TREE_READONLY (argv) = 1;
@@ -4354,10 +4378,12 @@ gfc_generate_constructors (void)
type = build_function_type (void_type_node,
gfc_chainon_list (NULL_TREE, void_type_node));
- fndecl = build_decl (FUNCTION_DECL, fnname, type);
+ fndecl = build_decl (input_location,
+ FUNCTION_DECL, fnname, type);
TREE_PUBLIC (fndecl) = 1;
- decl = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
+ decl = build_decl (input_location,
+ RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
DECL_CONTEXT (decl) = fndecl;
@@ -4378,7 +4404,7 @@ gfc_generate_constructors (void)
for (; gfc_static_ctors; gfc_static_ctors = TREE_CHAIN (gfc_static_ctors))
{
tmp = build_call_expr (TREE_VALUE (gfc_static_ctors), 0);
- DECL_SAVED_TREE (fndecl) = build_stmt (EXPR_STMT, tmp);
+ DECL_SAVED_TREE (fndecl) = build_stmt (input_location, EXPR_STMT, tmp);
}
decl = getdecls ();
@@ -4426,7 +4452,8 @@ gfc_generate_block_data (gfc_namespace * ns)
else
id = get_identifier ("__BLOCK_DATA__");
- decl = build_decl (VAR_DECL, id, gfc_array_index_type);
+ decl = build_decl (input_location,
+ VAR_DECL, id, gfc_array_index_type);
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
DECL_IGNORED_P (decl) = 1;
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 29cbff3ed1d..a4d00df7fa7 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -3052,7 +3052,8 @@ fill_with_spaces (tree start, tree type, tree size)
cond = fold_build2 (LE_EXPR, boolean_type_node, i,
fold_convert (sizetype, integer_zero_node));
tmp = build1_v (GOTO_EXPR, exit_label);
- tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp, build_empty_stmt ());
+ tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&loop, tmp);
/* Assignment. */
@@ -3205,7 +3206,8 @@ gfc_trans_string_copy (stmtblock_t * block, tree dlength, tree dest,
/* The whole copy_string function is there. */
tmp = fold_build3 (COND_EXPR, void_type_node, cond2, tmp2, tmp3);
- tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp, build_empty_stmt ());
+ tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
}
@@ -3999,7 +4001,8 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr)
{
tree tmp = se->expr;
STRIP_TYPE_NOPS (tmp);
- var = build_decl (CONST_DECL, NULL, TREE_TYPE (tmp));
+ var = build_decl (input_location,
+ CONST_DECL, NULL, TREE_TYPE (tmp));
DECL_INITIAL (var) = tmp;
TREE_STATIC (var) = 1;
pushdecl (var);
@@ -4246,7 +4249,8 @@ gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rse, gfc_typespec ts,
tmp = gfc_evaluate_now (lse->expr, &lse->pre);
tmp = gfc_deallocate_alloc_comp (ts.derived, tmp, 0);
if (r_is_var)
- tmp = build3_v (COND_EXPR, cond, build_empty_stmt (), tmp);
+ tmp = build3_v (COND_EXPR, cond, build_empty_stmt (input_location),
+ tmp);
gfc_add_expr_to_block (&lse->post, tmp);
}
@@ -4261,7 +4265,8 @@ gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rse, gfc_typespec ts,
if (r_is_var)
{
tmp = gfc_copy_alloc_comp (ts.derived, rse->expr, lse->expr, 0);
- tmp = build3_v (COND_EXPR, cond, build_empty_stmt (), tmp);
+ tmp = build3_v (COND_EXPR, cond, build_empty_stmt (input_location),
+ tmp);
gfc_add_expr_to_block (&block, tmp);
}
}
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index f448893724d..21694e41b36 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -693,7 +693,8 @@ gfc_get_intrinsic_lib_fndecl (gfc_intrinsic_map_t * m, gfc_expr * expr)
}
argtypes = gfc_chainon_list (argtypes, void_type_node);
type = build_function_type (gfc_typenode_for_spec (ts), argtypes);
- fndecl = build_decl (FUNCTION_DECL, get_identifier (name), type);
+ fndecl = build_decl (input_location,
+ FUNCTION_DECL, get_identifier (name), type);
/* Mark the decl as external. */
DECL_EXTERNAL (fndecl) = 1;
@@ -1388,7 +1389,7 @@ gfc_conv_intrinsic_ctime (gfc_se * se, gfc_expr * expr)
cond = fold_build2 (GT_EXPR, boolean_type_node,
len, build_int_cst (TREE_TYPE (len), 0));
tmp = gfc_call_free (var);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->post, tmp);
se->expr = var;
@@ -1426,7 +1427,7 @@ gfc_conv_intrinsic_fdate (gfc_se * se, gfc_expr * expr)
cond = fold_build2 (GT_EXPR, boolean_type_node,
len, build_int_cst (TREE_TYPE (len), 0));
tmp = gfc_call_free (var);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->post, tmp);
se->expr = var;
@@ -1466,7 +1467,7 @@ gfc_conv_intrinsic_ttynam (gfc_se * se, gfc_expr * expr)
cond = fold_build2 (GT_EXPR, boolean_type_node,
len, build_int_cst (TREE_TYPE (len), 0));
tmp = gfc_call_free (var);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->post, tmp);
se->expr = var;
@@ -1551,10 +1552,12 @@ gfc_conv_intrinsic_minmax (gfc_se * se, gfc_expr * expr, enum tree_code op)
tmp = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, tmp,
fold_convert (boolean_type_node, isnan));
}
- tmp = build3_v (COND_EXPR, tmp, thencase, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, thencase,
+ build_empty_stmt (input_location));
if (cond != NULL_TREE)
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->pre, tmp);
argexpr = argexpr->next;
@@ -1601,7 +1604,7 @@ gfc_conv_intrinsic_minmax_char (gfc_se * se, gfc_expr * expr, int op)
cond = fold_build2 (GT_EXPR, boolean_type_node,
len, build_int_cst (TREE_TYPE (len), 0));
tmp = gfc_call_free (var);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->post, tmp);
se->expr = var;
@@ -1798,7 +1801,7 @@ gfc_conv_intrinsic_anyall (gfc_se * se, gfc_expr * expr, enum tree_code op)
gfc_add_block_to_block (&body, &arrayse.pre);
tmp = fold_build2 (op, boolean_type_node, arrayse.expr,
build_int_cst (TREE_TYPE (arrayse.expr), 0));
- tmp = build3_v (COND_EXPR, tmp, found, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, found, build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
gfc_add_block_to_block (&body, &arrayse.post);
@@ -1865,7 +1868,8 @@ gfc_conv_intrinsic_count (gfc_se * se, gfc_expr * expr)
gfc_copy_loopinfo_to_se (&arrayse, &loop);
arrayse.ss = arrayss;
gfc_conv_expr_val (&arrayse, actual->expr);
- tmp = build3_v (COND_EXPR, arrayse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, arrayse.expr, tmp,
+ build_empty_stmt (input_location));
gfc_add_block_to_block (&body, &arrayse.pre);
gfc_add_expr_to_block (&body, tmp);
@@ -1977,7 +1981,8 @@ gfc_conv_intrinsic_arith (gfc_se * se, gfc_expr * expr, enum tree_code op)
/* We enclose the above in if (mask) {...} . */
tmp = gfc_finish_block (&block);
- tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskse.expr, tmp,
+ build_empty_stmt (input_location));
}
else
tmp = gfc_finish_block (&block);
@@ -1995,7 +2000,8 @@ gfc_conv_intrinsic_arith (gfc_se * se, gfc_expr * expr, enum tree_code op)
gfc_add_block_to_block (&block, &loop.post);
tmp = gfc_finish_block (&block);
- tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskse.expr, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&se->pre, &block);
}
@@ -2266,7 +2272,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op)
tmp = fold_build2 (TRUTH_OR_EXPR, boolean_type_node,
fold_build2 (op, boolean_type_node,
arrayse.expr, limit), tmp);
- tmp = build3_v (COND_EXPR, tmp, ifbody, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, ifbody, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
if (maskss)
@@ -2274,7 +2280,8 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op)
/* We enclose the above in if (mask) {...}. */
tmp = gfc_finish_block (&block);
- tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskse.expr, tmp,
+ build_empty_stmt (input_location));
}
else
tmp = gfc_finish_block (&block);
@@ -2428,14 +2435,15 @@ gfc_conv_intrinsic_minmaxval (gfc_se * se, gfc_expr * expr, enum tree_code op)
/* If it is a more extreme value. */
tmp = fold_build2 (op, boolean_type_node, arrayse.expr, limit);
- tmp = build3_v (COND_EXPR, tmp, ifbody, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, ifbody, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &arrayse.post);
tmp = gfc_finish_block (&block);
if (maskss)
/* We enclose the above in if (mask) {...}. */
- tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskse.expr, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
gfc_trans_scalarizing_loops (&loop, &body);
@@ -2450,7 +2458,8 @@ gfc_conv_intrinsic_minmaxval (gfc_se * se, gfc_expr * expr, enum tree_code op)
gfc_add_block_to_block (&block, &loop.post);
tmp = gfc_finish_block (&block);
- tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskse.expr, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&se->pre, &block);
}
@@ -3320,7 +3329,7 @@ gfc_conv_intrinsic_rrspacing (gfc_se * se, gfc_expr * expr)
cond = fold_build2 (NE_EXPR, boolean_type_node, x,
build_real_from_int_cst (type, integer_zero_node));
- tmp = build3_v (COND_EXPR, cond, stmt, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, stmt, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->pre, tmp);
se->expr = fold_convert (type, x);
@@ -3730,7 +3739,8 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr)
gfc_init_block (&block);
tmp = gfc_conv_array_data (argse.expr);
tmp = fold_build2 (NE_EXPR, boolean_type_node, source, tmp);
- tmp = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, stmt,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &se->post);
gfc_init_block (&se->post);
@@ -4221,7 +4231,7 @@ gfc_conv_intrinsic_trim (gfc_se * se, gfc_expr * expr)
cond = fold_build2 (GT_EXPR, boolean_type_node,
len, build_int_cst (TREE_TYPE (len), 0));
tmp = gfc_call_free (var);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->post, tmp);
se->expr = var;
@@ -4312,7 +4322,7 @@ gfc_conv_intrinsic_repeat (gfc_se * se, gfc_expr * expr)
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp,
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
/* Call memmove (dest + (i*slen*size), src, slen*size). */
diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c
index bdd70f58740..f8b943d7c0b 100644
--- a/gcc/fortran/trans-io.c
+++ b/gcc/fortran/trans-io.c
@@ -264,7 +264,7 @@ gfc_trans_io_runtime_check (tree cond, tree var, int error_code,
cond = build_call_expr (built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp);
cond = fold_convert (boolean_type_node, cond);
- tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt (input_location));
gfc_add_expr_to_block (pblock, tmp);
}
}
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 442290f36cb..a476487a0a2 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -436,7 +436,7 @@ gfc_trans_omp_variable_list (enum omp_clause_code code, gfc_namelist *namelist,
tree t = gfc_trans_omp_variable (namelist->sym);
if (t != error_mark_node)
{
- tree node = build_omp_clause (code);
+ tree node = build_omp_clause (input_location, code);
OMP_CLAUSE_DECL (node) = t;
list = gfc_trans_add_clause (node, list);
}
@@ -682,7 +682,8 @@ gfc_trans_omp_reduction_list (gfc_namelist *namelist, tree list,
tree t = gfc_trans_omp_variable (namelist->sym);
if (t != error_mark_node)
{
- tree node = build_omp_clause (OMP_CLAUSE_REDUCTION);
+ tree node = build_omp_clause (where.lb->location,
+ OMP_CLAUSE_REDUCTION);
OMP_CLAUSE_DECL (node) = t;
OMP_CLAUSE_REDUCTION_CODE (node) = reduction_code;
if (namelist->sym->attr.dimension)
@@ -801,7 +802,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
if_var = gfc_evaluate_now (se.expr, block);
gfc_add_block_to_block (block, &se.post);
- c = build_omp_clause (OMP_CLAUSE_IF);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_IF);
OMP_CLAUSE_IF_EXPR (c) = if_var;
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
@@ -816,7 +817,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
num_threads = gfc_evaluate_now (se.expr, block);
gfc_add_block_to_block (block, &se.post);
- c = build_omp_clause (OMP_CLAUSE_NUM_THREADS);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_NUM_THREADS);
OMP_CLAUSE_NUM_THREADS_EXPR (c) = num_threads;
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
@@ -833,7 +834,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
if (clauses->sched_kind != OMP_SCHED_NONE)
{
- c = build_omp_clause (OMP_CLAUSE_SCHEDULE);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_SCHEDULE);
OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = chunk_size;
switch (clauses->sched_kind)
{
@@ -860,7 +861,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
if (clauses->default_sharing != OMP_DEFAULT_UNKNOWN)
{
- c = build_omp_clause (OMP_CLAUSE_DEFAULT);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_DEFAULT);
switch (clauses->default_sharing)
{
case OMP_DEFAULT_NONE:
@@ -883,25 +884,25 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
if (clauses->nowait)
{
- c = build_omp_clause (OMP_CLAUSE_NOWAIT);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_NOWAIT);
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
if (clauses->ordered)
{
- c = build_omp_clause (OMP_CLAUSE_ORDERED);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_ORDERED);
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
if (clauses->untied)
{
- c = build_omp_clause (OMP_CLAUSE_UNTIED);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_UNTIED);
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
if (clauses->collapse)
{
- c = build_omp_clause (OMP_CLAUSE_COLLAPSE);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_COLLAPSE);
OMP_CLAUSE_COLLAPSE_EXPR (c) = build_int_cst (NULL, clauses->collapse);
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
@@ -1244,7 +1245,7 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock,
if (!dovar_found)
{
- tmp = build_omp_clause (OMP_CLAUSE_PRIVATE);
+ tmp = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_DECL (tmp) = dovar;
omp_clauses = gfc_trans_add_clause (tmp, omp_clauses);
}
@@ -1277,7 +1278,8 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock,
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE
&& OMP_CLAUSE_DECL (c) == dovar)
{
- tree l = build_omp_clause (OMP_CLAUSE_LASTPRIVATE);
+ tree l = build_omp_clause (input_location,
+ OMP_CLAUSE_LASTPRIVATE);
OMP_CLAUSE_DECL (l) = dovar;
OMP_CLAUSE_CHAIN (l) = omp_clauses;
OMP_CLAUSE_LASTPRIVATE_STMT (l) = tmp;
@@ -1290,7 +1292,7 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock,
}
if (!simple)
{
- tmp = build_omp_clause (OMP_CLAUSE_PRIVATE);
+ tmp = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_DECL (tmp) = count;
omp_clauses = gfc_trans_add_clause (tmp, omp_clauses);
}
@@ -1558,7 +1560,7 @@ gfc_trans_omp_workshare (gfc_code *code, gfc_omp_clauses *clauses)
pushlevel (0);
if (!code)
- return build_empty_stmt ();
+ return build_empty_stmt (input_location);
gfc_start_block (&block);
pblock = &block;
@@ -1681,7 +1683,8 @@ gfc_trans_omp_workshare (gfc_code *code, gfc_omp_clauses *clauses)
tmp = gfc_finish_block (&singleblock);
tmp = build2 (OMP_SINGLE, void_type_node, tmp,
clauses->nowait
- ? build_omp_clause (OMP_CLAUSE_NOWAIT) : NULL_TREE);
+ ? build_omp_clause (input_location, OMP_CLAUSE_NOWAIT)
+ : NULL_TREE);
gfc_add_expr_to_block (pblock, tmp);
}
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 596e95ceb22..0e8ce67c443 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -175,7 +175,7 @@ gfc_trans_goto (gfc_code * code)
tmp = fold_build2 (EQ_EXPR, boolean_type_node, tmp, assigned_goto);
tmp = build3_v (COND_EXPR, tmp,
fold_build1 (GOTO_EXPR, void_type_node, target),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&se.pre, tmp);
code = code->block;
}
@@ -453,7 +453,7 @@ gfc_trans_call (gfc_code * code, bool dependency_check,
if (mask && count1)
{
tmp = build3_v (COND_EXPR, maskexpr, loopse.expr,
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&loopse.pre, tmp);
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
count1, gfc_index_one_node);
@@ -655,7 +655,7 @@ gfc_trans_if_1 (gfc_code * code)
if (code->block)
elsestmt = gfc_trans_if_1 (code->block);
else
- elsestmt = build_empty_stmt ();
+ elsestmt = build_empty_stmt (input_location);
/* Build the condition expression and add it to the condition block. */
stmt = fold_build3 (COND_EXPR, void_type_node, if_se.expr, stmt, elsestmt);
@@ -849,7 +849,7 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar,
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
tmp = fold_build3 (COND_EXPR, void_type_node,
- cond, tmp, build_empty_stmt ());
+ cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
/* Finish the loop body. */
@@ -862,7 +862,7 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar,
else
cond = fold_build2 (GE_EXPR, boolean_type_node, dovar, to);
tmp = fold_build3 (COND_EXPR, void_type_node,
- cond, tmp, build_empty_stmt ());
+ cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (pblock, tmp);
/* Add the exit label. */
@@ -1007,7 +1007,7 @@ gfc_trans_do (gfc_code * code)
tmp = fold_build2 (LT_EXPR, boolean_type_node, to, from);
pos = fold_build3 (COND_EXPR, void_type_node, tmp,
build1_v (GOTO_EXPR, exit_label),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
tmp = fold_build2 (MINUS_EXPR, type, to, from);
tmp = fold_convert (utype, tmp);
tmp = fold_build2 (TRUNC_DIV_EXPR, utype, tmp,
@@ -1018,7 +1018,7 @@ gfc_trans_do (gfc_code * code)
tmp = fold_build2 (GT_EXPR, boolean_type_node, to, from);
neg = fold_build3 (COND_EXPR, void_type_node, tmp,
build1_v (GOTO_EXPR, exit_label),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
tmp = fold_build2 (MINUS_EXPR, type, from, to);
tmp = fold_convert (utype, tmp);
tmp = fold_build2 (TRUNC_DIV_EXPR, utype, tmp,
@@ -1049,7 +1049,7 @@ gfc_trans_do (gfc_code * code)
/* If the loop is empty, go directly to the exit label. */
tmp = fold_build3 (COND_EXPR, void_type_node, tmp,
build1_v (GOTO_EXPR, exit_label),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
}
@@ -1094,7 +1094,7 @@ gfc_trans_do (gfc_code * code)
build_int_cst (utype, 0));
tmp = build1_v (GOTO_EXPR, exit_label);
tmp = fold_build3 (COND_EXPR, void_type_node,
- cond, tmp, build_empty_stmt ());
+ cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
/* Decrement the loop count. */
@@ -1168,7 +1168,7 @@ gfc_trans_do_while (gfc_code * code)
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
tmp = fold_build3 (COND_EXPR, void_type_node,
- cond.expr, tmp, build_empty_stmt ());
+ cond.expr, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
/* The main body of the loop. */
@@ -1413,8 +1413,8 @@ gfc_trans_logical_select (gfc_code * code)
{
tree true_tree, false_tree, stmt;
- true_tree = build_empty_stmt ();
- false_tree = build_empty_stmt ();
+ true_tree = build_empty_stmt (input_location);
+ false_tree = build_empty_stmt (input_location);
/* If we have a case for .TRUE. and for .FALSE., discard the default case.
Otherwise, if .TRUE. or .FALSE. is missing and there is a default case,
@@ -1653,7 +1653,7 @@ gfc_trans_select (gfc_code * code)
/* Empty SELECT constructs are legal. */
if (code->block == NULL)
- return build_empty_stmt ();
+ return build_empty_stmt (input_location);
/* Select the correct translation function. */
switch (code->expr1->ts.type)
@@ -1928,7 +1928,7 @@ gfc_trans_forall_loop (forall_info *forall_tmp, tree body,
count, build_int_cst (TREE_TYPE (count), 0));
tmp = build1_v (GOTO_EXPR, exit_label);
tmp = fold_build3 (COND_EXPR, void_type_node,
- cond, tmp, build_empty_stmt ());
+ cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
/* The main loop body. */
@@ -2010,7 +2010,8 @@ gfc_trans_nested_forall_loop (forall_info * nested_forall_info, tree body,
if (mask)
{
tmp = gfc_build_array_ref (mask, maskindex, NULL);
- body = build3_v (COND_EXPR, tmp, body, build_empty_stmt ());
+ body = build3_v (COND_EXPR, tmp, body,
+ build_empty_stmt (input_location));
}
}
body = gfc_trans_forall_loop (forall_tmp, body, mask_flag, &header);
@@ -2146,7 +2147,8 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree count3,
TREE_TYPE (wheremaskexpr),
wheremaskexpr);
tmp = fold_build3 (COND_EXPR, void_type_node,
- wheremaskexpr, tmp, build_empty_stmt ());
+ wheremaskexpr, tmp,
+ build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&body, tmp);
@@ -2243,7 +2245,7 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree count3,
TREE_TYPE (wheremaskexpr),
wheremaskexpr);
tmp = fold_build3 (COND_EXPR, void_type_node,
- wheremaskexpr, tmp, build_empty_stmt ());
+ wheremaskexpr, tmp, build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&body1, tmp);
@@ -2815,7 +2817,7 @@ gfc_trans_forall_1 (gfc_code * code, forall_info * nested_forall_info)
if (code->expr1
&& code->expr1->expr_type == EXPR_CONSTANT
&& !code->expr1->value.logical)
- return build_empty_stmt ();
+ return build_empty_stmt (input_location);
n = 0;
/* Count the FORALL index number. */
@@ -3372,7 +3374,7 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2,
tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts,
loop.temp_ss != NULL, false);
- tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
@@ -3425,7 +3427,8 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2,
/* Use the scalar assignment as is. */
tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts, false, false);
- tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskexpr, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
/* Increment count2. */
@@ -3832,7 +3835,7 @@ gfc_trans_where_3 (gfc_code * cblock, gfc_code * eblock)
tstmt = gfc_trans_scalar_assign (&tdse, &tsse, tdst->ts, false, false);
estmt = eblock ? gfc_trans_scalar_assign (&edse, &esse, edst->ts, false, false)
- : build_empty_stmt ();
+ : build_empty_stmt (input_location);
tmp = build3_v (COND_EXPR, cexpr, tstmt, estmt);
gfc_add_expr_to_block (&body, tmp);
gfc_add_block_to_block (&body, &cse.post);
@@ -4011,7 +4014,7 @@ gfc_trans_allocate (gfc_code * code)
parm = fold_build2 (NE_EXPR, boolean_type_node,
stat, build_int_cst (TREE_TYPE (stat), 0));
tmp = fold_build3 (COND_EXPR, void_type_node,
- parm, tmp, build_empty_stmt ());
+ parm, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se.pre, tmp);
}
@@ -4066,7 +4069,7 @@ gfc_trans_allocate (gfc_code * code)
tmp = fold_build2 (NE_EXPR, boolean_type_node, stat,
build_int_cst (TREE_TYPE (stat), 0));
- tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
}
@@ -4200,7 +4203,7 @@ gfc_trans_deallocate (gfc_code *code)
tmp = fold_build2 (NE_EXPR, boolean_type_node, astat,
build_int_cst (TREE_TYPE (astat), 0));
- tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
}
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 0b4be585507..1785908f811 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -803,7 +803,8 @@ gfc_init_types (void)
/* Create and name the types. */
#define PUSH_TYPE(name, node) \
- pushdecl (build_decl (TYPE_DECL, get_identifier (name), node))
+ pushdecl (build_decl (input_location, \
+ TYPE_DECL, get_identifier (name), node))
for (index = 0; gfc_integer_kinds[index].kind != 0; ++index)
{
@@ -1241,19 +1242,22 @@ gfc_get_desc_dim_type (void)
TYPE_PACKED (type) = 1;
/* Consists of the stride, lbound and ubound members. */
- decl = build_decl (FIELD_DECL,
+ decl = build_decl (input_location,
+ FIELD_DECL,
get_identifier ("stride"), gfc_array_index_type);
DECL_CONTEXT (decl) = type;
TREE_NO_WARNING (decl) = 1;
fieldlist = decl;
- decl = build_decl (FIELD_DECL,
+ decl = build_decl (input_location,
+ FIELD_DECL,
get_identifier ("lbound"), gfc_array_index_type);
DECL_CONTEXT (decl) = type;
TREE_NO_WARNING (decl) = 1;
fieldlist = chainon (fieldlist, decl);
- decl = build_decl (FIELD_DECL,
+ decl = build_decl (input_location,
+ FIELD_DECL,
get_identifier ("ubound"), gfc_array_index_type);
DECL_CONTEXT (decl) = type;
TREE_NO_WARNING (decl) = 1;
@@ -1505,7 +1509,8 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed)
GFC_TYPE_ARRAY_UBOUND (type, n));
gtype = build_array_type (gtype, rtype);
}
- TYPE_NAME (type) = type_decl = build_decl (TYPE_DECL, NULL, gtype);
+ TYPE_NAME (type) = type_decl = build_decl (input_location,
+ TYPE_DECL, NULL, gtype);
DECL_ORIGINAL_TYPE (type_decl) = gtype;
}
@@ -1539,20 +1544,23 @@ gfc_get_array_descriptor_base (int dimen)
TYPE_NAME (fat_type) = get_identifier (name);
/* Add the data member as the first element of the descriptor. */
- decl = build_decl (FIELD_DECL, get_identifier ("data"), ptr_type_node);
+ decl = build_decl (input_location,
+ FIELD_DECL, get_identifier ("data"), ptr_type_node);
DECL_CONTEXT (decl) = fat_type;
fieldlist = decl;
/* Add the base component. */
- decl = build_decl (FIELD_DECL, get_identifier ("offset"),
+ decl = build_decl (input_location,
+ FIELD_DECL, get_identifier ("offset"),
gfc_array_index_type);
DECL_CONTEXT (decl) = fat_type;
TREE_NO_WARNING (decl) = 1;
fieldlist = chainon (fieldlist, decl);
/* Add the dtype component. */
- decl = build_decl (FIELD_DECL, get_identifier ("dtype"),
+ decl = build_decl (input_location,
+ FIELD_DECL, get_identifier ("dtype"),
gfc_array_index_type);
DECL_CONTEXT (decl) = fat_type;
TREE_NO_WARNING (decl) = 1;
@@ -1565,7 +1573,8 @@ gfc_get_array_descriptor_base (int dimen)
gfc_index_zero_node,
gfc_rank_cst[dimen - 1]));
- decl = build_decl (FIELD_DECL, get_identifier ("dim"), arraytype);
+ decl = build_decl (input_location,
+ FIELD_DECL, get_identifier ("dim"), arraytype);
DECL_CONTEXT (decl) = fat_type;
TREE_NO_WARNING (decl) = 1;
fieldlist = chainon (fieldlist, decl);
@@ -1803,7 +1812,8 @@ gfc_finish_type (tree type)
{
tree decl;
- decl = build_decl (TYPE_DECL, NULL_TREE, type);
+ decl = build_decl (input_location,
+ TYPE_DECL, NULL_TREE, type);
TYPE_STUB_DECL (type) = decl;
layout_type (type);
rest_of_type_compilation (type, 1);
@@ -1822,7 +1832,8 @@ gfc_add_field_to_struct (tree *fieldlist, tree context,
{
tree decl;
- decl = build_decl (FIELD_DECL, name, type);
+ decl = build_decl (input_location,
+ FIELD_DECL, name, type);
DECL_CONTEXT (decl) = context;
DECL_INITIAL (decl) = 0;
@@ -2124,7 +2135,8 @@ gfc_get_mixed_entry_union (gfc_namespace *ns)
if (el == el2)
{
- decl = build_decl (FIELD_DECL,
+ decl = build_decl (input_location,
+ FIELD_DECL,
get_identifier (el->sym->result->name),
gfc_sym_type (el->sym->result));
DECL_CONTEXT (decl) = type;
@@ -2411,7 +2423,7 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info)
base_decl = GFC_TYPE_ARRAY_BASE_DECL (type, indirect);
if (!base_decl)
{
- base_decl = build_decl (VAR_DECL, NULL_TREE,
+ base_decl = build_decl (input_location, VAR_DECL, NULL_TREE,
indirect ? build_pointer_type (ptype) : ptype);
GFC_TYPE_ARRAY_BASE_DECL (type, indirect) = base_decl;
}
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index c842ea8dcb0..319ae69edcc 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -238,7 +238,7 @@ gfc_finish_block (stmtblock_t * stmtblock)
expr = stmtblock->head;
if (!expr)
- expr = build_empty_stmt ();
+ expr = build_empty_stmt (input_location);
stmtblock->head = NULL_TREE;
@@ -485,7 +485,7 @@ gfc_trans_runtime_check (bool error, bool once, tree cond, stmtblock_t * pblock,
cond = build_call_expr (built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp);
cond = fold_convert (boolean_type_node, cond);
- tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt (input_location));
gfc_add_expr_to_block (pblock, tmp);
}
}
@@ -516,7 +516,7 @@ gfc_call_malloc (stmtblock_t * block, tree type, tree size)
("Attempt to allocate a negative amount of memory."));
tmp = fold_build3 (COND_EXPR, void_type_node, negative,
build_call_expr (gfor_fndecl_runtime_error, 1, msg),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
/* Call malloc and check the result. */
@@ -534,7 +534,7 @@ gfc_call_malloc (stmtblock_t * block, tree type, tree size)
("Memory allocation failed"));
tmp = fold_build3 (COND_EXPR, void_type_node, null_result,
build_call_expr (gfor_fndecl_os_error, 1, msg),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block2, tmp);
malloc_result = gfc_finish_block (&block2);
@@ -607,7 +607,7 @@ gfc_allocate_with_status (stmtblock_t * block, tree size, tree status)
tmp = fold_build3 (COND_EXPR, void_type_node,
fold_build2 (NE_EXPR, boolean_type_node, status,
build_int_cst (TREE_TYPE (status), 0)),
- tmp, build_empty_stmt ());
+ tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
}
@@ -664,7 +664,7 @@ gfc_allocate_with_status (stmtblock_t * block, tree size, tree status)
tmp = fold_build3 (COND_EXPR, void_type_node,
fold_build2 (EQ_EXPR, boolean_type_node, res,
build_int_cst (pvoid_type_node, 0)),
- tmp, build_empty_stmt ());
+ tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&alloc_block, tmp);
cond = fold_build2 (LT_EXPR, boolean_type_node, size,
@@ -790,7 +790,7 @@ gfc_call_free (tree var)
build_int_cst (pvoid_type_node, 0));
call = build_call_expr (built_in_decls[BUILT_IN_FREE], 1, var);
tmp = fold_build3 (COND_EXPR, void_type_node, cond, call,
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
return gfc_finish_block (&block);
@@ -854,7 +854,7 @@ gfc_deallocate_with_status (tree pointer, tree status, bool can_fail,
varname);
}
else
- error = build_empty_stmt ();
+ error = build_empty_stmt (input_location);
if (status != NULL_TREE && !integer_zerop (status))
{
@@ -889,7 +889,7 @@ gfc_deallocate_with_status (tree pointer, tree status, bool can_fail,
fold_build1 (INDIRECT_REF, status_type, status),
build_int_cst (status_type, 0));
tmp = fold_build3 (COND_EXPR, void_type_node, cond2, tmp,
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&non_null, tmp);
}
@@ -936,7 +936,7 @@ gfc_call_realloc (stmtblock_t * block, tree mem, tree size)
("Attempt to allocate a negative amount of memory."));
tmp = fold_build3 (COND_EXPR, void_type_node, negative,
build_call_expr (gfor_fndecl_runtime_error, 1, msg),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
/* Call realloc and check the result. */
@@ -953,14 +953,14 @@ gfc_call_realloc (stmtblock_t * block, tree mem, tree size)
("Out of memory"));
tmp = fold_build3 (COND_EXPR, void_type_node, null_result,
build_call_expr (gfor_fndecl_os_error, 1, msg),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
/* if (size == 0) then the result is NULL. */
tmp = fold_build2 (MODIFY_EXPR, type, res, build_int_cst (type, 0));
zero = fold_build1 (TRUTH_NOT_EXPR, boolean_type_node, nonzero);
tmp = fold_build3 (COND_EXPR, void_type_node, zero, tmp,
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
return res;
@@ -1038,7 +1038,7 @@ gfc_trans_code (gfc_code * code)
tree res;
if (!code)
- return build_empty_stmt ();
+ return build_empty_stmt (input_location);
gfc_start_block (&block);
@@ -1289,10 +1289,9 @@ gfc_generate_module_code (gfc_namespace * ns)
gcc_assert (ns->proc_name->backend_decl == NULL);
ns->proc_name->backend_decl
- = build_decl (NAMESPACE_DECL, get_identifier (ns->proc_name->name),
+ = build_decl (ns->proc_name->declared_at.lb->location,
+ NAMESPACE_DECL, get_identifier (ns->proc_name->name),
void_type_node);
- gfc_set_decl_location (ns->proc_name->backend_decl,
- &ns->proc_name->declared_at);
entry = gfc_find_module (ns->proc_name->name);
if (entry->namespace_decl)
/* Buggy sourcecode, using a module before defining it? */
diff --git a/gcc/function.c b/gcc/function.c
index 82741779aa6..20d7421ccd2 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -2100,7 +2100,8 @@ split_complex_args (tree args)
layout_decl (p, 0);
/* Build a second synthetic decl. */
- decl = build_decl (PARM_DECL, NULL_TREE, subtype);
+ decl = build_decl (EXPR_LOCATION (p),
+ PARM_DECL, NULL_TREE, subtype);
DECL_ARG_TYPE (decl) = DECL_ARG_TYPE (p);
DECL_ARTIFICIAL (decl) = addressable;
DECL_IGNORED_P (decl) = addressable;
@@ -2135,7 +2136,8 @@ assign_parms_augmented_arg_list (struct assign_parm_data_all *all)
tree type = build_pointer_type (TREE_TYPE (fntype));
tree decl;
- decl = build_decl (PARM_DECL, NULL_TREE, type);
+ decl = build_decl (DECL_SOURCE_LOCATION (fndecl),
+ PARM_DECL, NULL_TREE, type);
DECL_ARG_TYPE (decl) = type;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 42bf9b11ea9..e096c00dd21 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -169,7 +169,7 @@ lower_function_body (void)
tree disp_label, disp_var, arg;
/* Build 'DISP_LABEL:' and insert. */
- disp_label = create_artificial_label ();
+ disp_label = create_artificial_label (cfun->function_end_locus);
/* This mark will create forward edges from every call site. */
DECL_NONLOCAL (disp_label) = 1;
cfun->has_nonlocal_label = 1;
@@ -727,7 +727,7 @@ lower_gimple_return (gimple_stmt_iterator *gsi, struct lower_data *data)
}
/* Not found. Create a new label and record the return statement. */
- tmp_rs.label = create_artificial_label ();
+ tmp_rs.label = create_artificial_label (cfun->function_end_locus);
tmp_rs.stmt = stmt;
VEC_safe_push (return_statements_t, heap, data->return_statements, &tmp_rs);
@@ -797,8 +797,9 @@ static void
lower_builtin_setjmp (gimple_stmt_iterator *gsi)
{
gimple stmt = gsi_stmt (*gsi);
- tree cont_label = create_artificial_label ();
- tree next_label = create_artificial_label ();
+ location_t loc = gimple_location (stmt);
+ tree cont_label = create_artificial_label (loc);
+ tree next_label = create_artificial_label (loc);
tree dest, t, arg;
gimple g;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 6490a65ddc3..84531789f22 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1379,6 +1379,8 @@ dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
pp_string (buffer, " : ");
}
pp_decimal_int (buffer, xloc.line);
+ pp_string (buffer, ":");
+ pp_decimal_int (buffer, xloc.column);
pp_string (buffer, "] ");
}
@@ -1730,6 +1732,8 @@ dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
pp_string (buffer, " : ");
}
pp_decimal_int (buffer, goto_xloc.line);
+ pp_string (buffer, " : ");
+ pp_decimal_int (buffer, goto_xloc.column);
pp_string (buffer, "] ");
}
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 073fda0005b..15005c379bd 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -516,7 +516,8 @@ create_tmp_var_raw (tree type, const char *prefix)
new_type = build_type_variant (type, 0, 0);
TYPE_ATTRIBUTES (new_type) = TYPE_ATTRIBUTES (type);
- tmp_var = build_decl (VAR_DECL, prefix ? create_tmp_var_name (prefix) : NULL,
+ tmp_var = build_decl (input_location,
+ VAR_DECL, prefix ? create_tmp_var_name (prefix) : NULL,
type);
/* The variable was declared by the compiler. */
@@ -1464,7 +1465,7 @@ static enum gimplify_status
gimplify_loop_expr (tree *expr_p, gimple_seq *pre_p)
{
tree saved_label = gimplify_ctxp->exit_label;
- tree start_label = create_artificial_label ();
+ tree start_label = create_artificial_label (UNKNOWN_LOCATION);
gimplify_seq_add_stmt (pre_p, gimple_build_label (start_label));
@@ -1654,9 +1655,10 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p)
{
gimple new_default;
- default_case = build3 (CASE_LABEL_EXPR, void_type_node,
- NULL_TREE, NULL_TREE,
- create_artificial_label ());
+ default_case
+ = build3 (CASE_LABEL_EXPR, void_type_node,
+ NULL_TREE, NULL_TREE,
+ create_artificial_label (UNKNOWN_LOCATION));
new_default = gimple_build_label (CASE_LABEL (default_case));
gimplify_seq_add_stmt (&switch_body_seq, new_default);
}
@@ -1707,7 +1709,7 @@ build_and_jump (tree *label_p)
if (*label_p == NULL_TREE)
{
- tree label = create_artificial_label ();
+ tree label = create_artificial_label (UNKNOWN_LOCATION);
*label_p = label;
}
@@ -1853,7 +1855,7 @@ gimplify_conversion (tree *expr_p)
{
tree tem;
gcc_assert (CONVERT_EXPR_P (*expr_p));
-
+
/* Then strip away all but the outermost conversion. */
STRIP_SIGN_NOPS (TREE_OPERAND (*expr_p, 0));
@@ -1868,8 +1870,8 @@ gimplify_conversion (tree *expr_p)
&& POINTER_TYPE_P (TREE_TYPE (*expr_p))
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (*expr_p, 0)))
&& (tem = maybe_fold_offset_to_address
- (TREE_OPERAND (*expr_p, 0),
- integer_zero_node, TREE_TYPE (*expr_p))) != NULL_TREE)
+ (EXPR_LOCATION (*expr_p), TREE_OPERAND (*expr_p, 0),
+ integer_zero_node, TREE_TYPE (*expr_p))) != NULL_TREE)
*expr_p = tem;
/* If we still have a conversion at the toplevel,
@@ -2310,6 +2312,7 @@ gimplify_arg (tree *arg_p, gimple_seq *pre_p, location_t call_location)
/* If this is a variable sized type, we must remember the size. */
maybe_with_size_expr (arg_p);
+ /* FIXME diagnostics: This will mess up gcc.dg/Warray-bounds.c. */
/* Make sure arguments have the same location as the function call
itself. */
protected_set_expr_location (*arg_p, call_location);
@@ -2374,13 +2377,13 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
if (call_expr_nargs (*expr_p) < 2)
{
error ("too few arguments to function %<va_start%>");
- *expr_p = build_empty_stmt ();
+ *expr_p = build_empty_stmt (EXPR_LOCATION (*expr_p));
return GS_OK;
}
if (fold_builtin_next_arg (*expr_p, true))
{
- *expr_p = build_empty_stmt ();
+ *expr_p = build_empty_stmt (EXPR_LOCATION (*expr_p));
return GS_OK;
}
}
@@ -3048,7 +3051,7 @@ gimplify_cond_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback)
have_then_clause_p = true;
}
else
- label_true = create_artificial_label ();
+ label_true = create_artificial_label (UNKNOWN_LOCATION);
if (TREE_OPERAND (expr, 2) != NULL
&& TREE_CODE (TREE_OPERAND (expr, 2)) == GOTO_EXPR
&& TREE_CODE (GOTO_DESTINATION (TREE_OPERAND (expr, 2))) == LABEL_DECL
@@ -3066,7 +3069,7 @@ gimplify_cond_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback)
have_else_clause_p = true;
}
else
- label_false = create_artificial_label ();
+ label_false = create_artificial_label (UNKNOWN_LOCATION);
gimple_cond_get_ops_from_tree (COND_EXPR_COND (expr), &pred_code, &arm1,
&arm2);
@@ -3097,7 +3100,7 @@ gimplify_cond_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback)
&& gimple_seq_may_fallthru (seq))
{
gimple g;
- label_cont = create_artificial_label ();
+ label_cont = create_artificial_label (UNKNOWN_LOCATION);
g = gimple_build_goto (label_cont);
@@ -3380,9 +3383,9 @@ gimplify_init_ctor_eval_range (tree object, tree lower, tree upper,
tree loop_entry_label, loop_exit_label, fall_thru_label;
tree var, var_type, cref, tmp;
- loop_entry_label = create_artificial_label ();
- loop_exit_label = create_artificial_label ();
- fall_thru_label = create_artificial_label ();
+ loop_entry_label = create_artificial_label (UNKNOWN_LOCATION);
+ loop_exit_label = create_artificial_label (UNKNOWN_LOCATION);
+ fall_thru_label = create_artificial_label (UNKNOWN_LOCATION);
/* Create and initialize the index variable. */
var_type = TREE_TYPE (upper);
@@ -4479,7 +4482,10 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
gimple_call_set_lhs (assign, *to_p);
}
else
- assign = gimple_build_assign (*to_p, *from_p);
+ {
+ assign = gimple_build_assign (*to_p, *from_p);
+ gimple_set_location (assign, EXPR_LOCATION (*expr_p));
+ }
gimplify_seq_add_stmt (pre_p, assign);
@@ -5819,7 +5825,7 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
else
gcc_unreachable ();
- clause = build_omp_clause (code);
+ clause = build_omp_clause (input_location, code);
OMP_CLAUSE_DECL (clause) = decl;
OMP_CLAUSE_CHAIN (clause) = *list_p;
if (private_debug)
@@ -6969,8 +6975,9 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
*/
if (TREE_CODE (TREE_OPERAND (*expr_p, 1)) == INTEGER_CST
&& (tmp = maybe_fold_offset_to_address
- (TREE_OPERAND (*expr_p, 0), TREE_OPERAND (*expr_p, 1),
- TREE_TYPE (*expr_p))))
+ (EXPR_LOCATION (*expr_p),
+ TREE_OPERAND (*expr_p, 0), TREE_OPERAND (*expr_p, 1),
+ TREE_TYPE (*expr_p))))
{
*expr_p = tmp;
break;
@@ -6981,10 +6988,11 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p,
0),0)))
&& (tmp = maybe_fold_offset_to_address
- (TREE_OPERAND (TREE_OPERAND (*expr_p, 0), 0),
- TREE_OPERAND (*expr_p, 1),
- TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p, 0),
- 0)))))
+ (EXPR_LOCATION (*expr_p),
+ TREE_OPERAND (TREE_OPERAND (*expr_p, 0), 0),
+ TREE_OPERAND (*expr_p, 1),
+ TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p, 0),
+ 0)))))
{
*expr_p = fold_convert (TREE_TYPE (*expr_p), tmp);
break;
diff --git a/gcc/ipa-struct-reorg.c b/gcc/ipa-struct-reorg.c
index a81f7411521..199c5855e2e 100644
--- a/gcc/ipa-struct-reorg.c
+++ b/gcc/ipa-struct-reorg.c
@@ -2178,7 +2178,8 @@ create_new_var_1 (tree orig_decl, d_str str, new_var node)
type = gen_struct_type (orig_decl, type);
if (is_global_var (orig_decl))
- new_decl = build_decl (VAR_DECL, new_name, type);
+ new_decl = build_decl (DECL_SOURCE_LOCATION (orig_decl),
+ VAR_DECL, new_name, type);
else
{
const char *name = new_name ? IDENTIFIER_POINTER (new_name) : NULL;
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 1ea81d63346..b3daaa8e189 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,19 @@
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * java-gimplify.c (java_gimplify_block): New argument to
+ build_empty_stmt.
+ * expr.c (force_evaluation_order): Same.
+ * typeck.c: Add location to build_decl or PUSH_FIELD calls.
+ * class.c: Same.
+ * decl.c: Same.
+ * jcf-parse.c: Same.
+ * constants.c: Same.
+ * resource.c: Same.
+ * except.c: Same.
+ * builtins.c: Same.
+ * expr.c: Same.
+ * java-tree.h (PUSH_FIELD): Add location field.
+
2009-06-09 Ian Lance Taylor <iant@google.com>
* verify.h: Remove extern "C".
diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c
index 39c73a5e7fa..0f7b197f78c 100644
--- a/gcc/java/builtins.c
+++ b/gcc/java/builtins.c
@@ -411,7 +411,7 @@ getVolatile_builtin (tree method_return_type ATTRIBUTE_UNUSED,
stmt = build_call_expr (built_in_decls[BUILT_IN_SYNCHRONIZE], 0);
- tmp = build_decl (VAR_DECL, NULL, method_return_type);
+ tmp = build_decl (BUILTINS_LOCATION, VAR_DECL, NULL, method_return_type);
DECL_IGNORED_P (tmp) = 1;
DECL_ARTIFICIAL (tmp) = 1;
pushdecl (tmp);
@@ -453,7 +453,8 @@ define_builtin (enum built_in_function val,
{
tree decl;
- decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
+ decl = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, get_identifier (name), type);
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname));
diff --git a/gcc/java/class.c b/gcc/java/class.c
index edd16f0ad61..1b594e5ca84 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -420,7 +420,7 @@ do \
\
sprintf (buf, #NAME "_%s", type_name); \
TYPE_## TABLE ##_DECL (type) = decl = \
- build_decl (VAR_DECL, get_identifier (buf), TABLE_TYPE); \
+ build_decl (input_location, VAR_DECL, get_identifier (buf), TABLE_TYPE); \
DECL_EXTERNAL (decl) = 1; \
TREE_STATIC (decl) = 1; \
TREE_READONLY (decl) = 1; \
@@ -432,7 +432,7 @@ do \
DECL_OWNER (decl) = TYPE; \
sprintf (buf, #NAME "_syms_%s", type_name); \
TYPE_## TABLE ##_SYMS_DECL (TYPE) = \
- build_decl (VAR_DECL, get_identifier (buf), symbols_array_type); \
+ build_decl (input_location, VAR_DECL, get_identifier (buf), symbols_array_type); \
TREE_STATIC (TYPE_## TABLE ##_SYMS_DECL (TYPE)) = 1; \
TREE_CONSTANT (TYPE_## TABLE ##_SYMS_DECL (TYPE)) = 1; \
DECL_IGNORED_P (TYPE_## TABLE ##_SYMS_DECL (TYPE)) = 1; \
@@ -452,12 +452,14 @@ gen_indirect_dispatch_tables (tree type)
tree catch_class_type = make_node (RECORD_TYPE);
sprintf (buf, "_catch_classes_%s", type_name);
- PUSH_FIELD (catch_class_type, field, "address", utf8const_ptr_type);
- PUSH_FIELD (catch_class_type, field, "classname", ptr_type_node);
+ PUSH_FIELD (input_location,
+ catch_class_type, field, "address", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ catch_class_type, field, "classname", ptr_type_node);
FINISH_RECORD (catch_class_type);
TYPE_CTABLE_DECL (type)
- = build_decl (VAR_DECL, get_identifier (buf),
+ = build_decl (input_location, VAR_DECL, get_identifier (buf),
build_array_type (catch_class_type, 0));
DECL_EXTERNAL (TYPE_CTABLE_DECL (type)) = 1;
TREE_STATIC (TYPE_CTABLE_DECL (type)) = 1;
@@ -483,7 +485,7 @@ push_class (tree class_type, tree class_name)
tree decl, signature;
location_t saved_loc = input_location;
CLASS_P (class_type) = 1;
- decl = build_decl (TYPE_DECL, class_name, class_type);
+ decl = build_decl (input_location, TYPE_DECL, class_name, class_type);
TYPE_DECL_SUPPRESS_DEBUG (decl) = 1;
/* dbxout needs a DECL_SIZE if in gstabs mode */
@@ -758,7 +760,7 @@ add_method_1 (tree this_class, int access_flags, tree name, tree function_type)
method_type = build_java_method_type (function_type,
this_class, access_flags);
- fndecl = build_decl (FUNCTION_DECL, name, method_type);
+ fndecl = build_decl (input_location, FUNCTION_DECL, name, method_type);
DECL_CONTEXT (fndecl) = this_class;
DECL_LANG_SPECIFIC (fndecl)
@@ -844,7 +846,8 @@ add_field (tree klass, tree name, tree field_type, int flags)
{
int is_static = (flags & ACC_STATIC) != 0;
tree field;
- field = build_decl (is_static ? VAR_DECL : FIELD_DECL, name, field_type);
+ field = build_decl (input_location,
+ is_static ? VAR_DECL : FIELD_DECL, name, field_type);
TREE_CHAIN (field) = TYPE_FIELDS (klass);
TYPE_FIELDS (klass) = field;
DECL_CONTEXT (field) = klass;
@@ -948,9 +951,10 @@ build_utf8_ref (tree name)
- (name_len & (TYPE_ALIGN_UNIT (utf8const_type) - 1));
str_type = build_prim_array_type (unsigned_byte_type_node,
name_len + name_pad);
- PUSH_FIELD (ctype, field, "hash", unsigned_short_type_node);
- PUSH_FIELD (ctype, field, "length", unsigned_short_type_node);
- PUSH_FIELD (ctype, field, "data", str_type);
+ PUSH_FIELD (input_location, ctype, field, "hash", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ ctype, field, "length", unsigned_short_type_node);
+ PUSH_FIELD (input_location, ctype, field, "data", str_type);
FINISH_RECORD (ctype);
START_RECORD_CONSTRUCTOR (cinit, ctype);
name_hash = hashUtf8String (name_ptr, name_len) & 0xFFFF;
@@ -965,7 +969,8 @@ build_utf8_ref (tree name)
/* Generate a unique-enough identifier. */
sprintf(buf, "_Utf%d", ++utf8_count);
- decl = build_decl (VAR_DECL, get_identifier (buf), utf8const_type);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), utf8const_type);
TREE_STATIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
@@ -1027,7 +1032,7 @@ build_static_class_ref (tree type)
decl = IDENTIFIER_GLOBAL_VALUE (decl_name);
if (decl == NULL_TREE)
{
- decl = build_decl (VAR_DECL, decl_name, class_type_node);
+ decl = build_decl (input_location, VAR_DECL, decl_name, class_type_node);
TREE_STATIC (decl) = 1;
if (! flag_indirect_classes)
{
@@ -1062,7 +1067,8 @@ build_classdollar_field (tree type)
if (decl == NULL_TREE)
{
decl
- = build_decl (VAR_DECL, decl_name,
+ = build_decl (input_location,
+ VAR_DECL, decl_name,
(build_type_variant
(build_pointer_type
(build_type_variant (class_type_node,
@@ -1097,7 +1103,8 @@ cache_this_class_ref (tree fndecl)
else
classdollar_field = build_static_class_ref (output_class);
- this_classdollar = build_decl (VAR_DECL, NULL_TREE,
+ this_classdollar = build_decl (input_location,
+ VAR_DECL, NULL_TREE,
TREE_TYPE (classdollar_field));
java_add_local_var (this_classdollar);
@@ -1175,7 +1182,8 @@ build_class_ref (tree type)
decl = IDENTIFIER_GLOBAL_VALUE (decl_name);
if (decl == NULL_TREE)
{
- decl = build_decl (VAR_DECL, decl_name, class_type_node);
+ decl = build_decl (input_location,
+ VAR_DECL, decl_name, class_type_node);
TREE_STATIC (decl) = 1;
TREE_PUBLIC (decl) = 1;
DECL_EXTERNAL (decl) = 1;
@@ -1205,7 +1213,8 @@ build_fieldref_cache_entry (int index, tree fdecl ATTRIBUTE_UNUSED)
decl = IDENTIFIER_GLOBAL_VALUE (decl_name);
if (decl == NULL_TREE)
{
- decl = build_decl (VAR_DECL, decl_name, ptr_type_node);
+ decl = build_decl (input_location,
+ VAR_DECL, decl_name, ptr_type_node);
TREE_STATIC (decl) = 1;
TREE_PUBLIC (decl) = 0;
DECL_EXTERNAL (decl) = 0;
@@ -1386,7 +1395,8 @@ make_local_function_alias (tree method)
strcpy (name + 1, method_name);
ASM_GENERATE_INTERNAL_LABEL (buf, name, alias_labelno++);
- alias = build_decl (FUNCTION_DECL, get_identifier (buf),
+ alias = build_decl (input_location,
+ FUNCTION_DECL, get_identifier (buf),
TREE_TYPE (method));
DECL_CONTEXT (alias) = NULL;
TREE_READONLY (alias) = TREE_READONLY (method);
@@ -1530,7 +1540,8 @@ make_method_value (tree mdecl)
table = build_constructor_from_list (type, table);
/* Compute something unique enough. */
sprintf (buf, "_methods%d", method_name_count++);
- array = build_decl (VAR_DECL, get_identifier (buf), type);
+ array = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), type);
DECL_INITIAL (array) = table;
TREE_STATIC (array) = 1;
DECL_ARTIFICIAL (array) = 1;
@@ -1862,7 +1873,8 @@ make_class_data (tree type)
instance_fields = nreverse (instance_fields);
static_fields = chainon (static_fields, instance_fields);
field_array_type = build_prim_array_type (field_type_node, field_count);
- fields_decl = build_decl (VAR_DECL, mangled_classname ("_FL_", type),
+ fields_decl = build_decl (input_location,
+ VAR_DECL, mangled_classname ("_FL_", type),
field_array_type);
DECL_INITIAL (fields_decl) = build_constructor_from_list
(field_array_type, static_fields);
@@ -1918,7 +1930,8 @@ make_class_data (tree type)
}
}
method_array_type = build_prim_array_type (method_type_node, method_count);
- methods_decl = build_decl (VAR_DECL, mangled_classname ("_MT_", type),
+ methods_decl = build_decl (input_location,
+ VAR_DECL, mangled_classname ("_MT_", type),
method_array_type);
DECL_INITIAL (methods_decl) = build_constructor_from_list
(method_array_type, nreverse (methods));
@@ -1964,7 +1977,8 @@ make_class_data (tree type)
tree interface_array_type, idecl;
interface_array_type
= build_prim_array_type (class_ptr_type, interface_len);
- idecl = build_decl (VAR_DECL, mangled_classname ("_IF_", type),
+ idecl = build_decl (input_location,
+ VAR_DECL, mangled_classname ("_IF_", type),
interface_array_type);
for (i = interface_len; i > 0; i--)
@@ -2168,7 +2182,8 @@ make_class_data (tree type)
static int reflection_data_count;
sprintf (buf, "_reflection_data_%d", reflection_data_count++);
- array = build_decl (VAR_DECL, get_identifier (buf), type);
+ array = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), type);
rewrite_reflection_indexes (field_indexes);
@@ -2298,23 +2313,25 @@ build_dtable_decl (tree type)
dtype = make_node (RECORD_TYPE);
- PUSH_FIELD (dtype, dummy, "top_offset", ptr_type_node);
- PUSH_FIELD (dtype, dummy, "type_info", ptr_type_node);
+ PUSH_FIELD (input_location, dtype, dummy, "top_offset", ptr_type_node);
+ PUSH_FIELD (input_location, dtype, dummy, "type_info", ptr_type_node);
- PUSH_FIELD (dtype, dummy, "class", class_ptr_type);
+ PUSH_FIELD (input_location, dtype, dummy, "class", class_ptr_type);
for (n = 1; n < TARGET_VTABLE_USES_DESCRIPTORS; ++n)
{
- tree tmp_field = build_decl (FIELD_DECL, NULL_TREE, ptr_type_node);
+ tree tmp_field = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, ptr_type_node);
TREE_CHAIN (dummy) = tmp_field;
DECL_CONTEXT (tmp_field) = dtype;
DECL_ARTIFICIAL (tmp_field) = 1;
dummy = tmp_field;
}
- PUSH_FIELD (dtype, dummy, "gc_descr", ptr_type_node);
+ PUSH_FIELD (input_location, dtype, dummy, "gc_descr", ptr_type_node);
for (n = 1; n < TARGET_VTABLE_USES_DESCRIPTORS; ++n)
{
- tree tmp_field = build_decl (FIELD_DECL, NULL_TREE, ptr_type_node);
+ tree tmp_field = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, ptr_type_node);
TREE_CHAIN (dummy) = tmp_field;
DECL_CONTEXT (tmp_field) = dtype;
DECL_ARTIFICIAL (tmp_field) = 1;
@@ -2325,14 +2342,15 @@ build_dtable_decl (tree type)
if (TARGET_VTABLE_USES_DESCRIPTORS)
n *= TARGET_VTABLE_USES_DESCRIPTORS;
- PUSH_FIELD (dtype, dummy, "methods",
+ PUSH_FIELD (input_location, dtype, dummy, "methods",
build_prim_array_type (nativecode_ptr_type_node, n));
layout_type (dtype);
}
else
dtype = dtable_type;
- decl = build_decl (VAR_DECL, get_identifier ("vt$"), dtype);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier ("vt$"), dtype);
DECL_CONTEXT (decl) = type;
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
DECL_VTABLE_P (decl) = 1;
@@ -2350,7 +2368,8 @@ push_super_field (tree this_class, tree super_class)
/* Don't insert the field if we're just re-laying the class out. */
if (TYPE_FIELDS (this_class) && !DECL_NAME (TYPE_FIELDS (this_class)))
return;
- base_decl = build_decl (FIELD_DECL, NULL_TREE, super_class);
+ base_decl = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, super_class);
DECL_IGNORED_P (base_decl) = 1;
TREE_CHAIN (base_decl) = TYPE_FIELDS (this_class);
TYPE_FIELDS (this_class) = base_decl;
@@ -2719,7 +2738,8 @@ emit_indirect_register_classes (tree *list_p)
int size = VEC_length (tree, registered_class) * 2 + 1;
tree class_array_type
= build_prim_array_type (ptr_type_node, size);
- tree cdecl = build_decl (VAR_DECL, get_identifier ("_Jv_CLS"),
+ tree cdecl = build_decl (input_location,
+ VAR_DECL, get_identifier ("_Jv_CLS"),
class_array_type);
tree reg_class_list;
for (i = 0; VEC_iterate (tree, registered_class, i, klass); ++i)
@@ -2747,7 +2767,8 @@ emit_indirect_register_classes (tree *list_p)
t = build_function_type_list (void_type_node,
build_pointer_type (ptr_type_node), NULL);
- t = build_decl (FUNCTION_DECL,
+ t = build_decl (input_location,
+ FUNCTION_DECL,
get_identifier ("_Jv_RegisterNewClasses"), t);
TREE_PUBLIC (t) = 1;
DECL_EXTERNAL (t) = 1;
@@ -2809,7 +2830,8 @@ emit_register_classes (tree *list_p)
int i;
t = build_function_type_list (void_type_node, class_ptr_type, NULL);
- t = build_decl (FUNCTION_DECL, get_identifier ("_Jv_RegisterClass"), t);
+ t = build_decl (input_location,
+ FUNCTION_DECL, get_identifier ("_Jv_RegisterClass"), t);
TREE_PUBLIC (t) = 1;
DECL_EXTERNAL (t) = 1;
register_class_fn = t;
@@ -2915,7 +2937,8 @@ emit_symbol_table (tree name, tree the_table, tree decl_list,
table_size
= build_index_type (build_int_cst (NULL_TREE, index * element_size + 1));
the_array_type = build_array_type (the_array_element_type, table_size);
- the_table = build_decl (VAR_DECL, name, the_array_type);
+ the_table = build_decl (input_location,
+ VAR_DECL, name, the_array_type);
TREE_STATIC (the_table) = 1;
TREE_READONLY (the_table) = 1;
rest_of_decl_compilation (the_table, 1, 0);
@@ -2959,7 +2982,8 @@ emit_catch_table (tree this_class)
= build_array_type (TREE_TYPE (TREE_TYPE (TYPE_CTABLE_DECL (this_class))),
table_size);
table =
- build_decl (VAR_DECL, DECL_NAME (TYPE_CTABLE_DECL (this_class)), array_type);
+ build_decl (input_location,
+ VAR_DECL, DECL_NAME (TYPE_CTABLE_DECL (this_class)), array_type);
DECL_INITIAL (table) =
build_constructor_from_list (array_type, TYPE_CATCH_CLASSES (this_class));
TREE_STATIC (table) = 1;
@@ -3043,7 +3067,8 @@ emit_assertion_table (tree klass)
list = nreverse (list);
ctor = build_constructor_from_list (assertion_table_type, list);
- table_decl = build_decl (VAR_DECL, mangled_classname ("_type_assert_", klass),
+ table_decl = build_decl (input_location,
+ VAR_DECL, mangled_classname ("_type_assert_", klass),
assertion_table_type);
TREE_STATIC (table_decl) = 1;
diff --git a/gcc/java/constants.c b/gcc/java/constants.c
index 70d628b4c5a..541e78d2cb5 100644
--- a/gcc/java/constants.c
+++ b/gcc/java/constants.c
@@ -463,7 +463,7 @@ build_constant_data_ref (bool indirect)
thinks the type is incomplete. */
layout_type (type);
- decl = build_decl (VAR_DECL, decl_name, type);
+ decl = build_decl (input_location, VAR_DECL, decl_name, type);
TREE_STATIC (decl) = 1;
IDENTIFIER_GLOBAL_VALUE (decl_name) = decl;
}
@@ -581,7 +581,8 @@ build_constants_constructor (void)
data_value = build_address_of (data_decl);
tags_type = build_array_type (unsigned_byte_type_node, index_type);
- tags_decl = build_decl (VAR_DECL, mangled_classname ("_CT_",
+ tags_decl = build_decl (input_location,
+ VAR_DECL, mangled_classname ("_CT_",
current_class),
tags_type);
TREE_STATIC (tags_decl) = 1;
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index bd0cc8e4de6..3c1e7eaef9c 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -274,7 +274,7 @@ find_local_variable (int index, tree type, int pc ATTRIBUTE_UNUSED)
tree name;
sprintf (buf, "#slot#%d#%d", index, uniq++);
name = get_identifier (buf);
- decl = build_decl (VAR_DECL, name, type);
+ decl = build_decl (input_location, VAR_DECL, name, type);
DECL_IGNORED_P (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
decl = push_jvm_slot (index, decl);
@@ -297,7 +297,7 @@ find_local_variable (int index, tree type, int pc ATTRIBUTE_UNUSED)
name = get_identifier (buf);
base_decl
= TREE_VEC_ELT (base_decl_map, index)
- = build_decl (VAR_DECL, name, ptr_type_node);
+ = build_decl (input_location, VAR_DECL, name, ptr_type_node);
pushdecl_function_level (base_decl);
DECL_IGNORED_P (base_decl) = 1;
DECL_ARTIFICIAL (base_decl) = 1;
@@ -450,7 +450,8 @@ push_promoted_type (const char *name, tree actual_type)
TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node);
TYPE_STRING_FLAG (type) = TYPE_STRING_FLAG (actual_type);
layout_type (type);
- pushdecl (build_decl (TYPE_DECL, get_identifier (name), type));
+ pushdecl (build_decl (input_location,
+ TYPE_DECL, get_identifier (name), type));
return type;
}
@@ -462,7 +463,8 @@ create_primitive_vtable (const char *name)
char buf[50];
sprintf (buf, "_Jv_%sVTable", name);
- r = build_decl (VAR_DECL, get_identifier (buf), ptr_type_node);
+ r = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), ptr_type_node);
DECL_EXTERNAL (r) = 1;
return r;
}
@@ -545,25 +547,33 @@ java_init_decl_processing (void)
initialize_sizetypes (false);
byte_type_node = make_signed_type (8);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("byte"), byte_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("byte"), byte_type_node));
short_type_node = make_signed_type (16);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("short"), short_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("short"), short_type_node));
int_type_node = make_signed_type (32);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("int"), int_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("int"), int_type_node));
long_type_node = make_signed_type (64);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("long"), long_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("long"), long_type_node));
unsigned_byte_type_node = make_unsigned_type (8);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned byte"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("unsigned byte"),
unsigned_byte_type_node));
unsigned_short_type_node = make_unsigned_type (16);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned short"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("unsigned short"),
unsigned_short_type_node));
unsigned_int_type_node = make_unsigned_type (32);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("unsigned int"),
unsigned_int_type_node));
unsigned_long_type_node = make_unsigned_type (64);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned long"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("unsigned long"),
unsigned_long_type_node));
/* This is not a java type, however tree-dfa requires a definition for
@@ -600,7 +610,8 @@ java_init_decl_processing (void)
long_zero_node = build_int_cst (long_type_node, 0);
void_type_node = make_node (VOID_TYPE);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("void"), void_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("void"), void_type_node));
layout_type (void_type_node); /* Uses size_zero_node */
ptr_type_node = build_pointer_type (void_type_node);
@@ -617,12 +628,14 @@ java_init_decl_processing (void)
TYPE_STRING_FLAG (char_type_node) = 1;
TYPE_PRECISION (char_type_node) = 16;
fixup_unsigned_type (char_type_node);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("char"), char_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("char"), char_type_node));
boolean_type_node = make_node (BOOLEAN_TYPE);
TYPE_PRECISION (boolean_type_node) = 1;
fixup_unsigned_type (boolean_type_node);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("boolean"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("boolean"),
boolean_type_node));
boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
@@ -638,13 +651,15 @@ java_init_decl_processing (void)
float_type_node = make_node (REAL_TYPE);
TYPE_PRECISION (float_type_node) = 32;
- pushdecl (build_decl (TYPE_DECL, get_identifier ("float"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("float"),
float_type_node));
layout_type (float_type_node);
double_type_node = make_node (REAL_TYPE);
TYPE_PRECISION (double_type_node) = 64;
- pushdecl (build_decl (TYPE_DECL, get_identifier ("double"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("double"),
double_type_node));
layout_type (double_type_node);
@@ -663,8 +678,10 @@ java_init_decl_processing (void)
one_elt_array_domain_type = build_index_type (integer_one_node);
utf8const_type = make_node (RECORD_TYPE);
- PUSH_FIELD (utf8const_type, field, "hash", unsigned_short_type_node);
- PUSH_FIELD (utf8const_type, field, "length", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ utf8const_type, field, "hash", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ utf8const_type, field, "length", unsigned_short_type_node);
FINISH_RECORD (utf8const_type);
utf8const_ptr_type = build_pointer_type (utf8const_type);
@@ -679,9 +696,11 @@ java_init_decl_processing (void)
itable_ptr_type = build_pointer_type (itable_type);
symbol_type = make_node (RECORD_TYPE);
- PUSH_FIELD (symbol_type, field, "clname", utf8const_ptr_type);
- PUSH_FIELD (symbol_type, field, "name", utf8const_ptr_type);
- PUSH_FIELD (symbol_type, field, "signature", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ symbol_type, field, "clname", utf8const_ptr_type);
+ PUSH_FIELD (input_location, symbol_type, field, "name", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ symbol_type, field, "signature", utf8const_ptr_type);
FINISH_RECORD (symbol_type);
symbols_array_type = build_array_type (symbol_type,
@@ -689,9 +708,12 @@ java_init_decl_processing (void)
symbols_array_ptr_type = build_pointer_type (symbols_array_type);
assertion_entry_type = make_node (RECORD_TYPE);
- PUSH_FIELD (assertion_entry_type, field, "assertion_code", integer_type_node);
- PUSH_FIELD (assertion_entry_type, field, "op1", utf8const_ptr_type);
- PUSH_FIELD (assertion_entry_type, field, "op2", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ assertion_entry_type, field, "assertion_code", integer_type_node);
+ PUSH_FIELD (input_location,
+ assertion_entry_type, field, "op1", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ assertion_entry_type, field, "op2", utf8const_ptr_type);
FINISH_RECORD (assertion_entry_type);
assertion_table_type = build_array_type (assertion_entry_type,
@@ -729,7 +751,8 @@ java_init_decl_processing (void)
methodtable_type = make_node (RECORD_TYPE);
layout_type (methodtable_type);
- build_decl (TYPE_DECL, get_identifier ("methodtable"), methodtable_type);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("methodtable"), methodtable_type);
methodtable_ptr_type = build_pointer_type (methodtable_type);
TYPE_identifier_node = get_identifier ("TYPE");
@@ -747,12 +770,16 @@ java_init_decl_processing (void)
init_expr_processing();
constants_type_node = make_node (RECORD_TYPE);
- PUSH_FIELD (constants_type_node, field, "size", unsigned_int_type_node);
- PUSH_FIELD (constants_type_node, field, "tags", ptr_type_node);
- PUSH_FIELD (constants_type_node, field, "data", ptr_type_node);
+ PUSH_FIELD (input_location,
+ constants_type_node, field, "size", unsigned_int_type_node);
+ PUSH_FIELD (input_location,
+ constants_type_node, field, "tags", ptr_type_node);
+ PUSH_FIELD (input_location,
+ constants_type_node, field, "data", ptr_type_node);
constants_data_field_decl_node = field;
FINISH_RECORD (constants_type_node);
- build_decl (TYPE_DECL, get_identifier ("constants"), constants_type_node);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("constants"), constants_type_node);
access_flags_type_node = unsigned_short_type_node;
@@ -764,7 +791,8 @@ java_init_decl_processing (void)
TYPE_NONALIASED_COMPONENT (otable_type) = 1;
otable_ptr_type = build_pointer_type (otable_type);
- PUSH_FIELD (object_type_node, field, "vtable", dtable_ptr_type);
+ PUSH_FIELD (input_location,
+ object_type_node, field, "vtable", dtable_ptr_type);
DECL_FCONTEXT (field) = object_type_node;
TYPE_VFIELD (object_type_node) = field;
@@ -772,7 +800,7 @@ java_init_decl_processing (void)
There is an unresolved issue here, which is whether the vtable
should be marked by the GC. */
if (! flag_hash_synchronization)
- PUSH_FIELD (object_type_node, field, "sync_info",
+ PUSH_FIELD (input_location, object_type_node, field, "sync_info",
build_pointer_type (object_type_node));
for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
FIELD_PRIVATE (t) = 1;
@@ -787,101 +815,154 @@ java_init_decl_processing (void)
set_super_info (0, string_type_node, object_type_node, 0);
class_ptr_type = build_pointer_type (class_type_node);
- PUSH_FIELD (class_type_node, field, "next_or_version", class_ptr_type);
- PUSH_FIELD (class_type_node, field, "name", utf8const_ptr_type);
- PUSH_FIELD (class_type_node, field, "accflags", access_flags_type_node);
- PUSH_FIELD (class_type_node, field, "superclass", class_ptr_type);
- PUSH_FIELD (class_type_node, field, "constants", constants_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "next_or_version", class_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "name", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "accflags", access_flags_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "superclass", class_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "constants", constants_type_node);
constants_field_decl_node = field;
- PUSH_FIELD (class_type_node, field, "methods", method_ptr_type_node);
- PUSH_FIELD (class_type_node, field, "method_count", short_type_node);
- PUSH_FIELD (class_type_node, field, "vtable_method_count", short_type_node);
- PUSH_FIELD (class_type_node, field, "fields", field_ptr_type_node);
- PUSH_FIELD (class_type_node, field, "size_in_bytes", int_type_node);
- PUSH_FIELD (class_type_node, field, "field_count", short_type_node);
- PUSH_FIELD (class_type_node, field, "static_field_count", short_type_node);
- PUSH_FIELD (class_type_node, field, "vtable", dtable_ptr_type);
- PUSH_FIELD (class_type_node, field, "otable", otable_ptr_type);
- PUSH_FIELD (class_type_node, field, "otable_syms",
+ PUSH_FIELD (input_location,
+ class_type_node, field, "methods", method_ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "method_count", short_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "vtable_method_count", short_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "fields", field_ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "size_in_bytes", int_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "field_count", short_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "static_field_count", short_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "vtable", dtable_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "otable", otable_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "otable_syms",
symbols_array_ptr_type);
- PUSH_FIELD (class_type_node, field, "atable", atable_ptr_type);
- PUSH_FIELD (class_type_node, field, "atable_syms",
+ PUSH_FIELD (input_location,
+ class_type_node, field, "atable", atable_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "atable_syms",
symbols_array_ptr_type);
- PUSH_FIELD (class_type_node, field, "itable", itable_ptr_type);
- PUSH_FIELD (class_type_node, field, "itable_syms",
+ PUSH_FIELD (input_location,
+ class_type_node, field, "itable", itable_ptr_type);
+ PUSH_FIELD (input_location, class_type_node, field, "itable_syms",
symbols_array_ptr_type);
- PUSH_FIELD (class_type_node, field, "catch_classes", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "interfaces",
+ PUSH_FIELD (input_location,
+ class_type_node, field, "catch_classes", ptr_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "interfaces",
build_pointer_type (class_ptr_type));
- PUSH_FIELD (class_type_node, field, "loader", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "interface_count", short_type_node);
- PUSH_FIELD (class_type_node, field, "state", byte_type_node);
- PUSH_FIELD (class_type_node, field, "thread", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "depth", short_type_node);
- PUSH_FIELD (class_type_node, field, "ancestors", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "idt", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "arrayclass", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "protectionDomain", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "assertion_table", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "hack_signers", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "chain", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "aux_info", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "engine", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "reflection_data", ptr_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "loader", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "interface_count", short_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "state", byte_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "thread", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "depth", short_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "ancestors", ptr_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "idt", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "arrayclass", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "protectionDomain", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "assertion_table", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "hack_signers", ptr_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "chain", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "aux_info", ptr_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "engine", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "reflection_data", ptr_type_node);
for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
FIELD_PRIVATE (t) = 1;
push_super_field (class_type_node, object_type_node);
FINISH_RECORD (class_type_node);
- build_decl (TYPE_DECL, get_identifier ("Class"), class_type_node);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("Class"), class_type_node);
field_info_union_node = make_node (UNION_TYPE);
- PUSH_FIELD (field_info_union_node, field, "boffset", int_type_node);
- PUSH_FIELD (field_info_union_node, field, "addr", ptr_type_node);
+ PUSH_FIELD (input_location,
+ field_info_union_node, field, "boffset", int_type_node);
+ PUSH_FIELD (input_location,
+ field_info_union_node, field, "addr", ptr_type_node);
layout_type (field_info_union_node);
- PUSH_FIELD (field_type_node, field, "name", utf8const_ptr_type);
- PUSH_FIELD (field_type_node, field, "type", class_ptr_type);
- PUSH_FIELD (field_type_node, field, "accflags", access_flags_type_node);
- PUSH_FIELD (field_type_node, field, "bsize", unsigned_short_type_node);
- PUSH_FIELD (field_type_node, field, "info", field_info_union_node);
+ PUSH_FIELD (input_location,
+ field_type_node, field, "name", utf8const_ptr_type);
+ PUSH_FIELD (input_location, field_type_node, field, "type", class_ptr_type);
+ PUSH_FIELD (input_location,
+ field_type_node, field, "accflags", access_flags_type_node);
+ PUSH_FIELD (input_location,
+ field_type_node, field, "bsize", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ field_type_node, field, "info", field_info_union_node);
FINISH_RECORD (field_type_node);
- build_decl (TYPE_DECL, get_identifier ("Field"), field_type_node);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("Field"), field_type_node);
nativecode_ptr_array_type_node
= build_array_type (nativecode_ptr_type_node, one_elt_array_domain_type);
- PUSH_FIELD (dtable_type, field, "class", class_ptr_type);
- PUSH_FIELD (dtable_type, field, "methods", nativecode_ptr_array_type_node);
+ PUSH_FIELD (input_location,
+ dtable_type, field, "class", class_ptr_type);
+ PUSH_FIELD (input_location,
+ dtable_type, field, "methods", nativecode_ptr_array_type_node);
FINISH_RECORD (dtable_type);
- build_decl (TYPE_DECL, get_identifier ("dispatchTable"), dtable_type);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("dispatchTable"), dtable_type);
jexception_type = make_node (RECORD_TYPE);
- PUSH_FIELD (jexception_type, field, "start_pc", ptr_type_node);
- PUSH_FIELD (jexception_type, field, "end_pc", ptr_type_node);
- PUSH_FIELD (jexception_type, field, "handler_pc", ptr_type_node);
- PUSH_FIELD (jexception_type, field, "catch_type", class_ptr_type);
+ PUSH_FIELD (input_location,
+ jexception_type, field, "start_pc", ptr_type_node);
+ PUSH_FIELD (input_location, jexception_type, field, "end_pc", ptr_type_node);
+ PUSH_FIELD (input_location,
+ jexception_type, field, "handler_pc", ptr_type_node);
+ PUSH_FIELD (input_location,
+ jexception_type, field, "catch_type", class_ptr_type);
FINISH_RECORD (jexception_type);
- build_decl (TYPE_DECL, get_identifier ("jexception"), field_type_node);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("jexception"), field_type_node);
jexception_ptr_type = build_pointer_type (jexception_type);
lineNumberEntry_type = make_node (RECORD_TYPE);
- PUSH_FIELD (lineNumberEntry_type, field, "line_nr", unsigned_short_type_node);
- PUSH_FIELD (lineNumberEntry_type, field, "start_pc", ptr_type_node);
+ PUSH_FIELD (input_location,
+ lineNumberEntry_type, field, "line_nr", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ lineNumberEntry_type, field, "start_pc", ptr_type_node);
FINISH_RECORD (lineNumberEntry_type);
lineNumbers_type = make_node (RECORD_TYPE);
- PUSH_FIELD (lineNumbers_type, field, "length", unsigned_int_type_node);
+ PUSH_FIELD (input_location,
+ lineNumbers_type, field, "length", unsigned_int_type_node);
FINISH_RECORD (lineNumbers_type);
- PUSH_FIELD (method_type_node, field, "name", utf8const_ptr_type);
- PUSH_FIELD (method_type_node, field, "signature", utf8const_ptr_type);
- PUSH_FIELD (method_type_node, field, "accflags", access_flags_type_node);
- PUSH_FIELD (method_type_node, field, "index", unsigned_short_type_node);
- PUSH_FIELD (method_type_node, field, "ncode", nativecode_ptr_type_node);
- PUSH_FIELD (method_type_node, field, "throws", ptr_type_node);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "name", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "signature", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "accflags", access_flags_type_node);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "index", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "ncode", nativecode_ptr_type_node);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "throws", ptr_type_node);
FINISH_RECORD (method_type_node);
- build_decl (TYPE_DECL, get_identifier ("Method"), method_type_node);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("Method"), method_type_node);
endlink = end_params_node = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
@@ -1632,7 +1713,7 @@ give_name_to_locals (JCF *jcf)
{
tree *ptr;
int end_pc = start_pc + length;
- tree decl = build_decl (VAR_DECL, name, type);
+ tree decl = build_decl (input_location, VAR_DECL, name, type);
if (end_pc > DECL_CODE_LENGTH (current_function_decl))
{
warning (0, "bad PC range for debug info for local %q+D",
@@ -1694,7 +1775,8 @@ build_result_decl (tree fndecl)
tree result = DECL_RESULT (fndecl);
if (! result)
{
- result = build_decl (RESULT_DECL, NULL_TREE, restype);
+ result = build_decl (DECL_SOURCE_LOCATION (fndecl),
+ RESULT_DECL, NULL_TREE, restype);
DECL_ARTIFICIAL (result) = 1;
DECL_IGNORED_P (result) = 1;
DECL_CONTEXT (result) = fndecl;
@@ -1733,7 +1815,7 @@ start_java_method (tree fndecl)
tree parm_type = TREE_VALUE (tem);
gcc_assert (i < DECL_MAX_LOCALS (fndecl));
- parm_decl = build_decl (PARM_DECL, parm_name, parm_type);
+ parm_decl = build_decl (input_location, PARM_DECL, parm_name, parm_type);
DECL_CONTEXT (parm_decl) = fndecl;
if (targetm.calls.promote_prototypes (parm_type)
&& TYPE_PRECISION (parm_type) < TYPE_PRECISION (integer_type_node)
diff --git a/gcc/java/except.c b/gcc/java/except.c
index d163ba0e1b7..e97ed7755d9 100644
--- a/gcc/java/except.c
+++ b/gcc/java/except.c
@@ -393,7 +393,8 @@ prepare_eh_table_type (tree type)
name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
buf = (char *) alloca (strlen (name) + 5);
sprintf (buf, "%s_ref", name);
- decl = build_decl (VAR_DECL, get_identifier (buf), ptr_type_node);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), ptr_type_node);
TREE_STATIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
@@ -410,7 +411,8 @@ prepare_eh_table_type (tree type)
name = IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (utf8_ref, 0)));
buf = (char *) alloca (strlen (name) + 5);
sprintf (buf, "%s_ref", name);
- decl = build_decl (VAR_DECL, get_identifier (buf), utf8const_ptr_type);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), utf8const_ptr_type);
TREE_STATIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 858bc937d93..72ca77303ec 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -669,7 +669,7 @@ java_stack_swap (void)
flush_quick_stack ();
decl1 = find_stack_slot (stack_pointer - 1, type1);
decl2 = find_stack_slot (stack_pointer - 2, type2);
- temp = build_decl (VAR_DECL, NULL_TREE, type1);
+ temp = build_decl (input_location, VAR_DECL, NULL_TREE, type1);
java_add_local_var (temp);
java_add_stmt (build2 (MODIFY_EXPR, type1, temp, decl1));
java_add_stmt (build2 (MODIFY_EXPR, type2,
@@ -1192,7 +1192,7 @@ expand_java_arraystore (tree rhs_type_node)
MODIFY_EXPR to set the array element. */
access = build_java_arrayaccess (array, rhs_type_node, index);
- temp = build_decl (VAR_DECL, NULL_TREE,
+ temp = build_decl (input_location, VAR_DECL, NULL_TREE,
build_pointer_type (TREE_TYPE (access)));
java_add_local_var (temp);
java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (temp),
@@ -1332,7 +1332,7 @@ expand_load_internal (int index, tree type, int pc)
generated. To avoid this we create a new local and copy our
value into it. Then we push this new local on the stack.
Hopefully this all gets optimized out. */
- copy = build_decl (VAR_DECL, NULL_TREE, type);
+ copy = build_decl (input_location, VAR_DECL, NULL_TREE, type);
if ((INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type))
&& TREE_TYPE (copy) != TREE_TYPE (var))
var = convert (type, var);
@@ -1824,7 +1824,7 @@ tree
create_label_decl (tree name)
{
tree decl;
- decl = build_decl (LABEL_DECL, name,
+ decl = build_decl (input_location, LABEL_DECL, name,
TREE_TYPE (return_address_type_node));
DECL_CONTEXT (decl) = current_function_decl;
DECL_IGNORED_P (decl) = 1;
@@ -1907,7 +1907,7 @@ expand_java_switch (tree selector, int default_pc)
java_add_stmt (switch_expr);
x = build3 (CASE_LABEL_EXPR, void_type_node, NULL_TREE, NULL_TREE,
- create_artificial_label ());
+ create_artificial_label (input_location));
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
x = build1 (GOTO_EXPR, void_type_node, lookup_label (default_pc));
@@ -1924,7 +1924,7 @@ expand_java_add_case (tree switch_expr, int match, int target_pc)
value = build_int_cst (TREE_TYPE (switch_expr), match);
x = build3 (CASE_LABEL_EXPR, void_type_node, value, NULL_TREE,
- create_artificial_label ());
+ create_artificial_label (input_location));
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
x = build1 (GOTO_EXPR, void_type_node, lookup_label (target_pc));
@@ -2026,7 +2026,7 @@ build_class_init (tree clas, tree expr)
{
/* Build a declaration and mark it as a flag used to track
static class initializations. */
- decl = build_decl (VAR_DECL, NULL_TREE,
+ decl = build_decl (input_location, VAR_DECL, NULL_TREE,
boolean_type_node);
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
DECL_CONTEXT (decl) = current_function_decl;
@@ -2666,12 +2666,13 @@ build_jni_stub (tree method)
DECL_ARTIFICIAL (method) = 1;
DECL_EXTERNAL (method) = 0;
- env_var = build_decl (VAR_DECL, get_identifier ("env"), ptr_type_node);
+ env_var = build_decl (input_location,
+ VAR_DECL, get_identifier ("env"), ptr_type_node);
DECL_CONTEXT (env_var) = method;
if (TREE_TYPE (TREE_TYPE (method)) != void_type_node)
{
- res_var = build_decl (VAR_DECL, get_identifier ("res"),
+ res_var = build_decl (input_location, VAR_DECL, get_identifier ("res"),
TREE_TYPE (TREE_TYPE (method)));
DECL_CONTEXT (res_var) = method;
TREE_CHAIN (env_var) = res_var;
@@ -2745,7 +2746,8 @@ build_jni_stub (tree method)
garbage-collected. If it is, we end up using canonical types
with different uids for equivalent function types, and this in
turn causes utf8 identifiers and output order to vary. */
- meth_var = build_decl (VAR_DECL, get_identifier ("meth"), jni_func_type);
+ meth_var = build_decl (input_location,
+ VAR_DECL, get_identifier ("meth"), jni_func_type);
TREE_STATIC (meth_var) = 1;
TREE_PUBLIC (meth_var) = 0;
DECL_EXTERNAL (meth_var) = 0;
@@ -2971,7 +2973,8 @@ expand_java_field_op (int is_static, int is_putting, int field_ref_index)
}
else
{
- tree temp = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE (field_ref));
+ tree temp = build_decl (input_location,
+ VAR_DECL, NULL_TREE, TREE_TYPE (field_ref));
java_add_local_var (temp);
if (TREE_THIS_VOLATILE (field_decl))
@@ -3795,7 +3798,7 @@ force_evaluation_order (tree node)
tree
build_java_empty_stmt (void)
{
- tree t = build_empty_stmt ();
+ tree t = build_empty_stmt (input_location);
return t;
}
@@ -3832,7 +3835,7 @@ cache_cpool_data_ref (void)
{
tree cpool;
tree d = build_constant_data_ref (flag_indirect_classes);
- tree cpool_ptr = build_decl (VAR_DECL, NULL_TREE,
+ tree cpool_ptr = build_decl (input_location, VAR_DECL, NULL_TREE,
build_pointer_type (TREE_TYPE (d)));
java_add_local_var (cpool_ptr);
TREE_CONSTANT (cpool_ptr) = 1;
diff --git a/gcc/java/java-gimplify.c b/gcc/java/java-gimplify.c
index e2ad02b697a..c460e5b0941 100644
--- a/gcc/java/java-gimplify.c
+++ b/gcc/java/java-gimplify.c
@@ -163,7 +163,7 @@ java_gimplify_block (tree java_block)
/* Don't bother with empty blocks. */
if (! body)
- return build_empty_stmt ();
+ return build_empty_stmt (input_location);
if (IS_EMPTY_STMT (body))
return body;
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 9ab76606b46..98352a2eaf2 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -1435,15 +1435,15 @@ extern tree *type_map;
#define DECL_INNER_CLASS_LIST(NODE) DECL_INITIAL (TYPE_DECL_CHECK (NODE))
/* Add a FIELD_DECL to RECORD_TYPE RTYPE.
- The field has name NAME (a char*), and type FTYPE.
+ The field has name NAME (a char*), a type FTYPE, and a location of LOC.
Unless this is the first field, FIELD most hold the previous field.
FIELD is set to the newly created FIELD_DECL.
We set DECL_ARTIFICIAL so these fields get skipped by make_class_data
if compiling java.lang.Object or java.lang.Class. */
-#define PUSH_FIELD(RTYPE, FIELD, NAME, FTYPE) \
-{ tree _field = build_decl (FIELD_DECL, get_identifier ((NAME)), (FTYPE)); \
+#define PUSH_FIELD(LOC, RTYPE, FIELD, NAME, FTYPE) \
+{ tree _field = build_decl (LOC, FIELD_DECL, get_identifier ((NAME)), (FTYPE)); \
if (TYPE_FIELDS (RTYPE) == NULL_TREE) \
TYPE_FIELDS (RTYPE) = _field; \
else \
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index f28acb041cd..98c98c8bd90 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -1703,10 +1703,11 @@ java_emit_static_constructor (void)
tree name = get_identifier ("_Jv_global_static_constructor");
tree decl
- = build_decl (FUNCTION_DECL, name,
+ = build_decl (input_location, FUNCTION_DECL, name,
build_function_type (void_type_node, void_list_node));
- tree resdecl = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
+ tree resdecl = build_decl (input_location,
+ RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (resdecl) = 1;
DECL_RESULT (decl) = resdecl;
current_function_decl = decl;
@@ -1835,7 +1836,8 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
duplicate_class_warning (IDENTIFIER_POINTER (node));
else
{
- tree file_decl = build_decl (TRANSLATION_UNIT_DECL, node, NULL);
+ tree file_decl = build_decl (input_location,
+ TRANSLATION_UNIT_DECL, node, NULL);
TREE_CHAIN (file_decl) = current_file_list;
current_file_list = file_decl;
IS_A_COMMAND_LINE_FILENAME_P (node) = 1;
diff --git a/gcc/java/resource.c b/gcc/java/resource.c
index e6e50bab94a..550e1d505d8 100644
--- a/gcc/java/resource.c
+++ b/gcc/java/resource.c
@@ -59,9 +59,11 @@ compile_resource_data (const char *name, const char *buffer, int length)
data_type = build_prim_array_type (unsigned_byte_type_node,
strlen (name) + length);
rtype = make_node (RECORD_TYPE);
- PUSH_FIELD (rtype, field, "name_length", unsigned_int_type_node);
- PUSH_FIELD (rtype, field, "resource_length", unsigned_int_type_node);
- PUSH_FIELD (rtype, field, "data", data_type);
+ PUSH_FIELD (input_location,
+ rtype, field, "name_length", unsigned_int_type_node);
+ PUSH_FIELD (input_location,
+ rtype, field, "resource_length", unsigned_int_type_node);
+ PUSH_FIELD (input_location, rtype, field, "data", data_type);
FINISH_RECORD (rtype);
START_RECORD_CONSTRUCTOR (rinit, rtype);
PUSH_FIELD_VALUE (rinit, "name_length",
@@ -74,7 +76,8 @@ compile_resource_data (const char *name, const char *buffer, int length)
FINISH_RECORD_CONSTRUCTOR (rinit);
TREE_CONSTANT (rinit) = 1;
- decl = build_decl (VAR_DECL, java_mangle_resource_name (name), rtype);
+ decl = build_decl (input_location,
+ VAR_DECL, java_mangle_resource_name (name), rtype);
TREE_STATIC (decl) = 1;
TREE_PUBLIC (decl) = 1;
java_hide_decl (decl);
@@ -100,7 +103,8 @@ write_resource_constructor (tree *list_p)
return;
t = build_function_type_list (void_type_node, ptr_type_node, NULL);
- t = build_decl (FUNCTION_DECL, get_identifier ("_Jv_RegisterResource"), t);
+ t = build_decl (input_location,
+ FUNCTION_DECL, get_identifier ("_Jv_RegisterResource"), t);
TREE_PUBLIC (t) = 1;
DECL_EXTERNAL (t) = 1;
register_resource_fn = t;
diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c
index e812f31b829..c16976ca3b0 100644
--- a/gcc/java/typeck.c
+++ b/gcc/java/typeck.c
@@ -347,7 +347,7 @@ build_java_array_type (tree element_type, HOST_WIDE_INT length)
strcpy (suffix, "[]");
TYPE_NAME (t)
= TYPE_STUB_DECL (t)
- = build_decl (TYPE_DECL,
+ = build_decl (input_location, TYPE_DECL,
identifier_subst (el_name, "", '.', '.', suffix),
t);
TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (t)) = true;
@@ -360,7 +360,8 @@ build_java_array_type (tree element_type, HOST_WIDE_INT length)
TYPE_ARRAY_ELEMENT (t) = element_type;
/* Add length pseudo-field. */
- fld = build_decl (FIELD_DECL, get_identifier ("length"), int_type_node);
+ fld = build_decl (input_location,
+ FIELD_DECL, get_identifier ("length"), int_type_node);
TYPE_FIELDS (t) = fld;
DECL_CONTEXT (fld) = t;
FIELD_PUBLIC (fld) = 1;
@@ -368,7 +369,8 @@ build_java_array_type (tree element_type, HOST_WIDE_INT length)
TREE_READONLY (fld) = 1;
atype = build_prim_array_type (element_type, length);
- arfld = build_decl (FIELD_DECL, get_identifier ("data"), atype);
+ arfld = build_decl (input_location,
+ FIELD_DECL, get_identifier ("data"), atype);
DECL_CONTEXT (arfld) = t;
TREE_CHAIN (fld) = arfld;
DECL_ALIGN (arfld) = TYPE_ALIGN (element_type);
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 8579062e715..85d77a8856c 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -432,7 +432,7 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
pp_newline (context->printer);
if (s.file != NULL)
{
- if (flag_show_column && s.column != 0)
+ if (flag_show_column)
pp_printf (context->printer,
_(" inlined from %qs at %s:%d:%d"),
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
@@ -524,7 +524,7 @@ add_builtin_function_common (const char *name,
tree (*hook) (tree))
{
tree id = get_identifier (name);
- tree decl = build_decl (FUNCTION_DECL, id, type);
+ tree decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, id, type);
TREE_PUBLIC (decl) = 1;
DECL_EXTERNAL (decl) = 1;
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index 110c1a075a4..5aaa3b74722 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -1,3 +1,31 @@
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * objc-act.c (finish_var_decl): Pass location to finish_decl.
+ (objc_get_parm_info): Same.
+ (get_super_receiver): Same.
+ * objc-act.c (objc_build_component_ref): Pass location to
+ build_compound_ref.
+ (build_module_initializer_routine): Pass location to
+ c_end_compound_stmt.
+ (objc_generate_static_init_call): Pass location to build_stmt.
+ (build_typed_selector_reference): New location argument.
+ (build_selector_reference): Same.
+ (objc_substitute_decl): Pass location to build_array_ref.
+ (next_sjlj_build_try_catch_finally): Pass location to build_stmt.
+ (objc_begin_catch_clause): Same.
+ (objc_finish_try_stmt): Same.
+ (objc_finish_catch_clause): Pass location to c_end_compound_stmt.
+ (objc_build_throw_stmt): New argument.
+ (generate_shared_structures): Pass location to build_c_cast.
+ (objc_build_message_expr): Use local location.
+ (objc_finish_message_expr): Use input_location.
+ (build_objc_method_call): New argument.
+ (objc_build_selector_expr): Same.
+ (get_super_receiver): Pass location to build_c_cast,
+ build_modify_expr, build_compound_expr.
+ * objc-act.c: Add location to all calls to start_struct, build_decl,
+ finish_struct.
+
2009-06-09 Ian Lance Taylor <iant@google.com>
* objc-act.c (objc_gimplify_expr): Change return type to int.
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 41ed41ee5ba..0c91faa5363 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -151,7 +151,7 @@ static void finish_objc (void);
/* Code generation. */
static tree objc_build_constructor (tree, tree);
-static tree build_objc_method_call (int, tree, tree, tree, tree);
+static tree build_objc_method_call (location_t, int, tree, tree, tree, tree);
static tree get_proto_encoding (tree);
static tree lookup_interface (tree);
static tree objc_add_static_instance (tree, tree);
@@ -430,8 +430,8 @@ objc_start_struct (tree name)
{
gcc_assert (!objc_building_struct);
objc_building_struct = true;
- return start_struct (RECORD_TYPE, name, &objc_in_struct, &objc_struct_types,
- UNKNOWN_LOCATION);
+ return start_struct (input_location, RECORD_TYPE,
+ name, &objc_in_struct, &objc_struct_types);
}
/* Finish building a struct for objc. */
@@ -441,8 +441,8 @@ objc_finish_struct (tree type, tree fieldlist)
{
gcc_assert (objc_building_struct);
objc_building_struct = false;
- return finish_struct (type, fieldlist, NULL_TREE, objc_in_struct,
- objc_struct_types);
+ return finish_struct (input_location, type, fieldlist, NULL_TREE,
+ objc_in_struct, objc_struct_types);
}
/* Some platforms pass small structures through registers versus
@@ -826,7 +826,8 @@ objc_build_struct (tree klass, tree fields, tree super_name)
{
/* Prepend a packed variant of the base class into the layout. This
is necessary to preserve ObjC ABI compatibility. */
- tree base = build_decl (FIELD_DECL, NULL_TREE, super);
+ tree base = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, super);
tree field = TYPE_FIELDS (super);
while (field && TREE_CHAIN (field)
@@ -1287,7 +1288,7 @@ objc_build_component_ref (tree datum, tree component)
return finish_class_member_access_expr (datum, component, false,
tf_warning_or_error);
#else
- return build_component_ref (datum, component);
+ return build_component_ref (input_location, datum, component);
#endif
}
@@ -1482,7 +1483,8 @@ lookup_and_install_protocols (tree protocols)
static tree
create_field_decl (tree type, const char *name)
{
- return build_decl (FIELD_DECL, get_identifier (name), type);
+ return build_decl (input_location,
+ FIELD_DECL, get_identifier (name), type);
}
/* Create a global, static declaration for variable NAME of a given TYPE. The
@@ -1491,7 +1493,8 @@ create_field_decl (tree type, const char *name)
static tree
start_var_decl (tree type, const char *name)
{
- tree var = build_decl (VAR_DECL, get_identifier (name), type);
+ tree var = build_decl (input_location,
+ VAR_DECL, get_identifier (name), type);
TREE_STATIC (var) = 1;
DECL_INITIAL (var) = error_mark_node; /* A real initializer is coming... */
@@ -1510,7 +1513,7 @@ start_var_decl (tree type, const char *name)
static void
finish_var_decl (tree var, tree initializer)
{
- finish_decl (var, initializer, NULL_TREE, NULL_TREE);
+ finish_decl (var, input_location, initializer, NULL_TREE, NULL_TREE);
/* Ensure that the variable actually gets output. */
mark_decl_referenced (var);
/* Mark the decl to avoid "defined but not used" warning. */
@@ -1581,11 +1584,13 @@ synth_module_prologue (void)
/* Declare the 'id' and 'Class' typedefs. */
- type = lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ type = lang_hooks.decls.pushdecl (build_decl (input_location,
+ TYPE_DECL,
objc_object_name,
objc_object_type));
TREE_NO_WARNING (type) = 1;
- type = lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ type = lang_hooks.decls.pushdecl (build_decl (input_location,
+ TYPE_DECL,
objc_class_name,
objc_class_type));
TREE_NO_WARNING (type) = 1;
@@ -1843,11 +1848,14 @@ static tree
objc_build_internal_const_str_type (void)
{
tree type = (*lang_hooks.types.make_type) (RECORD_TYPE);
- tree fields = build_decl (FIELD_DECL, NULL_TREE, ptr_type_node);
- tree field = build_decl (FIELD_DECL, NULL_TREE, ptr_type_node);
+ tree fields = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, ptr_type_node);
+ tree field = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, ptr_type_node);
TREE_CHAIN (field) = fields; fields = field;
- field = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node);
+ field = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, unsigned_type_node);
TREE_CHAIN (field) = fields; fields = field;
/* NB: The finish_builtin_struct() routine expects FIELD_DECLs in
reverse order! */
@@ -1990,7 +1998,8 @@ objc_build_string_object (tree string)
= objc_add_static_instance (constructor, constant_string_type);
else
{
- var = build_decl (CONST_DECL, NULL, TREE_TYPE (constructor));
+ var = build_decl (input_location,
+ CONST_DECL, NULL, TREE_TYPE (constructor));
DECL_INITIAL (var) = constructor;
TREE_STATIC (var) = 1;
pushdecl_top_level (var);
@@ -2028,7 +2037,8 @@ objc_add_static_instance (tree constructor, tree class_decl)
}
sprintf (buf, "_OBJC_INSTANCE_%d", num_static_inst++);
- decl = build_decl (VAR_DECL, get_identifier (buf), class_decl);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), class_decl);
DECL_COMMON (decl) = 1;
TREE_STATIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
@@ -2371,7 +2381,8 @@ build_module_initializer_routine (void)
push_lang_context (lang_name_c); /* extern "C" */
#endif
- objc_push_parm (build_decl (PARM_DECL, NULL_TREE, void_type_node));
+ objc_push_parm (build_decl (input_location,
+ PARM_DECL, NULL_TREE, void_type_node));
objc_start_function (get_identifier (TAG_GNUINIT),
build_function_type (void_type_node,
OBJC_VOID_AT_END),
@@ -2379,12 +2390,13 @@ build_module_initializer_routine (void)
body = c_begin_compound_stmt (true);
add_stmt (build_function_call
- (execclass_decl,
+ (input_location,
+ execclass_decl,
build_tree_list
(NULL_TREE,
build_unary_op (input_location, ADDR_EXPR,
UOBJC_MODULES_decl, 0))));
- add_stmt (c_end_compound_stmt (body, true));
+ add_stmt (c_end_compound_stmt (input_location, body, true));
TREE_PUBLIC (current_function_decl) = 0;
@@ -2417,8 +2429,9 @@ objc_static_init_needed_p (void)
tree
objc_generate_static_init_call (tree ctors ATTRIBUTE_UNUSED)
{
- add_stmt (build_stmt (EXPR_STMT,
- build_function_call (GNU_INIT_decl, NULL_TREE)));
+ add_stmt (build_stmt (input_location, EXPR_STMT,
+ build_function_call (input_location,
+ GNU_INIT_decl, NULL_TREE)));
return ctors;
}
@@ -2647,10 +2660,11 @@ get_proto_encoding (tree proto)
}
/* sel_ref_chain is a list whose "value" fields will be instances of
- identifier_node that represent the selector. */
+ identifier_node that represent the selector. LOC is the location of
+ the @selector. */
static tree
-build_typed_selector_reference (tree ident, tree prototype)
+build_typed_selector_reference (location_t loc, tree ident, tree prototype)
{
tree *chain = &sel_ref_chain;
tree expr;
@@ -2668,16 +2682,15 @@ build_typed_selector_reference (tree ident, tree prototype)
*chain = tree_cons (prototype, ident, NULL_TREE);
return_at_index:
- expr = build_unary_op (input_location, ADDR_EXPR,
- build_array_ref (UOBJC_SELECTOR_TABLE_decl,
- build_int_cst (NULL_TREE, index),
- input_location),
+ expr = build_unary_op (loc, ADDR_EXPR,
+ build_array_ref (loc, UOBJC_SELECTOR_TABLE_decl,
+ build_int_cst (NULL_TREE, index)),
1);
return convert (objc_selector_type, expr);
}
static tree
-build_selector_reference (tree ident)
+build_selector_reference (location_t loc, tree ident)
{
tree *chain = &sel_ref_chain;
tree expr;
@@ -2688,9 +2701,8 @@ build_selector_reference (tree ident)
if (TREE_VALUE (*chain) == ident)
return (flag_next_runtime
? TREE_PURPOSE (*chain)
- : build_array_ref (UOBJC_SELECTOR_TABLE_decl,
- build_int_cst (NULL_TREE, index),
- input_location));
+ : build_array_ref (loc, UOBJC_SELECTOR_TABLE_decl,
+ build_int_cst (NULL_TREE, index)));
index++;
chain = &TREE_CHAIN (*chain);
@@ -2702,9 +2714,8 @@ build_selector_reference (tree ident)
return (flag_next_runtime
? expr
- : build_array_ref (UOBJC_SELECTOR_TABLE_decl,
- build_int_cst (NULL_TREE, index),
- input_location));
+ : build_array_ref (loc, UOBJC_SELECTOR_TABLE_decl,
+ build_int_cst (NULL_TREE, index)));
}
static GTY(()) int class_reference_idx;
@@ -2816,7 +2827,7 @@ objc_get_class_reference (tree ident)
IDENTIFIER_POINTER (ident)));
assemble_external (objc_get_class_decl);
- return build_function_call (objc_get_class_decl, params);
+ return build_function_call (input_location, objc_get_class_decl, params);
}
}
@@ -2884,7 +2895,8 @@ build_objc_string_decl (enum string_section section)
ident = get_identifier (buf);
- decl = build_decl (VAR_DECL, ident, build_array_type (char_type_node, 0));
+ decl = build_decl (input_location,
+ VAR_DECL, ident, build_array_type (char_type_node, 0));
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 0;
TREE_USED (decl) = 1;
@@ -2924,7 +2936,8 @@ objc_declare_alias (tree alias_ident, tree class_ident)
push_lang_context (lang_name_c); /* extern "C" */
#endif
lang_hooks.decls.pushdecl (build_decl
- (TYPE_DECL,
+ (input_location,
+ TYPE_DECL,
alias_ident,
xref_tag (RECORD_TYPE, underlying_class)));
#ifdef OBJCPLUS
@@ -3088,11 +3101,11 @@ objc_substitute_decl (tree expr, tree oldexpr, tree newexpr)
newexpr),
DECL_NAME (TREE_OPERAND (expr, 1)));
case ARRAY_REF:
- return build_array_ref (objc_substitute_decl (TREE_OPERAND (expr, 0),
+ return build_array_ref (input_location,
+ objc_substitute_decl (TREE_OPERAND (expr, 0),
oldexpr,
newexpr),
- TREE_OPERAND (expr, 1),
- input_location);
+ TREE_OPERAND (expr, 1));
case INDIRECT_REF:
return build_indirect_ref (input_location,
objc_substitute_decl (TREE_OPERAND (expr, 0),
@@ -3129,7 +3142,7 @@ objc_build_ivar_assignment (tree outervar, tree lhs, tree rhs)
NULL_TREE)));
assemble_external (func);
- return build_function_call (func, func_params);
+ return build_function_call (input_location, func, func_params);
}
static tree
@@ -3142,7 +3155,8 @@ objc_build_global_assignment (tree lhs, tree rhs)
NULL_TREE));
assemble_external (objc_assign_global_decl);
- return build_function_call (objc_assign_global_decl, func_params);
+ return build_function_call (input_location,
+ objc_assign_global_decl, func_params);
}
static tree
@@ -3155,7 +3169,8 @@ objc_build_strong_cast_assignment (tree lhs, tree rhs)
NULL_TREE));
assemble_external (objc_assign_strong_cast_decl);
- return build_function_call (objc_assign_strong_cast_decl, func_params);
+ return build_function_call (input_location,
+ objc_assign_strong_cast_decl, func_params);
}
static int
@@ -3422,7 +3437,8 @@ objc_create_temporary_var (tree type)
{
tree decl;
- decl = build_decl (VAR_DECL, NULL_TREE, type);
+ decl = build_decl (input_location,
+ VAR_DECL, NULL_TREE, type);
TREE_USED (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
@@ -3542,7 +3558,8 @@ next_sjlj_build_try_exit (void)
tree t;
t = build_fold_addr_expr (cur_try_context->stack_decl);
t = tree_cons (NULL, t, NULL);
- t = build_function_call (objc_exception_try_exit_decl, t);
+ t = build_function_call (input_location,
+ objc_exception_try_exit_decl, t);
return t;
}
@@ -3562,7 +3579,8 @@ next_sjlj_build_enter_and_setjmp (void)
t = build_fold_addr_expr (cur_try_context->stack_decl);
t = tree_cons (NULL, t, NULL);
- enter = build_function_call (objc_exception_try_enter_decl, t);
+ enter = build_function_call (input_location,
+ objc_exception_try_enter_decl, t);
t = objc_build_component_ref (cur_try_context->stack_decl,
get_identifier ("buf"));
@@ -3577,7 +3595,8 @@ next_sjlj_build_enter_and_setjmp (void)
t = convert (ptr_type_node, t);
#endif
t = tree_cons (NULL, t, NULL);
- sj = build_function_call (objc_setjmp_decl, t);
+ sj = build_function_call (input_location,
+ objc_setjmp_decl, t);
cond = build2 (COMPOUND_EXPR, TREE_TYPE (sj), enter, sj);
cond = c_common_truthvalue_conversion (input_location, cond);
@@ -3596,7 +3615,8 @@ next_sjlj_build_exc_extract (tree decl)
t = build_fold_addr_expr (cur_try_context->stack_decl);
t = tree_cons (NULL, t, NULL);
- t = build_function_call (objc_exception_extract_decl, t);
+ t = build_function_call (input_location,
+ objc_exception_extract_decl, t);
t = convert (TREE_TYPE (decl), t);
t = build2 (MODIFY_EXPR, void_type_node, decl, t);
@@ -3646,7 +3666,8 @@ next_sjlj_build_catch_list (void)
args = tree_cons (NULL, cur_try_context->caught_decl, NULL);
t = objc_get_class_reference (OBJC_TYPE_NAME (TREE_TYPE (type)));
args = tree_cons (NULL, t, args);
- t = build_function_call (objc_exception_match_decl, args);
+ t = build_function_call (input_location,
+ objc_exception_match_decl, args);
cond = c_common_truthvalue_conversion (input_location, t);
}
t = build3 (COND_EXPR, void_type_node, cond, body, NULL);
@@ -3744,7 +3765,7 @@ next_sjlj_build_try_catch_finally (void)
if (cur_try_context->catch_list)
{
tree caught_decl = objc_build_exc_ptr ();
- catch_seq = build_stmt (BIND_EXPR, caught_decl, NULL, NULL);
+ catch_seq = build_stmt (input_location, BIND_EXPR, caught_decl, NULL, NULL);
TREE_SIDE_EFFECTS (catch_seq) = 1;
t = next_sjlj_build_exc_extract (caught_decl);
@@ -3768,7 +3789,7 @@ next_sjlj_build_try_catch_finally (void)
/* Build the complete FINALLY statement list. */
t = next_sjlj_build_try_exit ();
- t = build_stmt (COND_EXPR,
+ t = build_stmt (input_location, COND_EXPR,
c_common_truthvalue_conversion
(input_location, rethrow_decl),
NULL, t);
@@ -3779,8 +3800,9 @@ next_sjlj_build_try_catch_finally (void)
&TREE_OPERAND (try_fin, 1));
t = tree_cons (NULL, rethrow_decl, NULL);
- t = build_function_call (objc_exception_throw_decl, t);
- t = build_stmt (COND_EXPR,
+ t = build_function_call (input_location,
+ objc_exception_throw_decl, t);
+ t = build_stmt (input_location, COND_EXPR,
c_common_truthvalue_conversion (input_location,
rethrow_decl),
t, NULL);
@@ -3822,7 +3844,8 @@ objc_begin_catch_clause (tree decl)
compound = c_begin_compound_stmt (true);
/* The parser passed in a PARM_DECL, but what we really want is a VAR_DECL. */
- decl = build_decl (VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+ decl = build_decl (input_location,
+ VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
lang_hooks.decls.pushdecl (decl);
/* Since a decl is required here by syntax, don't warn if its unused. */
@@ -3865,7 +3888,7 @@ objc_begin_catch_clause (tree decl)
/* Record the data for the catch in the try context so that we can
finalize it later. */
- t = build_stmt (CATCH_EXPR, type, compound);
+ t = build_stmt (input_location, CATCH_EXPR, type, compound);
cur_try_context->current_catch = t;
/* Initialize the decl from the EXC_PTR_EXPR we get from the runtime. */
@@ -3885,7 +3908,7 @@ objc_finish_catch_clause (void)
cur_try_context->current_catch = NULL;
cur_try_context->end_catch_locus = input_location;
- CATCH_BODY (c) = c_end_compound_stmt (CATCH_BODY (c), 1);
+ CATCH_BODY (c) = c_end_compound_stmt (input_location, CATCH_BODY (c), 1);
append_to_statement_list (c, &cur_try_context->catch_list);
}
@@ -3930,12 +3953,12 @@ objc_finish_try_stmt (void)
stmt = c->try_body;
if (c->catch_list)
{
- stmt = build_stmt (TRY_CATCH_EXPR, stmt, c->catch_list);
+ stmt = build_stmt (input_location, TRY_CATCH_EXPR, stmt, c->catch_list);
SET_EXPR_LOCATION (stmt, cur_try_context->try_locus);
}
if (c->finally_body)
{
- stmt = build_stmt (TRY_FINALLY_EXPR, stmt, c->finally_body);
+ stmt = build_stmt (input_location, TRY_FINALLY_EXPR, stmt, c->finally_body);
SET_EXPR_LOCATION (stmt, cur_try_context->try_locus);
}
}
@@ -3947,7 +3970,7 @@ objc_finish_try_stmt (void)
}
tree
-objc_build_throw_stmt (tree throw_expr)
+objc_build_throw_stmt (location_t loc, tree throw_expr)
{
tree args;
@@ -3960,7 +3983,7 @@ objc_build_throw_stmt (tree throw_expr)
if (cur_try_context == NULL
|| cur_try_context->current_catch == NULL)
{
- error ("%<@throw%> (rethrow) used outside of a @catch block");
+ error_at (loc, "%<@throw%> (rethrow) used outside of a @catch block");
return NULL_TREE;
}
@@ -3972,7 +3995,8 @@ objc_build_throw_stmt (tree throw_expr)
/* A throw is just a call to the runtime throw function with the
object as a parameter. */
args = tree_cons (NULL, throw_expr, NULL);
- return add_stmt (build_function_call (objc_exception_throw_decl, args));
+ return add_stmt (build_function_call (loc,
+ objc_exception_throw_decl, args));
}
tree
@@ -3983,13 +4007,15 @@ objc_build_synchronized (location_t start_locus, tree mutex, tree body)
/* First lock the mutex. */
mutex = save_expr (mutex);
args = tree_cons (NULL, mutex, NULL);
- call = build_function_call (objc_sync_enter_decl, args);
+ call = build_function_call (input_location,
+ objc_sync_enter_decl, args);
SET_EXPR_LOCATION (call, start_locus);
add_stmt (call);
/* Build the mutex unlock. */
args = tree_cons (NULL, mutex, NULL);
- call = build_function_call (objc_sync_exit_decl, args);
+ call = build_function_call (input_location,
+ objc_sync_exit_decl, args);
SET_EXPR_LOCATION (call, input_location);
/* Put the that and the body in a TRY_FINALLY. */
@@ -5792,13 +5818,14 @@ generate_shared_structures (int cls_flags)
if (my_super_id)
{
super_expr = add_objc_string (my_super_id, class_names);
- super_expr = build_c_cast (cast_type, super_expr); /* cast! */
+ super_expr = build_c_cast (input_location,
+ cast_type, super_expr); /* cast! */
}
else
super_expr = build_int_cst (NULL_TREE, 0);
root_expr = add_objc_string (my_root_id, class_names);
- root_expr = build_c_cast (cast_type, root_expr); /* cast! */
+ root_expr = build_c_cast (input_location, cast_type, root_expr); /* cast! */
if (CLASS_PROTOCOL_LIST (implementation_template))
{
@@ -6234,6 +6261,7 @@ tree
objc_build_message_expr (tree mess)
{
tree receiver = TREE_PURPOSE (mess);
+ location_t loc;
tree sel_name;
#ifdef OBJCPLUS
tree args = TREE_PURPOSE (TREE_VALUE (mess));
@@ -6245,6 +6273,11 @@ objc_build_message_expr (tree mess)
if (TREE_CODE (receiver) == ERROR_MARK)
return error_mark_node;
+ if (CAN_HAVE_LOCATION_P (receiver))
+ loc = EXPR_LOCATION (receiver);
+ else
+ loc = input_location;
+
/* Obtain the full selector name. */
if (TREE_CODE (args) == IDENTIFIER_NODE)
/* A unary selector. */
@@ -6501,9 +6534,12 @@ objc_finish_message_expr (tree receiver, tree sel_name, tree method_params)
if (!warn_missing_methods)
{
- warning (0, "(Messages without a matching method signature");
- warning (0, "will be assumed to return %<id%> and accept");
- warning (0, "%<...%> as arguments.)");
+ warning_at (input_location,
+ 0, "(Messages without a matching method signature");
+ warning_at (input_location,
+ 0, "will be assumed to return %<id%> and accept");
+ warning_at (input_location,
+ 0, "%<...%> as arguments.)");
warn_missing_methods = true;
}
}
@@ -6515,11 +6551,12 @@ objc_finish_message_expr (tree receiver, tree sel_name, tree method_params)
These are the object itself and the selector. */
if (flag_typed_selectors)
- selector = build_typed_selector_reference (sel_name, method_prototype);
+ selector = build_typed_selector_reference (input_location,
+ sel_name, method_prototype);
else
- selector = build_selector_reference (sel_name);
+ selector = build_selector_reference (input_location, sel_name);
- retval = build_objc_method_call (super, method_prototype,
+ retval = build_objc_method_call (input_location, super, method_prototype,
receiver,
selector, method_params);
@@ -6532,11 +6569,12 @@ objc_finish_message_expr (tree receiver, tree sel_name, tree method_params)
looking up the method on object LOOKUP_OBJECT (often same as OBJECT),
assuming the method has prototype METHOD_PROTOTYPE.
(That is an INSTANCE_METHOD_DECL or CLASS_METHOD_DECL.)
+ LOC is the location of the expression to build.
Use METHOD_PARAMS as list of args to pass to the method.
If SUPER_FLAG is nonzero, we look up the superclass's method. */
static tree
-build_objc_method_call (int super_flag, tree method_prototype,
+build_objc_method_call (location_t loc, int super_flag, tree method_prototype,
tree lookup_object, tree selector,
tree method_params)
{
@@ -6563,7 +6601,7 @@ build_objc_method_call (int super_flag, tree method_prototype,
(method_prototype, METHOD_REF, super_flag)));
tree method, t;
- lookup_object = build_c_cast (rcv_p, lookup_object);
+ lookup_object = build_c_cast (loc, rcv_p, lookup_object);
/* Use SAVE_EXPR to avoid evaluating the receiver twice. */
lookup_object = save_expr (lookup_object);
@@ -6599,7 +6637,8 @@ build_objc_method_call (int super_flag, tree method_prototype,
t = tree_cons (NULL_TREE, selector, NULL_TREE);
t = tree_cons (NULL_TREE, lookup_object, t);
- method = build_function_call (sender, t);
+ method = build_function_call (loc,
+ sender, t);
/* Pass the object to the method. */
method_params = tree_cons (NULL_TREE, object,
@@ -6610,7 +6649,8 @@ build_objc_method_call (int super_flag, tree method_prototype,
/* ??? Selector is not at this point something we can use inside
the compiler itself. Set it to garbage for the nonce. */
t = build3 (OBJ_TYPE_REF, sender_cast, method, lookup_object, size_zero_node);
- return build_function_call (t, method_params);
+ return build_function_call (loc,
+ t, method_params);
}
static void
@@ -6701,9 +6741,10 @@ objc_build_protocol_expr (tree protoname)
/* This function is called by the parser when a @selector() expression
is found, in order to compile it. It is only called by the parser
- and only to compile a @selector(). */
+ and only to compile a @selector(). LOC is the location of the
+ @selector. */
tree
-objc_build_selector_expr (tree selnamelist)
+objc_build_selector_expr (location_t loc, tree selnamelist)
{
tree selname;
@@ -6743,9 +6784,9 @@ objc_build_selector_expr (tree selnamelist)
if (flag_typed_selectors)
- return build_typed_selector_reference (selname, 0);
+ return build_typed_selector_reference (loc, selname, 0);
else
- return build_selector_reference (selname);
+ return build_selector_reference (loc, selname);
}
tree
@@ -8363,7 +8404,7 @@ objc_get_parm_info (int have_ellipsis)
TREE_CHAIN (parm_info) = NULL_TREE;
parm_info = pushdecl (parm_info);
- finish_decl (parm_info, NULL_TREE, NULL_TREE, NULL_TREE);
+ finish_decl (parm_info, input_location, NULL_TREE, NULL_TREE, NULL_TREE);
parm_info = next;
}
arg_info = get_parm_info (have_ellipsis);
@@ -8391,10 +8432,12 @@ synth_self_and_ucmd_args (void)
self_type = objc_object_type;
/* id self; */
- objc_push_parm (build_decl (PARM_DECL, self_id, self_type));
+ objc_push_parm (build_decl (input_location,
+ PARM_DECL, self_id, self_type));
/* SEL _cmd; */
- objc_push_parm (build_decl (PARM_DECL, ucmd_id, objc_selector_type));
+ objc_push_parm (build_decl (input_location,
+ PARM_DECL, ucmd_id, objc_selector_type));
}
/* Transform an Objective-C method definition into a static C function
@@ -8434,7 +8477,8 @@ start_method_def (tree method)
{
tree type = TREE_VALUE (TREE_TYPE (parmlist)), parm;
- parm = build_decl (PARM_DECL, KEYWORD_ARG_NAME (parmlist), type);
+ parm = build_decl (input_location,
+ PARM_DECL, KEYWORD_ARG_NAME (parmlist), type);
objc_push_parm (parm);
parmlist = TREE_CHAIN (parmlist);
}
@@ -8576,7 +8620,8 @@ objc_start_function (tree name, tree type, tree attrs,
#endif
)
{
- tree fndecl = build_decl (FUNCTION_DECL, name, type);
+ tree fndecl = build_decl (input_location,
+ FUNCTION_DECL, name, type);
#ifdef OBJCPLUS
DECL_ARGUMENTS (fndecl) = params;
@@ -8612,7 +8657,8 @@ objc_start_function (tree name, tree type, tree attrs,
push_scope ();
declare_parm_level ();
DECL_RESULT (current_function_decl)
- = build_decl (RESULT_DECL, NULL_TREE,
+ = build_decl (input_location,
+ RESULT_DECL, NULL_TREE,
TREE_TYPE (TREE_TYPE (current_function_decl)));
DECL_ARTIFICIAL (DECL_RESULT (current_function_decl)) = 1;
DECL_IGNORED_P (DECL_RESULT (current_function_decl)) = 1;
@@ -8749,19 +8795,22 @@ get_super_receiver (void)
if (!UOBJC_SUPER_decl)
{
- UOBJC_SUPER_decl = build_decl (VAR_DECL, get_identifier (TAG_SUPER),
+ UOBJC_SUPER_decl = build_decl (input_location,
+ VAR_DECL, get_identifier (TAG_SUPER),
objc_super_template);
/* This prevents `unused variable' warnings when compiling with -Wall. */
TREE_USED (UOBJC_SUPER_decl) = 1;
lang_hooks.decls.pushdecl (UOBJC_SUPER_decl);
- finish_decl (UOBJC_SUPER_decl, NULL_TREE, NULL_TREE, NULL_TREE);
+ finish_decl (UOBJC_SUPER_decl, input_location, NULL_TREE, NULL_TREE,
+ NULL_TREE);
UOBJC_SUPER_scope = objc_get_current_scope ();
}
/* Set receiver to self. */
super_expr = objc_build_component_ref (UOBJC_SUPER_decl, self_id);
super_expr = build_modify_expr (input_location, super_expr, NULL_TREE,
- NOP_EXPR, self_decl, NULL_TREE);
+ NOP_EXPR, input_location, self_decl,
+ NULL_TREE);
super_expr_list = super_expr;
/* Set class to begin searching. */
@@ -8775,6 +8824,7 @@ get_super_receiver (void)
super_expr = build_modify_expr (input_location, super_expr,
NULL_TREE, NOP_EXPR,
+ input_location,
((TREE_CODE (objc_method_context)
== INSTANCE_METHOD_DECL)
? ucls_super_ref
@@ -8807,7 +8857,8 @@ get_super_receiver (void)
super_class
= build_indirect_ref
(input_location,
- build_c_cast (build_pointer_type (objc_class_type),
+ build_c_cast (input_location,
+ build_pointer_type (objc_class_type),
super_class), "unary *");
}
else
@@ -8818,7 +8869,8 @@ get_super_receiver (void)
assemble_external (super_class);
super_class
= build_function_call
- (super_class,
+ (input_location,
+ super_class,
build_tree_list
(NULL_TREE,
my_build_string_pointer
@@ -8829,16 +8881,20 @@ get_super_receiver (void)
super_expr
= build_modify_expr (input_location, super_expr, NULL_TREE,
NOP_EXPR,
- build_c_cast (TREE_TYPE (super_expr),
+ input_location,
+ build_c_cast (input_location,
+ TREE_TYPE (super_expr),
super_class),
NULL_TREE);
}
- super_expr_list = build_compound_expr (super_expr_list, super_expr);
+ super_expr_list = build_compound_expr (input_location,
+ super_expr_list, super_expr);
super_expr = build_unary_op (input_location,
ADDR_EXPR, UOBJC_SUPER_decl, 0);
- super_expr_list = build_compound_expr (super_expr_list, super_expr);
+ super_expr_list = build_compound_expr (input_location,
+ super_expr_list, super_expr);
return super_expr_list;
}
@@ -9350,7 +9406,8 @@ handle_class_ref (tree chain)
#endif
/* Make a decl for this name, so we can use its address in a tree. */
- decl = build_decl (VAR_DECL, get_identifier (string), char_type_node);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (string), char_type_node);
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
@@ -9361,7 +9418,8 @@ handle_class_ref (tree chain)
sprintf (string, "%sobjc_class_ref_%s",
(flag_next_runtime ? "." : "__"), name);
exp = build1 (ADDR_EXPR, string_type_node, decl);
- decl = build_decl (VAR_DECL, get_identifier (string), string_type_node);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (string), string_type_node);
DECL_INITIAL (decl) = exp;
TREE_STATIC (decl) = 1;
TREE_USED (decl) = 1;
@@ -9421,7 +9479,8 @@ handle_impent (struct imp_entry *impent)
tree decl, init;
init = build_int_cst (c_common_type_for_size (BITS_PER_WORD, 1), 0);
- decl = build_decl (VAR_DECL, get_identifier (string), TREE_TYPE (init));
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (string), TREE_TYPE (init));
TREE_PUBLIC (decl) = 1;
TREE_READONLY (decl) = 1;
TREE_USED (decl) = 1;
diff --git a/gcc/objcp/ChangeLog b/gcc/objcp/ChangeLog
index 12b93aac710..fcb4a6419be 100644
--- a/gcc/objcp/ChangeLog
+++ b/gcc/objcp/ChangeLog
@@ -1,3 +1,9 @@
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * objcp-decl.h (c_end_compound_stmt): New argument.
+ * objcp-decl.c (objcp_start_struct): Add argument.
+ (objcp_finish_struct): Same.
+
2009-06-03 Ian Lance Taylor <iant@google.com>
* Make-lang.in (cc1objplus-checksum.o): Depend upon $(CONFIG_H)
diff --git a/gcc/objcp/objcp-decl.c b/gcc/objcp/objcp-decl.c
index 12a73c1272a..379a69c2bb4 100644
--- a/gcc/objcp/objcp-decl.c
+++ b/gcc/objcp/objcp-decl.c
@@ -44,7 +44,8 @@ along with GCC; see the file COPYING3. If not see
/* Hacks to simulate start_struct() and finish_struct(). */
tree
-objcp_start_struct (enum tree_code code ATTRIBUTE_UNUSED, tree name)
+objcp_start_struct (location_t loc ATTRIBUTE_UNUSED,
+ enum tree_code code ATTRIBUTE_UNUSED, tree name)
{
tree s;
/* The idea here is to mimic the actions that the C++ parser takes when
@@ -62,7 +63,8 @@ objcp_start_struct (enum tree_code code ATTRIBUTE_UNUSED, tree name)
}
tree
-objcp_finish_struct (tree t, tree fieldlist, tree attributes)
+objcp_finish_struct (location_t loc ATTRIBUTE_UNUSED,
+ tree t, tree fieldlist, tree attributes)
{
tree field, next_field;
diff --git a/gcc/objcp/objcp-decl.h b/gcc/objcp/objcp-decl.h
index 3f6c4321e7f..e335149e0e5 100644
--- a/gcc/objcp/objcp-decl.h
+++ b/gcc/objcp/objcp-decl.h
@@ -23,8 +23,8 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_OBJCP_DECL_H
#define GCC_OBJCP_DECL_H
-extern tree objcp_start_struct (enum tree_code, tree);
-extern tree objcp_finish_struct (tree, tree, tree);
+extern tree objcp_start_struct (location_t, enum tree_code, tree);
+extern tree objcp_finish_struct (location_t, tree, tree, tree);
extern void objcp_finish_function (void);
extern tree objcp_build_function_call (tree, tree);
extern tree objcp_xref_tag (enum tree_code, tree);
@@ -49,7 +49,7 @@ extern tree objcp_end_compound_stmt (tree, int);
objcp_comptypes (type1, type2)
#define c_begin_compound_stmt(flags) \
objcp_begin_compound_stmt (flags)
-#define c_end_compound_stmt(stmt, flags) \
+#define c_end_compound_stmt(loc, stmt, flags) \
objcp_end_compound_stmt (stmt, flags)
#undef OBJC_TYPE_NAME
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index e1fb7231c3e..e8b2b4dd52e 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -807,7 +807,7 @@ use_pointer_for_field (tree decl, omp_context *shared_ctx)
tree
copy_var_decl (tree var, tree name, tree type)
{
- tree copy = build_decl (VAR_DECL, name, type);
+ tree copy = build_decl (DECL_SOURCE_LOCATION (var), VAR_DECL, name, type);
TREE_ADDRESSABLE (copy) = TREE_ADDRESSABLE (var);
TREE_THIS_VOLATILE (copy) = TREE_THIS_VOLATILE (var);
@@ -815,7 +815,6 @@ copy_var_decl (tree var, tree name, tree type)
DECL_ARTIFICIAL (copy) = DECL_ARTIFICIAL (var);
DECL_IGNORED_P (copy) = DECL_IGNORED_P (var);
DECL_CONTEXT (copy) = DECL_CONTEXT (var);
- DECL_SOURCE_LOCATION (copy) = DECL_SOURCE_LOCATION (var);
TREE_USED (copy) = 1;
DECL_SEEN_IN_BIND_EXPR_P (copy) = 1;
@@ -928,7 +927,8 @@ install_var_field (tree var, bool by_ref, int mask, omp_context *ctx)
else if ((mask & 3) == 1 && is_reference (var))
type = TREE_TYPE (type);
- field = build_decl (FIELD_DECL, DECL_NAME (var), type);
+ field = build_decl (DECL_SOURCE_LOCATION (var),
+ FIELD_DECL, DECL_NAME (var), type);
/* Remember what variable this field was created for. This does have a
side effect of making dwarf2out ignore this member, so for helpful
@@ -948,7 +948,8 @@ install_var_field (tree var, bool by_ref, int mask, omp_context *ctx)
insert_field_into_struct (ctx->record_type, field);
if (ctx->srecord_type)
{
- sfield = build_decl (FIELD_DECL, DECL_NAME (var), type);
+ sfield = build_decl (DECL_SOURCE_LOCATION (var),
+ FIELD_DECL, DECL_NAME (var), type);
DECL_ABSTRACT_ORIGIN (sfield) = var;
DECL_ALIGN (sfield) = DECL_ALIGN (field);
DECL_USER_ALIGN (sfield) = DECL_USER_ALIGN (field);
@@ -966,7 +967,8 @@ install_var_field (tree var, bool by_ref, int mask, omp_context *ctx)
ctx->sfield_map = splay_tree_new (splay_tree_compare_pointers, 0, 0);
for (t = TYPE_FIELDS (ctx->record_type); t ; t = TREE_CHAIN (t))
{
- sfield = build_decl (FIELD_DECL, DECL_NAME (t), TREE_TYPE (t));
+ sfield = build_decl (DECL_SOURCE_LOCATION (var),
+ FIELD_DECL, DECL_NAME (t), TREE_TYPE (t));
DECL_ABSTRACT_ORIGIN (sfield) = DECL_ABSTRACT_ORIGIN (t);
insert_field_into_struct (ctx->srecord_type, sfield);
splay_tree_insert (ctx->sfield_map,
@@ -1043,7 +1045,7 @@ omp_copy_decl (tree var, copy_body_data *cb)
if (TREE_CODE (var) == LABEL_DECL)
{
- new_var = create_artificial_label ();
+ new_var = create_artificial_label (DECL_SOURCE_LOCATION (var));
DECL_CONTEXT (new_var) = current_function_decl;
insert_decl_map (&ctx->cb, var, new_var);
return new_var;
@@ -1309,7 +1311,8 @@ fixup_child_record_type (omp_context *ctx)
type = lang_hooks.types.make_type (RECORD_TYPE);
name = DECL_NAME (TYPE_NAME (ctx->record_type));
- name = build_decl (TYPE_DECL, name, type);
+ name = build_decl (DECL_SOURCE_LOCATION (ctx->receiver_decl),
+ TYPE_DECL, name, type);
TYPE_NAME (type) = name;
for (f = TYPE_FIELDS (ctx->record_type); f ; f = TREE_CHAIN (f))
@@ -1555,7 +1558,8 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
else
type = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
- decl = build_decl (FUNCTION_DECL, name, type);
+ decl = build_decl (gimple_location (ctx->stmt),
+ FUNCTION_DECL, name, type);
decl = lang_hooks.decls.pushdecl (decl);
if (!task_copy)
@@ -1573,13 +1577,15 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
DECL_CONTEXT (decl) = NULL_TREE;
DECL_INITIAL (decl) = make_node (BLOCK);
- t = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
+ t = build_decl (DECL_SOURCE_LOCATION (decl),
+ RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_IGNORED_P (t) = 1;
DECL_CONTEXT (t) = decl;
DECL_RESULT (decl) = t;
- t = build_decl (PARM_DECL, get_identifier (".omp_data_i"), ptr_type_node);
+ t = build_decl (DECL_SOURCE_LOCATION (decl),
+ PARM_DECL, get_identifier (".omp_data_i"), ptr_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_ARG_TYPE (t) = ptr_type_node;
DECL_CONTEXT (t) = current_function_decl;
@@ -1589,7 +1595,8 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
ctx->receiver_decl = t;
else
{
- t = build_decl (PARM_DECL, get_identifier (".omp_data_o"),
+ t = build_decl (DECL_SOURCE_LOCATION (decl),
+ PARM_DECL, get_identifier (".omp_data_o"),
ptr_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_ARG_TYPE (t) = ptr_type_node;
@@ -1604,7 +1611,6 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
allocate_struct_function clobbers CFUN, so we need to restore
it afterward. */
push_struct_function (decl);
- DECL_SOURCE_LOCATION (decl) = gimple_location (ctx->stmt);
cfun->function_end_locus = gimple_location (ctx->stmt);
pop_cfun ();
}
@@ -1637,7 +1643,8 @@ scan_omp_parallel (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
ctx->default_kind = OMP_CLAUSE_DEFAULT_SHARED;
ctx->record_type = lang_hooks.types.make_type (RECORD_TYPE);
name = create_tmp_var_name (".omp_data_s");
- name = build_decl (TYPE_DECL, name, ctx->record_type);
+ name = build_decl (gimple_location (stmt),
+ TYPE_DECL, name, ctx->record_type);
TYPE_NAME (ctx->record_type) = name;
create_omp_child_function (ctx, false);
gimple_omp_parallel_set_child_fn (stmt, ctx->cb.dst_fn);
@@ -1678,7 +1685,8 @@ scan_omp_task (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
ctx->default_kind = OMP_CLAUSE_DEFAULT_SHARED;
ctx->record_type = lang_hooks.types.make_type (RECORD_TYPE);
name = create_tmp_var_name (".omp_data_s");
- name = build_decl (TYPE_DECL, name, ctx->record_type);
+ name = build_decl (gimple_location (stmt),
+ TYPE_DECL, name, ctx->record_type);
TYPE_NAME (ctx->record_type) = name;
create_omp_child_function (ctx, false);
gimple_omp_task_set_child_fn (stmt, ctx->cb.dst_fn);
@@ -1688,7 +1696,8 @@ scan_omp_task (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
if (ctx->srecord_type)
{
name = create_tmp_var_name (".omp_data_a");
- name = build_decl (TYPE_DECL, name, ctx->srecord_type);
+ name = build_decl (gimple_location (stmt),
+ TYPE_DECL, name, ctx->srecord_type);
TYPE_NAME (ctx->srecord_type) = name;
create_omp_child_function (ctx, true);
}
@@ -1781,7 +1790,8 @@ scan_omp_single (gimple stmt, omp_context *outer_ctx)
ctx->field_map = splay_tree_new (splay_tree_compare_pointers, 0, 0);
ctx->record_type = lang_hooks.types.make_type (RECORD_TYPE);
name = create_tmp_var_name (".omp_copy_s");
- name = build_decl (TYPE_DECL, name, ctx->record_type);
+ name = build_decl (gimple_location (stmt),
+ TYPE_DECL, name, ctx->record_type);
TYPE_NAME (ctx->record_type) = name;
scan_sharing_clauses (gimple_omp_single_clauses (stmt), ctx);
@@ -2518,8 +2528,8 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list,
gimple stmt;
tree label_true, arm1, arm2;
- label = create_artificial_label ();
- label_true = create_artificial_label ();
+ label = create_artificial_label (UNKNOWN_LOCATION);
+ label_true = create_artificial_label (UNKNOWN_LOCATION);
arm1 = TREE_OPERAND (predicate, 0);
arm2 = TREE_OPERAND (predicate, 1);
gimplify_expr (&arm1, stmt_list, NULL, is_gimple_val, fb_rvalue);
@@ -5595,8 +5605,9 @@ lower_omp_sections (gimple_stmt_iterator *gsi_p, omp_context *ctx)
static void
lower_omp_single_simple (gimple single_stmt, gimple_seq *pre_p)
{
- tree tlabel = create_artificial_label ();
- tree flabel = create_artificial_label ();
+ location_t loc = gimple_location (single_stmt);
+ tree tlabel = create_artificial_label (loc);
+ tree flabel = create_artificial_label (loc);
gimple call, cond;
tree lhs, decl;
@@ -5650,15 +5661,16 @@ lower_omp_single_copy (gimple single_stmt, gimple_seq *pre_p, omp_context *ctx)
{
tree ptr_type, t, l0, l1, l2;
gimple_seq copyin_seq;
+ location_t loc = gimple_location (single_stmt);
ctx->sender_decl = create_tmp_var (ctx->record_type, ".omp_copy_o");
ptr_type = build_pointer_type (ctx->record_type);
ctx->receiver_decl = create_tmp_var (ptr_type, ".omp_copy_i");
- l0 = create_artificial_label ();
- l1 = create_artificial_label ();
- l2 = create_artificial_label ();
+ l0 = create_artificial_label (loc);
+ l1 = create_artificial_label (loc);
+ l2 = create_artificial_label (loc);
t = build_call_expr (built_in_decls[BUILT_IN_GOMP_SINGLE_COPY_START], 0);
t = fold_convert (ptr_type, t);
@@ -6106,7 +6118,8 @@ task_copyfn_remap_type (struct omp_taskcopy_context *tcctx, tree orig_type)
type = lang_hooks.types.make_type (RECORD_TYPE);
name = DECL_NAME (TYPE_NAME (orig_type));
- name = build_decl (TYPE_DECL, name, type);
+ name = build_decl (gimple_location (tcctx->ctx->stmt),
+ TYPE_DECL, name, type);
TYPE_NAME (type) = name;
for (f = TYPE_FIELDS (orig_type); f ; f = TREE_CHAIN (f))
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 257edd9e648..99da304b5c1 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -6044,7 +6044,8 @@ init_one_libfunc (const char *name)
targetm.encode_section_info. */
/* ??? We don't have any type information except for this is
a function. Pretend this is "int foo()". */
- decl = build_decl (FUNCTION_DECL, get_identifier (name),
+ decl = build_decl (UNKNOWN_LOCATION,
+ FUNCTION_DECL, get_identifier (name),
build_function_type (integer_type_node, NULL_TREE));
DECL_ARTIFICIAL (decl) = 1;
DECL_EXTERNAL (decl) = 1;
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 152761bcb1c..de9d9a80753 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -750,6 +750,12 @@ extern void rtl_check_failed_flag (const char *, const_rtx, const char *,
#define BLOCK_FOR_INSN(INSN) XBBDEF (INSN, 3)
#define INSN_LOCATOR(INSN) XINT (INSN, 4)
+/* LOCATION of an RTX if relevant. */
+#define RTL_LOCATION(X) (INSN_P (X) ? \
+ locator_location (INSN_LOCATOR (x)) \
+ : UNKNOWN_LOCATION)
+/* LOCATION of current INSN. */
+#define CURR_INSN_LOCATION (locator_location (curr_insn_locator ()))
/* The body of an insn. */
#define PATTERN(INSN) XEXP (INSN, 5)
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 7fc4038aaf5..31b0b7d8365 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -2905,7 +2905,9 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx default_label,
/* Neither node is bounded. First distinguish the two sides;
then emit the code for one side at a time. */
- tree test_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ tree test_label
+ = build_decl (CURR_INSN_LOCATION,
+ LABEL_DECL, NULL_TREE, NULL_TREE);
/* See if the value is on the right. */
emit_cmp_and_jump_insns (index,
@@ -3028,7 +3030,8 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx default_label,
/* Right hand node requires testing.
Branch to a label where we will handle it later. */
- test_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ test_label = build_decl (CURR_INSN_LOCATION,
+ LABEL_DECL, NULL_TREE, NULL_TREE);
emit_cmp_and_jump_insns (index,
convert_modes
(mode, imode,
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index fab5817d3c2..d65452bc710 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1547,7 +1547,8 @@ finish_builtin_struct (tree type, const char *name, tree fields,
#if 0 /* not yet, should get fixed properly later */
TYPE_NAME (type) = make_type_decl (get_identifier (name), type);
#else
- TYPE_NAME (type) = build_decl (TYPE_DECL, get_identifier (name), type);
+ TYPE_NAME (type) = build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier (name), type);
#endif
TYPE_STUB_DECL (type) = TYPE_NAME (type);
layout_decl (TYPE_NAME (type), 0);
diff --git a/gcc/stub-objc.c b/gcc/stub-objc.c
index a907d51d684..fc3d4169f0a 100644
--- a/gcc/stub-objc.c
+++ b/gcc/stub-objc.c
@@ -224,7 +224,7 @@ objc_build_protocol_expr (tree ARG_UNUSED (expr))
}
tree
-objc_build_selector_expr (tree ARG_UNUSED (expr))
+objc_build_selector_expr (location_t ARG_UNUSED (loc), tree ARG_UNUSED (expr))
{
return 0;
}
@@ -279,7 +279,7 @@ objc_get_class_ivars (tree ARG_UNUSED (name))
}
tree
-objc_build_throw_stmt (tree ARG_UNUSED (expr))
+objc_build_throw_stmt (location_t ARG_UNUSED (loc), tree ARG_UNUSED (expr))
{
return 0;
}
diff --git a/gcc/target.h b/gcc/target.h
index 0d60b1134ce..bbc6cd87699 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -564,7 +564,8 @@ struct gcc_target
complete expression that implements the operation. PARAMS really
has type VEC(tree,gc)*, but we don't want to include tree.h
here. */
- tree (*resolve_overloaded_builtin) (tree decl, void *params);
+ tree (*resolve_overloaded_builtin) (unsigned int /*location_t*/,
+ tree decl, void *params);
/* Fold a target-specific builtin. */
tree (* fold_builtin) (tree fndecl, tree arglist, bool ignore);
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index 91c29f0974b..4d799c5d73d 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -477,7 +477,8 @@ default_stack_protect_guard (void)
if (t == NULL)
{
- t = build_decl (VAR_DECL, get_identifier ("__stack_chk_guard"),
+ t = build_decl (UNKNOWN_LOCATION,
+ VAR_DECL, get_identifier ("__stack_chk_guard"),
ptr_type_node);
TREE_STATIC (t) = 1;
TREE_PUBLIC (t) = 1;
@@ -503,7 +504,8 @@ default_external_stack_protect_fail (void)
if (t == NULL_TREE)
{
t = build_function_type_list (void_type_node, NULL_TREE);
- t = build_decl (FUNCTION_DECL, get_identifier ("__stack_chk_fail"), t);
+ t = build_decl (UNKNOWN_LOCATION,
+ FUNCTION_DECL, get_identifier ("__stack_chk_fail"), t);
TREE_STATIC (t) = 1;
TREE_PUBLIC (t) = 1;
DECL_EXTERNAL (t) = 1;
@@ -535,7 +537,7 @@ default_hidden_stack_protect_fail (void)
if (t == NULL_TREE)
{
t = build_function_type_list (void_type_node, NULL_TREE);
- t = build_decl (FUNCTION_DECL,
+ t = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
get_identifier ("__stack_chk_fail_local"), t);
TREE_STATIC (t) = 1;
TREE_PUBLIC (t) = 1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c7801d77376..62b77f61e49 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,45 @@
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * gcc.dg/old-style-prom-3.c: Add column info.
+ * gcc.dg/overflow-warn-1.c
+ * gcc.dg/gomp/pr27415.c
+ * gcc.dg/gomp/for-1.c: Same.
+ * gcc.dg/enum-compat-1.c: Same.
+ * gcc.dg/c99-tag-3.c: Same.
+ * gcc.dg/Wredundant-decls-2.c: Same.
+ * gcc.dg/func-ptr-conv-1.c: Same.
+ * gcc.dg/asm-wide-1.c: Same.
+ * gcc.dg/nofixed-point-2.c: Same.
+ * gcc.dg/cpp/line3.c: Same.
+ * gcc.dg/array-10.c: Same.
+ * gcc.dg/c99-vla-jump-1.c: Same.
+ * gcc.dg/pr20368-1.c: Same.
+ * gcc.dg/Wshadow-3.c: Same.
+ * gcc.dg/c90-const-expr-8.c: Same.
+ * gcc.dg/label-decl-2.c: Same.
+ * gcc.dg/dremf-type-compat-2.c: Same.
+ * gcc.dg/c90-const-expr-5.c: Same.
+ * gcc.dg/builtins-30.c: Same.
+ * gcc.dg/Warray-bounds.c: Same.
+ * gcc.dg/Wcxx-compat-2.c: Same.
+ * gcc.dg/tree-ssa/col-1.c: Same.
+ * gcc.dg/old-style-prom-2.c: Same.
+ * gcc.dg/cast-function-1.c: Same.
+ * gcc.dg/pr15698-1.c: Same.
+ * gcc.dg/dremf-type-compat-3.c: Same.
+ * gcc.dg/vla-8.c: Same.
+ * gcc.dg/gomp/pr27415.c: Move firstprivate diagnostics to correct
+ line.
+ * gcc.dg/label-decl-2.c: Move label diagnostic to correct line.
+ * gcc.dg/old-style-prom-3.c: Check for error on the correct line.
+ * gcc.dg/enum-compat-1.c: Same.
+ * gcc.dg/dremf-type-compat-2.c: Same.
+ * gcc.dg/old-style-prom-2.c: Same.
+ * gcc.dg/pr15698-1.c: Same.
+ * gcc.dg/pr20368-1.c: Same.
+ * gcc.dg/dremf-type-compat-3.c: Same.
+ * gcc.dg/builtins-30.c: Same. Test for columns.
+
2009-06-12 Janus Weil <janus@gcc.gnu.org>
PR fortran/40176
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds.c b/gcc/testsuite/gcc.dg/Warray-bounds.c
index ac384e6bb2f..44120392c73 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds.c
@@ -18,40 +18,40 @@ int* f(void) {
int c[10];
} c;
- a[-1] = 0; /* { dg-warning "array subscript" } */
+ a[-1] = 0; /* { dg-warning "6:array subscript" } */
a[ 0] = 0;
a[ 1] = 0;
a[ 9] = 0;
- a[10] = 0; /* { dg-warning "array subscript" } */
- a[11] = 0; /* { dg-warning "array subscript" } */
- a[2 * n() - 11] = 1; /* { dg-warning "array subscript" } */
+ a[10] = 0; /* { dg-warning "6:array subscript" } */
+ a[11] = 0; /* { dg-warning "6:array subscript" } */
+ a[2 * n() - 11] = 1; /* { dg-warning "6:array subscript" } */
a[2 * n() - 10] = 1;
a[2 * n() - 1] = 1;
- a[2 * n() - 0] = 1; /* { dg-warning "array subscript" } */
+ a[2 * n() - 0] = 1; /* { dg-warning "6:array subscript" } */
- b[-1] = 0; /* { dg-warning "array subscript" } */
+ b[-1] = 0; /* { dg-warning "6:array subscript" } */
b[ 0] = 0;
b[ 1] = 0;
b[ 9] = 0;
- b[10] = 0; /* { dg-warning "array subscript" } */
- b[11] = 0; /* { dg-warning "array subscript" } */
- b[2 * n() - 11] = 1; /* { dg-warning "array subscript" } */
+ b[10] = 0; /* { dg-warning "6:array subscript" } */
+ b[11] = 0; /* { dg-warning "6:array subscript" } */
+ b[2 * n() - 11] = 1; /* { dg-warning "6:array subscript" } */
b[2 * n() - 10] = 1;
b[2 * n() - 1] = 1;
b[2 * n() - 0] = 1; /* { dg-warning "array subscript" } */
- c.c[-1] = 0; /* { dg-warning "array subscript" } */
+ c.c[-1] = 0; /* { dg-warning "8:array subscript" } */
c.c[ 0] = 0;
c.c[ 1] = 0;
c.c[ 9] = 0;
- c.c[10] = 0; /* { dg-warning "array subscript" } */
- c.c[11] = 0; /* { dg-warning "array subscript" } */
- c.c[2 * n() - 11] = 1; /* { dg-warning "array subscript" } */
+ c.c[10] = 0; /* { dg-warning "8:array subscript" } */
+ c.c[11] = 0; /* { dg-warning "8:array subscript" } */
+ c.c[2 * n() - 11] = 1; /* { dg-warning "8:array subscript" } */
c.c[2 * n() - 10] = 1;
c.c[2 * n() - 1] = 1;
- c.c[2 * n() - 0] = 1; /* { dg-warning "array subscript" } */
+ c.c[2 * n() - 0] = 1; /* { dg-warning "8:array subscript" } */
g(&a[8]);
g(&a[9]);
@@ -86,7 +86,7 @@ int* f(void) {
c.c[-1] = 0;
for (i = 20; i < 30; ++i)
- a[i] = 1; /* { dg-warning "array subscript" } */
+ a[i] = 1; /* { dg-warning "15:array subscript" } */
return a;
}
diff --git a/gcc/testsuite/gcc.dg/Wcxx-compat-2.c b/gcc/testsuite/gcc.dg/Wcxx-compat-2.c
index a091c6dd8b5..14edc1a4215 100644
--- a/gcc/testsuite/gcc.dg/Wcxx-compat-2.c
+++ b/gcc/testsuite/gcc.dg/Wcxx-compat-2.c
@@ -1,36 +1,36 @@
/* { dg-options "-Wc++-compat" } */
_Bool foo; /* This is okay. */
-int bool; /* { dg-warning "keyword" } */
-int catch; /* { dg-warning "keyword" } */
-int char16_t; /* { dg-warning "keyword" } */
-int char32_t; /* { dg-warning "keyword" } */
-int class; /* { dg-warning "keyword" } */
-int const_cast; /* { dg-warning "keyword" } */
-int decltype; /* { dg-warning "keyword" } */
-int delete; /* { dg-warning "keyword" } */
-int dynamic_cast; /* { dg-warning "keyword" } */
-int explicit; /* { dg-warning "keyword" } */
-int export; /* { dg-warning "keyword" } */
-int false; /* { dg-warning "keyword" } */
-int friend; /* { dg-warning "keyword" } */
-int mutable; /* { dg-warning "keyword" } */
-int namespace; /* { dg-warning "keyword" } */
-int new; /* { dg-warning "keyword" } */
-int operator; /* { dg-warning "keyword" } */
-int private; /* { dg-warning "keyword" } */
-int protected; /* { dg-warning "keyword" } */
-int public; /* { dg-warning "keyword" } */
-int reinterpret_cast; /* { dg-warning "keyword" } */
-int static_assert; /* { dg-warning "keyword" } */
-int static_cast; /* { dg-warning "keyword" } */
-int template; /* { dg-warning "keyword" } */
-int this; /* { dg-warning "keyword" } */
-int throw; /* { dg-warning "keyword" } */
-int true; /* { dg-warning "keyword" } */
-int try; /* { dg-warning "keyword" } */
-int typename; /* { dg-warning "keyword" } */
-int typeid; /* { dg-warning "keyword" } */
-int using; /* { dg-warning "keyword" } */
-int virtual; /* { dg-warning "keyword" } */
+int bool; /* { dg-warning "5:keyword" } */
+int catch; /* { dg-warning "5:keyword" } */
+int char16_t; /* { dg-warning "5:keyword" } */
+int char32_t; /* { dg-warning "5:keyword" } */
+int class; /* { dg-warning "5:keyword" } */
+int const_cast; /* { dg-warning "5:keyword" } */
+int decltype; /* { dg-warning "5:keyword" } */
+int delete; /* { dg-warning "5:keyword" } */
+int dynamic_cast; /* { dg-warning "5:keyword" } */
+int explicit; /* { dg-warning "5:keyword" } */
+int export; /* { dg-warning "5:keyword" } */
+int false; /* { dg-warning "5:keyword" } */
+int friend; /* { dg-warning "5:keyword" } */
+int mutable; /* { dg-warning "5:keyword" } */
+int namespace; /* { dg-warning "5:keyword" } */
+int new; /* { dg-warning "5:keyword" } */
+int operator; /* { dg-warning "5:keyword" } */
+int private; /* { dg-warning "5:keyword" } */
+int protected; /* { dg-warning "5:keyword" } */
+int public; /* { dg-warning "5:keyword" } */
+int reinterpret_cast; /* { dg-warning "5:keyword" } */
+int static_assert; /* { dg-warning "5:keyword" } */
+int static_cast; /* { dg-warning "5:keyword" } */
+int template; /* { dg-warning "5:keyword" } */
+int this; /* { dg-warning "5:keyword" } */
+int throw; /* { dg-warning "5:keyword" } */
+int true; /* { dg-warning "5:keyword" } */
+int try; /* { dg-warning "5:keyword" } */
+int typename; /* { dg-warning "5:keyword" } */
+int typeid; /* { dg-warning "5:keyword" } */
+int using; /* { dg-warning "5:keyword" } */
+int virtual; /* { dg-warning "5:keyword" } */
int wchar_t;
diff --git a/gcc/testsuite/gcc.dg/Wredundant-decls-2.c b/gcc/testsuite/gcc.dg/Wredundant-decls-2.c
index 89f57b427c6..27c8e5d9f7d 100644
--- a/gcc/testsuite/gcc.dg/Wredundant-decls-2.c
+++ b/gcc/testsuite/gcc.dg/Wredundant-decls-2.c
@@ -2,22 +2,22 @@
/* { dg-do compile } */
/* { dg-options "-Wredundant-decls" } */
-int j = 5; /* { dg-message "note: previous" } */
-int j; /* { dg-warning "redundant" } */
+int j = 5; /* { dg-message "5:note: previous" } */
+int j; /* { dg-warning "5:redundant" } */
static int k;
-static int k = 5; /* { dg-message "note: previous" } */
-static int k; /* { dg-warning "redundant" } */
+static int k = 5; /* { dg-message "12:note: previous" } */
+static int k; /* { dg-warning "12:redundant" } */
-static int l = 5; /* { dg-message "note: previous" } */
-static int l; /* { dg-warning "redundant" } */
+static int l = 5; /* { dg-message "12:note: previous" } */
+static int l; /* { dg-warning "12:redundant" } */
-static int m; /* { dg-message "note: previous" } */
-static int m; /* { dg-warning "redundant" } */
+static int m; /* { dg-message "12:note: previous" } */
+static int m; /* { dg-warning "12:redundant" } */
static int m = 5;
-int n; /* { dg-message "note: previous" } */
-int n; /* { dg-warning "redundant" } */
+int n; /* { dg-message "5:note: previous" } */
+int n; /* { dg-warning "5:redundant" } */
int n = 5;
static int o;
diff --git a/gcc/testsuite/gcc.dg/Wshadow-3.c b/gcc/testsuite/gcc.dg/Wshadow-3.c
index a7f06a26f96..b6d78b1d38b 100644
--- a/gcc/testsuite/gcc.dg/Wshadow-3.c
+++ b/gcc/testsuite/gcc.dg/Wshadow-3.c
@@ -1,21 +1,61 @@
-/* Test warnings for shadowing in function prototype scope: generally
- useless but of use if the parameter is used within the scope. Bug
- 529. */
-/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* PR middle-end/36902 Array bound warning with dead code after optimization */
/* { dg-do compile } */
-/* { dg-options "-std=gnu89 -Wshadow" } */
-
-int v; /* { dg-warning "shadowed declaration" } */
-int f1(int v);
-int f2(int v, int x[v]); /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f3(int v, int y[sizeof(v)]); /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f4(int v) { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f5(int v, int x[v]) { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f6(int x) { return 0; }
-int f7(v) int v; { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f8(v, w) int v; int w[v]; { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f9(x) int x; { return 0; }
-int f10(v) { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f11(int a, int b(int a));
-int f12(int a, int b(int a, int x[a])); /* { dg-warning "declaration of 'a' shadows a parameter" } */
-/* { dg-warning "shadowed declaration" "outer parm" { target *-*-* } 20 } */
+/* { dg-options "-O2 -Warray-bounds -Wall -Wextra" } */
+typedef unsigned char __u8;
+typedef unsigned short __u16;
+
+static inline unsigned char *
+foo(unsigned char * to, const unsigned char * from, int n)
+{
+ switch ( n )
+ {
+ case 3:
+ *to = *from;
+ break;
+ case 5:
+ to[4] = from [4];
+ break;
+ }
+ return to;
+}
+
+struct {
+ int size_of_select;
+ unsigned char pcr_select[4];
+} sel;
+
+int bar(void)
+{
+ static unsigned char buf[64];
+
+ sel.size_of_select = 3;
+ foo(buf, sel.pcr_select, sel.size_of_select);
+
+ return 1;
+}
+
+
+static inline unsigned char *
+foo2(unsigned char * to, const unsigned char * from, int n)
+{
+ switch ( n )
+ {
+ case 3:
+ *to = *from;
+ break;
+ case 5:
+ to[63] = from [111]; /* { dg-warning "array subscript is above array bounds" } */
+ break;
+ }
+ return to;
+}
+
+int baz(void)
+{
+ static unsigned char buf[64];
+
+ sel.size_of_select = 5;
+ foo2(buf, sel.pcr_select, sel.size_of_select);
+
+ return 1;
+}
diff --git a/gcc/testsuite/gcc.dg/array-10.c b/gcc/testsuite/gcc.dg/array-10.c
index aab1538d5e1..3b4d512ba5a 100644
--- a/gcc/testsuite/gcc.dg/array-10.c
+++ b/gcc/testsuite/gcc.dg/array-10.c
@@ -6,28 +6,28 @@
int a;
-int b0[a]; /* { dg-error "at file scope" } */
-int (*b1)[a]; /* { dg-error "at file scope" } */
+int b0[a]; /* { dg-error "5:at file scope" } */
+int (*b1)[a]; /* { dg-error "7:at file scope" } */
int (*b2())[a]; /* { dg-error "at file scope" } */
-struct b3 { int x[a]; }; /* { dg-error "at file scope" } */
-struct b4 { int (*x)[a]; }; /* { dg-error "at file scope" } */
+struct b3 { int x[a]; }; /* { dg-error "17:at file scope" } */
+struct b4 { int (*x)[a]; }; /* { dg-error "19:at file scope" } */
typeof (int [a]) b5; /* { dg-error "at file scope|outside of any function" } */
-int c0[(__SIZE_TYPE__)&a]; /* { dg-error "at file scope" } */
-int (*c1)[(__SIZE_TYPE__)&a]; /* { dg-error "at file scope" } */
-int (*c2())[(__SIZE_TYPE__)&a]; /* { dg-error "at file scope" } */
-struct c3 { int x[(__SIZE_TYPE__)&a]; }; /* { dg-error "at file scope" } */
-struct c4 { int (*x)[(__SIZE_TYPE__)&a]; }; /* { dg-error "at file scope" } */
-typeof (int [(__SIZE_TYPE__)&a]) c5; /* { dg-error "at file scope" } */
+int c0[(__SIZE_TYPE__)&a]; /* { dg-error "5:at file scope" } */
+int (*c1)[(__SIZE_TYPE__)&a]; /* { dg-error "7:at file scope" } */
+int (*c2())[(__SIZE_TYPE__)&a]; /* { dg-error "7:at file scope" } */
+struct c3 { int x[(__SIZE_TYPE__)&a]; }; /* { dg-error "17:at file scope" } */
+struct c4 { int (*x)[(__SIZE_TYPE__)&a]; }; /* { dg-error "19:at file scope" } */
+typeof (int [(__SIZE_TYPE__)&a]) c5; /* { dg-error "34:at file scope" } */
-int d0[1/0]; /* { dg-error "at file scope" } */
-/* { dg-warning "division by zero" "" { target *-*-* } 23 } */
-int (*d1)[1/0]; /* { dg-error "at file scope" } */
-/* { dg-warning "division by zero" "" { target *-*-* } 25 } */
-int (*d2())[1/0]; /* { dg-error "at file scope" } */
-/* { dg-warning "division by zero" "" { target *-*-* } 27 } */
-struct d3 { int x[1/0]; }; /* { dg-error "at file scope" } */
-/* { dg-warning "division by zero" "" { target *-*-* } 29 } */
-struct d4 { int (*x)[1/0]; }; /* { dg-error "at file scope" } */
-/* { dg-warning "division by zero" "" { target *-*-* } 31 } */
-typeof (int [1/0]) d5; /* { dg-error "at file scope" } */
+int d0[1/0]; /* { dg-error "5:at file scope" } */
+/* { dg-warning "9:division by zero" "" { target *-*-* } 23 } */
+int (*d1)[1/0]; /* { dg-error "7:at file scope" } */
+/* { dg-warning "12:division by zero" "" { target *-*-* } 25 } */
+int (*d2())[1/0]; /* { dg-error "7:at file scope" } */
+/* { dg-warning "14:division by zero" "" { target *-*-* } 27 } */
+struct d3 { int x[1/0]; }; /* { dg-error "17:at file scope" } */
+/* { dg-warning "20:division by zero" "" { target *-*-* } 29 } */
+struct d4 { int (*x)[1/0]; }; /* { dg-error "19:at file scope" } */
+/* { dg-warning "23:division by zero" "" { target *-*-* } 31 } */
+typeof (int [1/0]) d5; /* { dg-error "20:at file scope" } */
diff --git a/gcc/testsuite/gcc.dg/asm-wide-1.c b/gcc/testsuite/gcc.dg/asm-wide-1.c
index a42271fd4b1..c14b19d3479 100644
--- a/gcc/testsuite/gcc.dg/asm-wide-1.c
+++ b/gcc/testsuite/gcc.dg/asm-wide-1.c
@@ -3,27 +3,27 @@
/* { dg-do compile } */
/* { dg-options "" } */
-int foo asm (L"bar"); /* { dg-error "wide string literal in 'asm'" } */
+int foo asm (L"bar"); /* { dg-error "14:wide string literal in 'asm'" } */
-asm (L"foo"); /* { dg-error "wide string literal in 'asm'" } */
+asm (L"foo"); /* { dg-error "6:wide string literal in 'asm'" } */
void
f (void)
{
int x = 1;
- asm (L"foo"); /* { dg-error "wide string literal in 'asm'" } */
+ asm (L"foo"); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" :
- L"=g" (x)); /* { dg-error "wide string literal in 'asm'" } */
+ L"=g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" : [x]
- L"=g" (x)); /* { dg-error "wide string literal in 'asm'" } */
+ L"=g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" : [x] "=g" (x),
- L"=g" (x)); /* { dg-error "wide string literal in 'asm'" } */
+ L"=g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" : :
- L"g" (x)); /* { dg-error "wide string literal in 'asm'" } */
+ L"g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" : : :
- L"memory"); /* { dg-error "wide string literal in 'asm'" } */
+ L"memory"); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" : : : "memory",
- L"memory"); /* { dg-error "wide string literal in 'asm'" } */
+ L"memory"); /* { dg-error "8:wide string literal in 'asm'" } */
}
/* Extra errors from the substitution of "" for wide strings: */
diff --git a/gcc/testsuite/gcc.dg/builtins-30.c b/gcc/testsuite/gcc.dg/builtins-30.c
index 65a78fefe1d..37e5dba2db6 100644
--- a/gcc/testsuite/gcc.dg/builtins-30.c
+++ b/gcc/testsuite/gcc.dg/builtins-30.c
@@ -1,29 +1,27 @@
/* { dg-do compile } */
-/* { dg-options "-Wall -Wshadow" } */
+/* { dg-options "-Wall -Wshadow -fshow-column" } */
extern double strtod (const char *, char **);
#define UNUSED __attribute__ ((unused))
/* A built-in function may be overridden by an old-style definition
specifying too few arguments... */
-double cos () /* { dg-warning "shadows a built-in" } */
+double cos () /* { dg-warning "shadows a built-in|number of arguments" } */
{
- /* { dg-warning "number of arguments doesn't match built-in prototype" "built-in" { target *-*-* } 10 } */
return strtod ("nan", 0);
}
/* the right number, but the wrong type, arguments... */
-double sin (foo) /* { dg-warning "shadows a built-in" } */
- int foo UNUSED;
-{ /* { dg-warning "argument 'foo' doesn't match built-in prototype" } */
+double sin (foo) /* { dg-warning "8:shadows a built-in" } */
+ int foo UNUSED; /* { dg-warning "10:argument 'foo' doesn't match built-in prototype" } */
+{
return strtod ("nan", 0);
}
/* or too many arguments. */
-long double cosl (foo, bar) /* { dg-warning "shadows a built-in" } */
- const char *foo UNUSED;
+long double cosl (foo, bar) /* { dg-warning "shadows a built-in|number of arguments" } */
+ const char *foo UNUSED; /* { dg-warning "18:argument 'foo' doesn't match" } */
int bar UNUSED;
-{ /* { dg-warning "number of arguments doesn't match built-in prototype" } */
- /* { dg-warning "argument 'foo' doesn't match built-in prototype" "foo" { target *-*-* } 26 } */
+{
return strtod ("nan", 0);
}
diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-5.c b/gcc/testsuite/gcc.dg/c90-const-expr-5.c
index 0a5af8124cd..9f5cdef8399 100644
--- a/gcc/testsuite/gcc.dg/c90-const-expr-5.c
+++ b/gcc/testsuite/gcc.dg/c90-const-expr-5.c
@@ -2,7 +2,7 @@
qualified void. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic-errors -fshow-column" } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
typedef void V;
int *p;
@@ -15,14 +15,14 @@ f (void)
{
/* (V *)0 is a null pointer constant, so the assignment should be
diagnosed. */
- q = (j ? p : (V *)0); /* { dg-error "3:assignment from incompatible pointer type" } */
- q = (j ? p : (void *)0); /* { dg-error "3:assignment from incompatible pointer type" } */
+ q = (j ? p : (V *)0); /* { dg-error "5:assignment from incompatible pointer type" } */
+ q = (j ? p : (void *)0); /* { dg-error "5:assignment from incompatible pointer type" } */
/* And this conversion should be valid. */
(void (*)(void))(V *)0;
(void (*)(void))(void *)0;
/* Pointers to qualified void are not valid null pointer
constants. */
- fp = (const void *)0; /* { dg-error "3:ISO C forbids assignment between function pointer and 'void \\*'" } */
+ fp = (const void *)0; /* { dg-error "6:ISO C forbids assignment between function pointer and 'void \\*'" } */
fp = (void *)0;
fp = (V *)0;
fp = 0;
diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-8.c b/gcc/testsuite/gcc.dg/c90-const-expr-8.c
index 966044c4eff..b00bb9718f8 100644
--- a/gcc/testsuite/gcc.dg/c90-const-expr-8.c
+++ b/gcc/testsuite/gcc.dg/c90-const-expr-8.c
@@ -9,19 +9,19 @@
#include <limits.h>
enum e {
- E0 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 12 } */
- E1 = 0 * (INT_MIN / -1), /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 14 } */
- E2 = 0 * (INT_MAX * INT_MAX), /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 16 } */
- E3 = 0 * (INT_MIN - 1), /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 18 } */
- E4 = 0 * (unsigned)(INT_MIN - 1), /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 20 } */
- E5 = 0 * -INT_MIN, /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 22 } */
- E6 = 0 * !-INT_MIN, /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "not an integer constant" "constant" { target *-*-* } 24 } */
+ E0 = 0 * (INT_MAX + 1), /* { dg-warning "21:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 12 } */
+ E1 = 0 * (INT_MIN / -1), /* { dg-warning "21:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 14 } */
+ E2 = 0 * (INT_MAX * INT_MAX), /* { dg-warning "21:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 16 } */
+ E3 = 0 * (INT_MIN - 1), /* { dg-warning "21:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 18 } */
+ E4 = 0 * (unsigned)(INT_MIN - 1), /* { dg-warning "31:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 20 } */
+ E5 = 0 * -INT_MIN, /* { dg-warning "12:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 22 } */
+ E6 = 0 * !-INT_MIN, /* { dg-warning "13:integer overflow in expression" } */
+ /* { dg-error "3:not an integer constant" "constant" { target *-*-* } 24 } */
E7 = INT_MIN % -1 /* Not an overflow. */
};
diff --git a/gcc/testsuite/gcc.dg/c99-tag-3.c b/gcc/testsuite/gcc.dg/c99-tag-3.c
index 7406e7d64c7..a492037b07a 100644
--- a/gcc/testsuite/gcc.dg/c99-tag-3.c
+++ b/gcc/testsuite/gcc.dg/c99-tag-3.c
@@ -13,10 +13,10 @@ void f (void) { struct s0; }
/* A declaration with a qualifier or storage class specifier declares
the tag if no other declaration of it is visible. */
-const union u0; /* { dg-warning "useless type qualifier in empty declaration" } */
+const union u0; /* { dg-warning "13:useless type qualifier in empty declaration" } */
union u0 { long b; };
-extern struct s1; /* { dg-warning "useless storage class specifier in empty declaration" } */
+extern struct s1; /* { dg-warning "15:useless storage class specifier in empty declaration" } */
/* But if a declaration of the tag is visible, whether at the same
scope or an outer scope, the declaration specifies the same type as
@@ -25,13 +25,13 @@ extern struct s1; /* { dg-warning "useless storage class specifier in empty decl
the members of an enumeration, it is a constraint violation. */
struct s2 { char x; };
-const struct s2; /* { dg-error "empty declaration with type qualifier does not redeclare tag" } */
+const struct s2; /* { dg-error "14:empty declaration with type qualifier does not redeclare tag" } */
union u1;
-extern union u1; /* { dg-error "empty declaration with storage class specifier does not redeclare tag" } */
+extern union u1; /* { dg-error "14:empty declaration with storage class specifier does not redeclare tag" } */
union u2 { long b; };
-void g(void) { const union u2; } /* { dg-error "empty declaration with type qualifier does not redeclare tag" } */
+void g(void) { const union u2; } /* { dg-error "28:empty declaration with type qualifier does not redeclare tag" } */
/* And it does not redeclare the tag either if the outer tag is the
wrong kind of tag. This also yields an error for the reference to
@@ -39,21 +39,21 @@ void g(void) { const union u2; } /* { dg-error "empty declaration with type qual
declaration. */
union u3 { float v; };
-void h(void) { const struct u3; } /* { dg-error "'u3' defined as wrong kind of tag" } */
-/* { dg-error "empty declaration with type qualifier does not redeclare tag" "wrong tag empty" { target *-*-* } 42 } */
+void h(void) { const struct u3; } /* { dg-error "29:'u3' defined as wrong kind of tag" } */
+/* { dg-error "29:empty declaration with type qualifier does not redeclare tag" "wrong tag empty" { target *-*-* } 42 } */
/* However, such useless specifiers are OK if the contents of the tag
are being defined, or shadowed in an inner scope with the contents
included in the shadowing. */
struct s3;
-const struct s3 { int a; }; /* { dg-warning "useless type qualifier in empty declaration" } */
+const struct s3 { int a; }; /* { dg-warning "14:useless type qualifier in empty declaration" } */
union u4;
-extern union u4 { int z; }; /* { dg-warning "useless storage class specifier in empty declaration" } */
+extern union u4 { int z; }; /* { dg-warning "14:useless storage class specifier in empty declaration" } */
enum e0 { E0 };
-void i(void) { const enum e0 { E1 }; } /* { dg-warning "useless type qualifier in empty declaration" } */
+void i(void) { const enum e0 { E1 }; } /* { dg-warning "32:useless type qualifier in empty declaration" } */
union u5 { int p; };
-void j(void) { extern struct u5 { int q; }; } /* { dg-warning "useless storage class specifier in empty declaration" } */
+void j(void) { extern struct u5 { int q; }; } /* { dg-warning "30:useless storage class specifier in empty declaration" } */
diff --git a/gcc/testsuite/gcc.dg/c99-vla-jump-1.c b/gcc/testsuite/gcc.dg/c99-vla-jump-1.c
index 4e984d2b81b..3cfa384d1ca 100644
--- a/gcc/testsuite/gcc.dg/c99-vla-jump-1.c
+++ b/gcc/testsuite/gcc.dg/c99-vla-jump-1.c
@@ -15,11 +15,11 @@
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
void fa0 (int n) { goto a; a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; }
-void fa1 (int n) { goto a; { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
-void fa2 (int n) { goto a; { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
-void fa3 (int n) { goto a; { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
-void fa4 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
-void fa5 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
+void fa1 (int n) { goto a; { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "41:jump into scope of identifier with variably modified type" } */
+void fa2 (int n) { goto a; { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "53:jump into scope of identifier with variably modified type" } */
+void fa3 (int n) { goto a; { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "57:jump into scope of identifier with variably modified type" } */
+void fa4 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "69:jump into scope of identifier with variably modified type" } */
+void fa5 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "73:jump into scope of identifier with variably modified type" } */
void fa6 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
void fa7 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; }
void fa8 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
diff --git a/gcc/testsuite/gcc.dg/cast-function-1.c b/gcc/testsuite/gcc.dg/cast-function-1.c
index 8ed7d5da41c..781d0e22191 100644
--- a/gcc/testsuite/gcc.dg/cast-function-1.c
+++ b/gcc/testsuite/gcc.dg/cast-function-1.c
@@ -22,14 +22,14 @@ void bar(void)
int i;
str_t s;
- d = ((double (*) (int)) foo1) (i); /* { dg-warning "non-compatible|abort" } */
- i = ((int (*) (double)) foo1) (d); /* { dg-warning "non-compatible|abort" } */
- s = ((str_t (*) (int)) foo1) (i); /* { dg-warning "non-compatible|abort" } */
+ d = ((double (*) (int)) foo1) (i); /* { dg-warning "33:non-compatible|abort" } */
+ i = ((int (*) (double)) foo1) (d); /* { dg-warning "33:non-compatible|abort" } */
+ s = ((str_t (*) (int)) foo1) (i); /* { dg-warning "32:non-compatible|abort" } */
((void (*) (int)) foo1) (d); /* { dg-warning "non-compatible|abort" } */
i = ((int (*) (int)) foo1) (i); /* { dg-bogus "non-compatible|abort" } */
(void) foo1 (i); /* { dg-bogus "non-compatible|abort" } */
- d = ((double (*) (int)) foo2) (i); /* { dg-warning "non-compatible|abort" } */
+ d = ((double (*) (int)) foo2) (i); /* { dg-warning "33:non-compatible|abort" } */
i = ((int (*) (double)) foo2) (d); /* { dg-bogus "non-compatible|abort" } */
s = ((str_t (*) (int)) foo2) (i); /* { dg-warning "non-compatible|abort" } */
((void (*) (int)) foo2) (d); /* { dg-warning "non-compatible|abort" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/line3.c b/gcc/testsuite/gcc.dg/cpp/line3.c
index dc5bf818da9..7a1061478d4 100644
--- a/gcc/testsuite/gcc.dg/cpp/line3.c
+++ b/gcc/testsuite/gcc.dg/cpp/line3.c
@@ -14,15 +14,15 @@ main(void)
char *A;
A = "text"; /* { dg-warning "discards qualifiers" "case zero" } */
- A = one("text"
+ A = one("text" /* { dg-warning "discards qualifiers" "case one" } */
"text")
- ; /* { dg-warning "discards qualifiers" "case one" } */
- A = two("text"
+ ;
+ A = two("text" /* { dg-warning "discards qualifiers" "case two" } */
"text")
- ; /* { dg-warning "discards qualifiers" "case two" } */
- A = four("text"
+ ;
+ A = four("text" /* { dg-warning "discards qualifiers" "case four" } */
"text")
- ; /* { dg-warning "discards qualifiers" "case four" } */
+ ;
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/dremf-type-compat-2.c b/gcc/testsuite/gcc.dg/dremf-type-compat-2.c
index 61f0ba84fe3..980ead187e7 100644
--- a/gcc/testsuite/gcc.dg/dremf-type-compat-2.c
+++ b/gcc/testsuite/gcc.dg/dremf-type-compat-2.c
@@ -11,8 +11,8 @@ float dremf (float, float); /* { dg-warning "prototype declaration" } */
float
dremf (x, y)
- float x;
- float y;
-{ /* { dg-warning "promoted argument '.' doesn't match prototype" } */
+ float x; /* { dg-warning "promoted argument 'x' doesn't match prototype" } */
+ float y; /* { dg-warning "promoted argument 'y' doesn't match prototype" } */
+{
return x + y;
}
diff --git a/gcc/testsuite/gcc.dg/dremf-type-compat-3.c b/gcc/testsuite/gcc.dg/dremf-type-compat-3.c
index 437e26f65ba..3934a64e19f 100644
--- a/gcc/testsuite/gcc.dg/dremf-type-compat-3.c
+++ b/gcc/testsuite/gcc.dg/dremf-type-compat-3.c
@@ -11,8 +11,8 @@ float dremf (float, float); /* { dg-error "prototype declaration" } */
float
dremf (x, y)
- float x;
- float y;
-{ /* { dg-error "promoted argument '.' doesn't match prototype" } */
+ float x; /* { dg-error "promoted argument 'x' doesn't match prototype" } */
+ float y; /* { dg-error "promoted argument 'y' doesn't match prototype" } */
+{
return x + y;
}
diff --git a/gcc/testsuite/gcc.dg/enum-compat-1.c b/gcc/testsuite/gcc.dg/enum-compat-1.c
index 18d1f7fe715..5fb150cee79 100644
--- a/gcc/testsuite/gcc.dg/enum-compat-1.c
+++ b/gcc/testsuite/gcc.dg/enum-compat-1.c
@@ -12,8 +12,8 @@ enum e2 {c, d};
void f(enum e1); /* { dg-error "prototype" "error at decl" } */
void f(x)
- enum e2 x;
-{ /* { dg-error "doesn't match prototype" "error at defn" } */
+ enum e2 x; /* { dg-error "doesn't match prototype" } */
+{
return;
}
diff --git a/gcc/testsuite/gcc.dg/func-ptr-conv-1.c b/gcc/testsuite/gcc.dg/func-ptr-conv-1.c
index 4e42e5fe117..c331fbc88fc 100644
--- a/gcc/testsuite/gcc.dg/func-ptr-conv-1.c
+++ b/gcc/testsuite/gcc.dg/func-ptr-conv-1.c
@@ -9,15 +9,15 @@
void f(void);
-void *v1 = f; /* { dg-warning "pointer" "bad conversion" } */
-void *v2 = &f; /* { dg-warning "pointer" "bad conversion" } */
-void *v3 = (void *)f; /* { dg-warning "pointer" "bad conversion" } */
-void *v4 = (void *)&f; /* { dg-warning "pointer" "bad conversion" } */
+void *v1 = f; /* { dg-warning "12:pointer" "bad conversion" } */
+void *v2 = &f; /* { dg-warning "12:pointer" "bad conversion" } */
+void *v3 = (void *)f; /* { dg-warning "12:pointer" "bad conversion" } */
+void *v4 = (void *)&f; /* { dg-warning "12:pointer" "bad conversion" } */
void *v5;
-char *c1 = f; /* { dg-warning "pointer" "bad conversion" } */
-char *c2 = &f; /* { dg-warning "pointer" "bad conversion" } */
-char *c3 = (char *)f; /* { dg-warning "pointer" "bad conversion" } */
-char *c4 = (char *)&f; /* { dg-warning "pointer" "bad conversion" } */
+char *c1 = f; /* { dg-warning "12:pointer" "bad conversion" } */
+char *c2 = &f; /* { dg-warning "12:pointer" "bad conversion" } */
+char *c3 = (char *)f; /* { dg-warning "12:pointer" "bad conversion" } */
+char *c4 = (char *)&f; /* { dg-warning "12:pointer" "bad conversion" } */
char *c5;
void (*fp)(void);
int a;
@@ -25,20 +25,20 @@ int a;
void
g(void)
{
- v5 = f; /* { dg-warning "pointer" "bad conversion" } */
- v5 = &f; /* { dg-warning "pointer" "bad conversion" } */
- v5 = (void *)f; /* { dg-warning "pointer" "bad conversion" } */
- v5 = (void *)&f; /* { dg-warning "pointer" "bad conversion" } */
- c5 = f; /* { dg-warning "pointer" "bad conversion" } */
- c5 = &f; /* { dg-warning "pointer" "bad conversion" } */
- c5 = (char *)f; /* { dg-warning "pointer" "bad conversion" } */
- c5 = (char *)&f; /* { dg-warning "pointer" "bad conversion" } */
- fp = v5; /* { dg-warning "pointer" "bad conversion" } */
- fp = c5; /* { dg-warning "pointer" "bad conversion" } */
- fp = (void (*)(void))v5; /* { dg-warning "pointer" "bad conversion" } */
- fp = (void (*)(void))c5; /* { dg-warning "pointer" "bad conversion" } */
- (a ? f : v3); /* { dg-warning "pointer" "bad conversion" } */
- (a ? v2 : fp); /* { dg-warning "pointer" "bad conversion" } */
+ v5 = f; /* { dg-warning "6:pointer" "bad conversion" } */
+ v5 = &f; /* { dg-warning "6:pointer" "bad conversion" } */
+ v5 = (void *)f; /* { dg-warning "8:pointer" "bad conversion" } */
+ v5 = (void *)&f; /* { dg-warning "8:pointer" "bad conversion" } */
+ c5 = f; /* { dg-warning "6:pointer" "bad conversion" } */
+ c5 = &f; /* { dg-warning "6:pointer" "bad conversion" } */
+ c5 = (char *)f; /* { dg-warning "8:pointer" "bad conversion" } */
+ c5 = (char *)&f; /* { dg-warning "8:pointer" "bad conversion" } */
+ fp = v5; /* { dg-warning "6:pointer" "bad conversion" } */
+ fp = c5; /* { dg-warning "6:pointer" "bad conversion" } */
+ fp = (void (*)(void))v5; /* { dg-warning "8:pointer" "bad conversion" } */
+ fp = (void (*)(void))c5; /* { dg-warning "8:pointer" "bad conversion" } */
+ (a ? f : v3); /* { dg-warning "6:pointer" "bad conversion" } */
+ (a ? v2 : fp); /* { dg-warning "6:pointer" "bad conversion" } */
/* The following are OK. */
fp = 0;
fp = (void *)0;
diff --git a/gcc/testsuite/gcc.dg/gomp/for-1.c b/gcc/testsuite/gcc.dg/gomp/for-1.c
index 840f9478499..384293e8275 100644
--- a/gcc/testsuite/gcc.dg/gomp/for-1.c
+++ b/gcc/testsuite/gcc.dg/gomp/for-1.c
@@ -44,6 +44,6 @@ void foo (int j, int k)
baz (i);
#pragma omp for
- for (i = 0; i < 10; i-=3, j+=2) /* { dg-error "23:invalid increment expression" } */
+ for (i = 0; i < 10; i-=3, j+=2) /* { dg-error "27:invalid increment expression" } */
baz (i);
}
diff --git a/gcc/testsuite/gcc.dg/gomp/pr27415.c b/gcc/testsuite/gcc.dg/gomp/pr27415.c
index 418eaf678e9..010a6c3e4dd 100644
--- a/gcc/testsuite/gcc.dg/gomp/pr27415.c
+++ b/gcc/testsuite/gcc.dg/gomp/pr27415.c
@@ -15,8 +15,8 @@ void
test2 (void)
{
int i = 0;
-#pragma omp parallel for firstprivate (i)
- for (i = 0; i < 10; i++) /* { dg-error "should not be firstprivate" } */
+#pragma omp parallel for firstprivate (i) /* { dg-error "should not be firstprivate" } */
+ for (i = 0; i < 10; i++)
;
}
@@ -34,8 +34,8 @@ void
test4 (void)
{
int i = 0;
-#pragma omp parallel for reduction (*:i)
- for (i = 0; i < 10; i++) /* { dg-error "should not be reduction" } */
+#pragma omp parallel for reduction (*:i) /* { dg-error "should not be reduction" } */
+ for (i = 0; i < 10; i++)
;
}
diff --git a/gcc/testsuite/gcc.dg/label-decl-2.c b/gcc/testsuite/gcc.dg/label-decl-2.c
index 97c453b78b7..6706a706bfe 100644
--- a/gcc/testsuite/gcc.dg/label-decl-2.c
+++ b/gcc/testsuite/gcc.dg/label-decl-2.c
@@ -8,9 +8,8 @@ typedef int b;
void
f (void)
{
- __label__ a, b, c, d;
+ __label__ a, b, c, d; /* { dg-warning "ISO C forbids label declarations" "label decls" { target *-*-* } 11 } */
__extension__ (void)&&d; /* { dg-error "label 'd' used but not defined" } */
- /* { dg-warning "ISO C forbids label declarations" "label decls" { target *-*-* } 11 } */
goto c; /* { dg-error "label 'c' used but not defined" } */
a: (void)0;
b: (void)0;
diff --git a/gcc/testsuite/gcc.dg/nofixed-point-2.c b/gcc/testsuite/gcc.dg/nofixed-point-2.c
index 97bbf70225c..5820ded922e 100644
--- a/gcc/testsuite/gcc.dg/nofixed-point-2.c
+++ b/gcc/testsuite/gcc.dg/nofixed-point-2.c
@@ -9,7 +9,7 @@ f1 (void)
}
__typeof (0r) /* { dg-error "not supported" "reject fixed-point" } */
-b2 (void)
+b2 (void) /* { dg-warning "defaults to" } */
{
return 0r; /* { dg-error "not supported" "reject fixed-point" } */
}
@@ -26,5 +26,4 @@ f4 (void) /* { dg-error "not supported" "reject fixed-point" } */
return 0k; /* { dg-error "not supported" "reject fixed-point" } */
}
-/* { dg-warning "defaults to" "" { target *-*-* } 13 } */
/* { dg-error "is used without" "" { target *-*-* } 24 } */
diff --git a/gcc/testsuite/gcc.dg/old-style-prom-2.c b/gcc/testsuite/gcc.dg/old-style-prom-2.c
index 0460facef61..e7e690e1417 100644
--- a/gcc/testsuite/gcc.dg/old-style-prom-2.c
+++ b/gcc/testsuite/gcc.dg/old-style-prom-2.c
@@ -7,8 +7,8 @@ float f (float, float); /* { dg-warning "prototype declaration" } */
float
f (x, y)
- float x;
- float y;
-{ /* { dg-warning "promoted argument '.' doesn't match prototype" } */
+ float x; /* { dg-warning "promoted argument 'x' doesn't match prototype" } */
+ float y; /* { dg-warning "promoted argument 'y' doesn't match prototype" } */
+{
return x + y;
}
diff --git a/gcc/testsuite/gcc.dg/old-style-prom-3.c b/gcc/testsuite/gcc.dg/old-style-prom-3.c
index 931a4a7264b..720367f2e33 100644
--- a/gcc/testsuite/gcc.dg/old-style-prom-3.c
+++ b/gcc/testsuite/gcc.dg/old-style-prom-3.c
@@ -7,8 +7,8 @@ float f (float, float); /* { dg-error "prototype declaration" } */
float
f (x, y)
- float x;
- float y;
-{ /* { dg-error "promoted argument '.' doesn't match prototype" } */
+ float x; /* { dg-error "promoted argument 'x' doesn't match prototype" } */
+ float y; /* { dg-error "promoted argument 'y' doesn't match prototype" } */
+{
return x + y;
}
diff --git a/gcc/testsuite/gcc.dg/overflow-warn-1.c b/gcc/testsuite/gcc.dg/overflow-warn-1.c
index 0cf08a3e77f..78909df368b 100644
--- a/gcc/testsuite/gcc.dg/overflow-warn-1.c
+++ b/gcc/testsuite/gcc.dg/overflow-warn-1.c
@@ -12,23 +12,23 @@ enum e {
/* Overflow in an unevaluated part of an expression is OK (example
in the standard). */
E2 = 2 || 1 / 0,
- E3 = 1 / 0, /* { dg-warning "division by zero" } */
- /* { dg-error "enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } 15 } */
+ E3 = 1 / 0, /* { dg-warning "10:division by zero" } */
+ /* { dg-error "3:enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } 15 } */
/* But as in DR#031, the 1/0 in an evaluated subexpression means the
whole expression violates the constraints. */
- E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */
+ E4 = 0 * (1 / 0), /* { dg-warning "15:division by zero" } */
/* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { target *-*-* } 19 } */
- E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */
+ E5 = INT_MAX + 1, /* { dg-warning "16:integer overflow in expression" } */
/* Again, overflow in evaluated subexpression. */
- E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */
+ E6 = 0 * (INT_MAX + 1), /* { dg-warning "21:integer overflow in expression" } */
/* A cast does not constitute overflow in conversion. */
E7 = (char) INT_MAX
};
struct s {
int a;
- int : 0 * (1 / 0); /* { dg-warning "division by zero" } */
- /* { dg-error "not an integer constant" "integer constant" { target *-*-* } 30 } */
+ int : 0 * (1 / 0); /* { dg-warning "16:division by zero" } */
+ /* { dg-error "not an integer constant" "22:integer constant" { target *-*-* } 30 } */
int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
};
@@ -37,11 +37,11 @@ f (void)
{
/* This expression is not required to be a constant expression, so
it should just involve undefined behavior at runtime. */
- int c = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
+ int c = INT_MAX + 1; /* { dg-warning "19:integer overflow in expression" } */
}
/* But this expression does need to be constant. */
-static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
+static int sc = INT_MAX + 1; /* { dg-warning "25:integer overflow in expression" } */
/* The first two of these involve overflow, so are not null pointer
constants. The third has the overflow in an unevaluated
diff --git a/gcc/testsuite/gcc.dg/pr15698-1.c b/gcc/testsuite/gcc.dg/pr15698-1.c
index 6bb001aea7f..5a75a10733f 100644
--- a/gcc/testsuite/gcc.dg/pr15698-1.c
+++ b/gcc/testsuite/gcc.dg/pr15698-1.c
@@ -17,7 +17,7 @@ int foobar ()
}
char *rindex(a, b)
- register char *a, b;
-{ /* { dg-warning "argument 'a' doesn't match built-in prototype" } */
+ register char *a, b; /* { dg-warning "argument 'a' doesn't match built-in prototype" } */
+{
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/pr20368-1.c b/gcc/testsuite/gcc.dg/pr20368-1.c
index ac76c16f783..4140397c142 100644
--- a/gcc/testsuite/gcc.dg/pr20368-1.c
+++ b/gcc/testsuite/gcc.dg/pr20368-1.c
@@ -6,7 +6,7 @@
extern __typeof (f) g; /* { dg-error "'f' undeclared here \\(not in a function\\)" } */
int
-f (x)
- float x; /* { dg-warning "function declaration isn't a prototype" } */
+f (x) /* { dg-warning "function declaration isn't a prototype" } */
+ float x;
{
}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/col-1.c b/gcc/testsuite/gcc.dg/tree-ssa/col-1.c
new file mode 100644
index 00000000000..5838134ad21
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/col-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-gimple-details-lineno" } */
+
+void foo (int, int);
+
+int
+m(int x)
+{
+ int c, a;
+ a = (c = 5) + 16 + x * 2 ;
+ foo (c, a);
+}
+
+/* { dg-final { scan-tree-dump-times "10:9.*c = 5" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "10:14.*c . 16" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "10:4.*a =" 1 "gimple" } } */
+/* { dg-final { cleanup-tree-dump "gimple" } } */
diff --git a/gcc/testsuite/gcc.dg/vla-8.c b/gcc/testsuite/gcc.dg/vla-8.c
index e4c6ae4157f..1d31876b9b4 100644
--- a/gcc/testsuite/gcc.dg/vla-8.c
+++ b/gcc/testsuite/gcc.dg/vla-8.c
@@ -23,8 +23,8 @@ void foo1(int n) {
}
void foo2(int n) {
- goto A; /* { dg-error "jump into scope of identifier with variably modified type" } */
+ goto A;
int (*(*bar2)(void))[n];
- A:
+ A: /* { dg-error "jump into scope of identifier with variably modified type" } */
;
}
diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c
index 698ec2f483e..b71978016c5 100644
--- a/gcc/tree-call-cdce.c
+++ b/gcc/tree-call-cdce.c
@@ -779,7 +779,7 @@ shrink_wrap_one_built_in_call (gimple bi_call)
gcc_assert (cond_expr && gimple_code (cond_expr) == GIMPLE_COND);
/* Now the label. */
- bi_call_label_decl = create_artificial_label ();
+ bi_call_label_decl = create_artificial_label (gimple_location (bi_call));
bi_call_label = gimple_build_label (bi_call_label_decl);
gsi_insert_before (&bi_call_bsi, bi_call_label, GSI_SAME_STMT);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 763ac04d5ca..8470d765681 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -329,7 +329,7 @@ factor_computed_gotos (void)
/* Build a label for the new block which will contain the
factored computed goto. */
- factored_label_decl = create_artificial_label ();
+ factored_label_decl = create_artificial_label (UNKNOWN_LOCATION);
factored_computed_goto_label
= gimple_build_label (factored_label_decl);
gsi_insert_after (&new_gsi, factored_computed_goto_label,
@@ -4268,7 +4268,7 @@ verify_stmt (gimple_stmt_iterator *gsi)
if (addr)
{
debug_generic_expr (addr);
- inform (input_location, "in statement");
+ inform (gimple_location (gsi_stmt (*gsi)), "in statement");
debug_gimple_stmt (stmt);
return true;
}
@@ -4874,7 +4874,7 @@ gimple_block_label (basic_block bb)
}
}
- label = create_artificial_label ();
+ label = create_artificial_label (UNKNOWN_LOCATION);
stmt = gimple_build_label (label);
gsi_insert_before (&s, stmt, GSI_NEW_STMT);
return label;
@@ -6033,7 +6033,7 @@ new_label_mapper (tree decl, void *data)
m = XNEW (struct tree_map);
m->hash = DECL_UID (decl);
m->base.from = decl;
- m->to = create_artificial_label ();
+ m->to = create_artificial_label (UNKNOWN_LOCATION);
LABEL_DECL_UID (m->to) = LABEL_DECL_UID (decl);
if (LABEL_DECL_UID (m->to) >= cfun->cfg->last_label_uid)
cfun->cfg->last_label_uid = LABEL_DECL_UID (m->to) + 1;
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 6a19bd52930..e38b1bd8160 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -486,6 +486,7 @@ replace_goto_queue_cond_clause (tree *tp, struct leh_tf_state *tf,
tree label;
gimple_seq new_seq;
treemple temp;
+ location_t loc = gimple_location (gsi_stmt (*gsi));
temp.tp = tp;
new_seq = find_goto_replacement (tf, temp);
@@ -499,7 +500,7 @@ replace_goto_queue_cond_clause (tree *tp, struct leh_tf_state *tf,
return;
}
- label = create_artificial_label ();
+ label = create_artificial_label (loc);
/* Set the new label for the GIMPLE_COND */
*tp = label;
@@ -832,6 +833,7 @@ frob_into_branch_around (gimple tp, tree lab, tree over)
{
gimple x;
gimple_seq cleanup, result;
+ location_t loc = gimple_location (tp);
cleanup = gimple_try_cleanup (tp);
result = gimple_try_eval (tp);
@@ -839,7 +841,7 @@ frob_into_branch_around (gimple tp, tree lab, tree over)
if (gimple_seq_may_fallthru (result))
{
if (!over)
- over = create_artificial_label ();
+ over = create_artificial_label (loc);
x = gimple_build_goto (over);
gimple_seq_add_stmt (&result, x);
}
@@ -890,7 +892,7 @@ lower_try_finally_fallthru_label (struct leh_tf_state *tf)
if (!label)
{
- label = create_artificial_label ();
+ label = create_artificial_label (gimple_location (tf->try_finally_expr));
tf->fallthru_label = label;
if (tf->outer->tf)
{
@@ -1082,7 +1084,7 @@ lower_try_finally_nofallthru (struct leh_state *state,
if (tf->may_throw)
lab = tf->eh_label;
else
- lab = create_artificial_label ();
+ lab = create_artificial_label (gimple_location (tf->try_finally_expr));
/* We expect that tf->top_p is a GIMPLE_TRY. */
finally = gimple_try_cleanup (tf->top_p);
@@ -1117,6 +1119,7 @@ lower_try_finally_onedest (struct leh_state *state, struct leh_tf_state *tf)
gimple x;
gimple_seq finally;
tree finally_label;
+ location_t loc = gimple_location (tf->try_finally_expr);
finally = gimple_try_cleanup (tf->top_p);
tf->top_p_seq = gimple_try_eval (tf->top_p);
@@ -1148,7 +1151,7 @@ lower_try_finally_onedest (struct leh_state *state, struct leh_tf_state *tf)
return;
}
- finally_label = create_artificial_label ();
+ finally_label = create_artificial_label (loc);
x = gimple_build_label (finally_label);
gimple_seq_add_stmt (&tf->top_p_seq, x);
@@ -1201,6 +1204,7 @@ lower_try_finally_copy (struct leh_state *state, struct leh_tf_state *tf)
gimple_seq seq;
gimple x;
tree tmp;
+ location_t tf_loc = gimple_location (tf->try_finally_expr);
finally = gimple_try_cleanup (tf->top_p);
tf->top_p_seq = gimple_try_eval (tf->top_p);
@@ -1262,7 +1266,8 @@ lower_try_finally_copy (struct leh_state *state, struct leh_tf_state *tf)
if (! q)
continue;
- lab = labels[index].label = create_artificial_label ();
+ lab = labels[index].label
+ = create_artificial_label (tf_loc);
if (index == return_index)
do_return_redirection (q, lab, NULL, &return_val);
@@ -1327,6 +1332,10 @@ lower_try_finally_switch (struct leh_state *state, struct leh_tf_state *tf)
gimple switch_stmt;
gimple_seq finally;
struct pointer_map_t *cont_map = NULL;
+ /* The location of the TRY_FINALLY stmt. */
+ location_t tf_loc;
+ /* The location of the finally block. */
+ location_t finally_loc;
switch_body = gimple_seq_alloc ();
@@ -1334,6 +1343,12 @@ lower_try_finally_switch (struct leh_state *state, struct leh_tf_state *tf)
finally = gimple_try_cleanup (tf->top_p);
tf->top_p_seq = gimple_try_eval (tf->top_p);
+ /* The location of the finally is either the last stmt in the finally
+ block or the location of the TRY_FINALLY itself. */
+ finally_loc = gimple_seq_last_stmt (tf->top_p_seq) != NULL ?
+ gimple_location (gimple_seq_last_stmt (tf->top_p_seq))
+ : tf_loc;
+
/* Lower the finally block itself. */
lower_eh_constructs_1 (state, finally);
@@ -1345,7 +1360,7 @@ lower_try_finally_switch (struct leh_state *state, struct leh_tf_state *tf)
ndests = fallthru_index + tf->may_fallthru;
finally_tmp = create_tmp_var (integer_type_node, "finally_tmp");
- finally_label = create_artificial_label ();
+ finally_label = create_artificial_label (finally_loc);
/* We use VEC_quick_push on case_label_vec throughout this function,
since we know the size in advance and allocate precisely as muce
@@ -1373,7 +1388,7 @@ lower_try_finally_switch (struct leh_state *state, struct leh_tf_state *tf)
last_case = build3 (CASE_LABEL_EXPR, void_type_node,
build_int_cst (NULL_TREE, fallthru_index), NULL,
- create_artificial_label ());
+ create_artificial_label (tf_loc));
VEC_quick_push (tree, case_label_vec, last_case);
last_case_index++;
@@ -1396,7 +1411,7 @@ lower_try_finally_switch (struct leh_state *state, struct leh_tf_state *tf)
last_case = build3 (CASE_LABEL_EXPR, void_type_node,
build_int_cst (NULL_TREE, eh_index), NULL,
- create_artificial_label ());
+ create_artificial_label (tf_loc));
VEC_quick_push (tree, case_label_vec, last_case);
last_case_index++;
@@ -1480,7 +1495,7 @@ lower_try_finally_switch (struct leh_state *state, struct leh_tf_state *tf)
gcc_assert (slot);
cont_stmt = *(gimple *) slot;
- label = create_artificial_label ();
+ label = create_artificial_label (tf_loc);
CASE_LABEL (last_case) = label;
x = gimple_build_label (label);
@@ -1502,6 +1517,7 @@ lower_try_finally_switch (struct leh_state *state, struct leh_tf_state *tf)
label. */
switch_stmt = gimple_build_switch_vec (finally_tmp, last_case,
case_label_vec);
+ gimple_set_location (switch_stmt, finally_loc);
/* Need to link SWITCH_STMT after running replace_goto_queue
due to not wanting to process the same goto stmts twice. */
@@ -1561,6 +1577,7 @@ lower_try_finally (struct leh_state *state, gimple tp)
struct leh_tf_state this_tf;
struct leh_state this_state;
int ndests;
+ location_t tf_loc = gimple_location (tp);
/* Process the try block. */
@@ -1587,7 +1604,7 @@ lower_try_finally (struct leh_state *state, gimple tp)
this_tf.may_throw = get_eh_region_may_contain_throw (this_tf.region);
if (this_tf.may_throw)
{
- this_tf.eh_label = create_artificial_label ();
+ this_tf.eh_label = create_artificial_label (tf_loc);
set_eh_region_tree_label (this_tf.region, this_tf.eh_label);
honor_protect_cleanup_actions (state, &this_state, &this_tf);
}
@@ -1650,6 +1667,7 @@ lower_catch (struct leh_state *state, gimple tp)
struct leh_state this_state;
gimple_stmt_iterator gsi;
tree out_label;
+ location_t try_catch_loc = gimple_location (tp);
try_region = gen_eh_region_try (state->cur_region);
this_state.cur_region = try_region;
@@ -1676,7 +1694,7 @@ lower_catch (struct leh_state *state, gimple tp)
this_state.cur_region = catch_region;
lower_eh_constructs_1 (&this_state, gimple_catch_handler (gcatch));
- eh_label = create_artificial_label ();
+ eh_label = create_artificial_label (try_catch_loc);
set_eh_region_tree_label (catch_region, eh_label);
x = gimple_build_label (eh_label);
@@ -1685,7 +1703,7 @@ lower_catch (struct leh_state *state, gimple tp)
if (gimple_seq_may_fallthru (gimple_catch_handler (gcatch)))
{
if (!out_label)
- out_label = create_artificial_label ();
+ out_label = create_artificial_label (try_catch_loc);
x = gimple_build_goto (out_label);
gimple_seq_add_stmt (gimple_catch_handler_ptr (gcatch), x);
@@ -1731,7 +1749,7 @@ lower_eh_filter (struct leh_state *state, gimple tp)
lower_eh_constructs_1 (state, gimple_eh_filter_failure (inner));
gimple_try_set_cleanup (tp, gimple_eh_filter_failure (inner));
- eh_label = create_artificial_label ();
+ eh_label = create_artificial_label (gimple_location (inner));
set_eh_region_tree_label (this_region, eh_label);
return frob_into_branch_around (tp, eh_label, NULL);
@@ -1770,13 +1788,13 @@ lower_cleanup (struct leh_state *state, gimple tp)
/* Build enough of a try-finally state so that we can reuse
honor_protect_cleanup_actions. */
memset (&fake_tf, 0, sizeof (fake_tf));
- fake_tf.top_p = tp;
+ fake_tf.top_p = fake_tf.try_finally_expr = tp;
fake_tf.outer = state;
fake_tf.region = this_region;
fake_tf.may_fallthru = gimple_seq_may_fallthru (gimple_try_eval (tp));
fake_tf.may_throw = true;
- fake_tf.eh_label = create_artificial_label ();
+ fake_tf.eh_label = create_artificial_label (gimple_location (tp));
set_eh_region_tree_label (this_region, fake_tf.eh_label);
honor_protect_cleanup_actions (state, NULL, &fake_tf);
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 18c2c0307de..052d3412869 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -974,7 +974,7 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data)
STRIP_TYPE_NOPS (value);
if (TREE_CONSTANT (value) || TREE_READONLY (value))
{
- *tp = build_empty_stmt ();
+ *tp = build_empty_stmt (EXPR_LOCATION (*tp));
return copy_tree_body_r (tp, walk_subtrees, data);
}
}
@@ -2648,7 +2648,6 @@ inline_forbidden_p_2 (tree *nodep, int *walk_subtrees,
static bool
inline_forbidden_p (tree fndecl)
{
- location_t saved_loc = input_location;
struct function *fun = DECL_STRUCT_FUNCTION (fndecl);
tree step;
struct walk_stmt_info wi;
@@ -2691,7 +2690,6 @@ inline_forbidden_p (tree fndecl)
egress:
pointer_set_destroy (visited_nodes);
- input_location = saved_loc;
return forbidden_p;
}
@@ -4183,7 +4181,8 @@ copy_decl_to_var (tree decl, copy_body_data *id)
type = TREE_TYPE (decl);
- copy = build_decl (VAR_DECL, DECL_NAME (decl), type);
+ copy = build_decl (DECL_SOURCE_LOCATION (id->dst_fn),
+ VAR_DECL, DECL_NAME (decl), type);
TREE_ADDRESSABLE (copy) = TREE_ADDRESSABLE (decl);
TREE_READONLY (copy) = TREE_READONLY (decl);
TREE_THIS_VOLATILE (copy) = TREE_THIS_VOLATILE (decl);
@@ -4207,7 +4206,8 @@ copy_result_decl_to_var (tree decl, copy_body_data *id)
if (DECL_BY_REFERENCE (decl))
type = TREE_TYPE (type);
- copy = build_decl (VAR_DECL, DECL_NAME (decl), type);
+ copy = build_decl (DECL_SOURCE_LOCATION (id->dst_fn),
+ VAR_DECL, DECL_NAME (decl), type);
TREE_READONLY (copy) = TREE_READONLY (decl);
TREE_THIS_VOLATILE (copy) = TREE_THIS_VOLATILE (decl);
if (!DECL_BY_REFERENCE (decl))
diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c
index 5f4f5ac0b29..cfba33d9c66 100644
--- a/gcc/tree-mudflap.c
+++ b/gcc/tree-mudflap.c
@@ -295,7 +295,8 @@ static GTY (()) tree mf_set_options_fndecl;
static inline tree
mf_make_builtin (enum tree_code category, const char *name, tree type)
{
- tree decl = mf_mark (build_decl (category, get_identifier (name), type));
+ tree decl = mf_mark (build_decl (UNKNOWN_LOCATION,
+ category, get_identifier (name), type));
TREE_PUBLIC (decl) = 1;
DECL_EXTERNAL (decl) = 1;
lang_hooks.decls.pushdecl (decl);
@@ -315,8 +316,10 @@ mf_make_mf_cache_struct_type (tree field_type)
/* There is, abominably, no language-independent way to construct a
RECORD_TYPE. So we have to call the basic type construction
primitives by hand. */
- tree fieldlo = build_decl (FIELD_DECL, get_identifier ("low"), field_type);
- tree fieldhi = build_decl (FIELD_DECL, get_identifier ("high"), field_type);
+ tree fieldlo = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("low"), field_type);
+ tree fieldhi = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("high"), field_type);
tree struct_type = make_node (RECORD_TYPE);
DECL_CONTEXT (fieldlo) = struct_type;
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index df5577091a0..80041ec66a7 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -314,7 +314,8 @@ get_chain_decl (struct nesting_info *info)
Note also that it's represented as a parameter. This is more
close to the truth, since the initial value does come from
the caller. */
- decl = build_decl (PARM_DECL, create_tmp_var_name ("CHAIN"), type);
+ decl = build_decl (DECL_SOURCE_LOCATION (info->context),
+ PARM_DECL, create_tmp_var_name ("CHAIN"), type);
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
TREE_USED (decl) = 1;
@@ -427,7 +428,7 @@ save_tmp_var (struct nesting_info *info, tree exp, gimple_stmt_iterator *gsi)
static GTY(()) tree trampoline_type;
static tree
-get_trampoline_type (void)
+get_trampoline_type (struct nesting_info *info)
{
unsigned align, size;
tree t;
@@ -448,7 +449,8 @@ get_trampoline_type (void)
t = build_index_type (build_int_cst (NULL_TREE, size - 1));
t = build_array_type (char_type_node, t);
- t = build_decl (FIELD_DECL, get_identifier ("__data"), t);
+ t = build_decl (DECL_SOURCE_LOCATION (info->context),
+ FIELD_DECL, get_identifier ("__data"), t);
DECL_ALIGN (t) = align;
DECL_USER_ALIGN (t) = 1;
@@ -481,7 +483,7 @@ lookup_tramp_for_decl (struct nesting_info *info, tree decl,
{
tree field = make_node (FIELD_DECL);
DECL_NAME (field) = DECL_NAME (decl);
- TREE_TYPE (field) = get_trampoline_type ();
+ TREE_TYPE (field) = get_trampoline_type (info);
TREE_ADDRESSABLE (field) = 1;
insert_field_into_struct (get_frame_type (info), field);
@@ -818,9 +820,9 @@ get_nonlocal_debug_decl (struct nesting_info *info, tree decl)
x = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (x)), x);
/* ??? We should be remapping types as well, surely. */
- new_decl = build_decl (VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+ new_decl = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
DECL_CONTEXT (new_decl) = info->context;
- DECL_SOURCE_LOCATION (new_decl) = DECL_SOURCE_LOCATION (decl);
DECL_ARTIFICIAL (new_decl) = DECL_ARTIFICIAL (decl);
DECL_IGNORED_P (new_decl) = DECL_IGNORED_P (decl);
TREE_THIS_VOLATILE (new_decl) = TREE_THIS_VOLATILE (decl);
@@ -1209,7 +1211,8 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
{
tree c, decl;
decl = get_chain_decl (info);
- c = build_omp_clause (OMP_CLAUSE_FIRSTPRIVATE);
+ c = build_omp_clause (gimple_location (stmt),
+ OMP_CLAUSE_FIRSTPRIVATE);
OMP_CLAUSE_DECL (c) = decl;
OMP_CLAUSE_CHAIN (c) = gimple_omp_taskreg_clauses (stmt);
gimple_omp_taskreg_set_clauses (stmt, c);
@@ -1302,9 +1305,9 @@ get_local_debug_decl (struct nesting_info *info, tree decl, tree field)
x = info->frame_decl;
x = build3 (COMPONENT_REF, TREE_TYPE (field), x, field, NULL_TREE);
- new_decl = build_decl (VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+ new_decl = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
DECL_CONTEXT (new_decl) = info->context;
- DECL_SOURCE_LOCATION (new_decl) = DECL_SOURCE_LOCATION (decl);
DECL_ARTIFICIAL (new_decl) = DECL_ARTIFICIAL (decl);
DECL_IGNORED_P (new_decl) = DECL_IGNORED_P (decl);
TREE_THIS_VOLATILE (new_decl) = TREE_THIS_VOLATILE (decl);
@@ -1616,7 +1619,8 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
{
tree c;
(void) get_frame_type (info);
- c = build_omp_clause (OMP_CLAUSE_SHARED);
+ c = build_omp_clause (gimple_location (stmt),
+ OMP_CLAUSE_SHARED);
OMP_CLAUSE_DECL (c) = info->frame_decl;
OMP_CLAUSE_CHAIN (c) = gimple_omp_taskreg_clauses (stmt);
gimple_omp_taskreg_set_clauses (stmt, c);
@@ -1728,7 +1732,7 @@ convert_nl_goto_reference (gimple_stmt_iterator *gsi, bool *handled_ops_p,
slot = pointer_map_insert (i->var_map, label);
if (*slot == NULL)
{
- new_label = create_artificial_label ();
+ new_label = create_artificial_label (UNKNOWN_LOCATION);
DECL_NONLOCAL (new_label) = 1;
*slot = new_label;
}
@@ -1960,8 +1964,9 @@ convert_gimple_call (gimple_stmt_iterator *gsi, bool *handled_ops_p,
break;
if (c == NULL)
{
- c = build_omp_clause (i ? OMP_CLAUSE_FIRSTPRIVATE
- : OMP_CLAUSE_SHARED);
+ c = build_omp_clause (gimple_location (stmt),
+ i ? OMP_CLAUSE_FIRSTPRIVATE
+ : OMP_CLAUSE_SHARED);
OMP_CLAUSE_DECL (c) = decl;
OMP_CLAUSE_CHAIN (c) = gimple_omp_taskreg_clauses (stmt);
gimple_omp_taskreg_set_clauses (stmt, c);
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 2ec26196bc1..fb4d1df7cdb 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -545,7 +545,8 @@ initialize_reductions (void **slot, void *data)
bvar = create_tmp_var (type, "reduction");
add_referenced_var (bvar);
- c = build_omp_clause (OMP_CLAUSE_REDUCTION);
+ c = build_omp_clause (gimple_location (reduc->reduc_stmt),
+ OMP_CLAUSE_REDUCTION);
OMP_CLAUSE_REDUCTION_CODE (c) = reduc->reduction_code;
OMP_CLAUSE_DECL (c) = SSA_NAME_VAR (gimple_assign_lhs (reduc->reduc_stmt));
@@ -852,7 +853,8 @@ add_field_for_reduction (void **slot, void *data)
struct reduction_info *const red = (struct reduction_info *) *slot;
tree const type = (tree) data;
tree var = SSA_NAME_VAR (gimple_assign_lhs (red->reduc_stmt));
- tree field = build_decl (FIELD_DECL, DECL_NAME (var), TREE_TYPE (var));
+ tree field = build_decl (gimple_location (red->reduc_stmt),
+ FIELD_DECL, DECL_NAME (var), TREE_TYPE (var));
insert_field_into_struct (type, field);
@@ -871,7 +873,8 @@ add_field_for_name (void **slot, void *data)
tree type = (tree) data;
tree name = ssa_name (elt->version);
tree var = SSA_NAME_VAR (name);
- tree field = build_decl (FIELD_DECL, DECL_NAME (var), TREE_TYPE (var));
+ tree field = build_decl (DECL_SOURCE_LOCATION (var),
+ FIELD_DECL, DECL_NAME (var), TREE_TYPE (var));
insert_field_into_struct (type, field);
elt->field = field;
@@ -1204,7 +1207,8 @@ separate_decls_in_region (edge entry, edge exit, htab_t reduction_list,
{
/* Create the type for the structure to store the ssa names to. */
type = lang_hooks.types.make_type (RECORD_TYPE);
- type_name = build_decl (TYPE_DECL, create_tmp_var_name (".paral_data"),
+ type_name = build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, create_tmp_var_name (".paral_data"),
type);
TYPE_NAME (type) = type_name;
@@ -1284,7 +1288,8 @@ create_loop_fn (void)
name = get_identifier (tname);
type = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
- decl = build_decl (FUNCTION_DECL, name, type);
+ decl = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, name, type);
if (!parallelized_functions)
parallelized_functions = BITMAP_GGC_ALLOC ();
bitmap_set_bit (parallelized_functions, DECL_UID (decl));
@@ -1299,12 +1304,14 @@ create_loop_fn (void)
DECL_CONTEXT (decl) = NULL_TREE;
DECL_INITIAL (decl) = make_node (BLOCK);
- t = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
+ t = build_decl (BUILTINS_LOCATION,
+ RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_IGNORED_P (t) = 1;
DECL_RESULT (decl) = t;
- t = build_decl (PARM_DECL, get_identifier (".paral_data_param"),
+ t = build_decl (BUILTINS_LOCATION,
+ PARM_DECL, get_identifier (".paral_data_param"),
ptr_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_ARG_TYPE (t) = ptr_type_node;
@@ -1566,7 +1573,7 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
paral_bb = single_pred (bb);
gsi = gsi_last_bb (paral_bb);
- t = build_omp_clause (OMP_CLAUSE_NUM_THREADS);
+ t = build_omp_clause (BUILTINS_LOCATION, OMP_CLAUSE_NUM_THREADS);
OMP_CLAUSE_NUM_THREADS_EXPR (t)
= build_int_cst (integer_type_node, n_threads);
stmt = gimple_build_omp_parallel (NULL, t, loop_fn, data);
@@ -1637,7 +1644,7 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
/* Emit GIMPLE_OMP_FOR. */
gimple_cond_set_lhs (cond_stmt, cvar_base);
type = TREE_TYPE (cvar);
- t = build_omp_clause (OMP_CLAUSE_SCHEDULE);
+ t = build_omp_clause (BUILTINS_LOCATION, OMP_CLAUSE_SCHEDULE);
OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_STATIC;
for_stmt = gimple_build_omp_for (NULL, t, 1, NULL);
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index 8ffedf1823e..95ab49a7543 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -75,7 +75,7 @@ tree_init_ic_make_global_vars (void)
ptr_void = build_pointer_type (void_type_node);
ic_void_ptr_var
- = build_decl (VAR_DECL,
+ = build_decl (UNKNOWN_LOCATION, VAR_DECL,
get_identifier ("__gcov_indirect_call_callee"),
ptr_void);
TREE_STATIC (ic_void_ptr_var) = 1;
@@ -86,7 +86,7 @@ tree_init_ic_make_global_vars (void)
gcov_type_ptr = build_pointer_type (get_gcov_type ());
ic_gcov_type_ptr_var
- = build_decl (VAR_DECL,
+ = build_decl (UNKNOWN_LOCATION, VAR_DECL,
get_identifier ("__gcov_indirect_call_counters"),
gcov_type_ptr);
TREE_STATIC (ic_gcov_type_ptr_var) = 1;
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index fb6eb4da209..3c88766a998 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1048,7 +1048,8 @@ ccp_fold (gimple stmt)
if (!useless_type_conversion_p (TREE_TYPE (lhs),
TREE_TYPE (op0))
&& ((tem = maybe_fold_offset_to_address
- (op0, integer_zero_node, TREE_TYPE (lhs)))
+ (gimple_location (stmt),
+ op0, integer_zero_node, TREE_TYPE (lhs)))
!= NULL_TREE))
return tem;
return op0;
@@ -1085,8 +1086,8 @@ ccp_fold (gimple stmt)
&& TREE_CODE (op1) == INTEGER_CST)
{
tree lhs = gimple_assign_lhs (stmt);
- tree tem = maybe_fold_offset_to_address (op0, op1,
- TREE_TYPE (lhs));
+ tree tem = maybe_fold_offset_to_address
+ (gimple_location (stmt), op0, op1, TREE_TYPE (lhs));
if (tem != NULL_TREE)
return tem;
}
@@ -1644,10 +1645,13 @@ struct gimple_opt_pass pass_ccp =
/* A subroutine of fold_stmt. Attempts to fold *(A+O) to A[X].
BASE is an array type. OFFSET is a byte displacement. ORIG_TYPE
- is the desired result type. */
+ is the desired result type.
+
+ LOC is the location of the original expression. */
static tree
-maybe_fold_offset_to_array_ref (tree base, tree offset, tree orig_type,
+maybe_fold_offset_to_array_ref (location_t loc, tree base, tree offset,
+ tree orig_type,
bool allow_negative_idx)
{
tree min_idx, idx, idx_type, elt_offset = integer_zero_node;
@@ -1780,16 +1784,23 @@ maybe_fold_offset_to_array_ref (tree base, tree offset, tree orig_type,
&& compare_tree_int (idx, 0) < 0)
return NULL_TREE;
- return build4 (ARRAY_REF, elt_type, base, idx, NULL_TREE, NULL_TREE);
+ {
+ tree t = build4 (ARRAY_REF, elt_type, base, idx, NULL_TREE, NULL_TREE);
+ SET_EXPR_LOCATION (t, loc);
+ return t;
+ }
}
/* Attempt to fold *(S+O) to S.X.
BASE is a record type. OFFSET is a byte displacement. ORIG_TYPE
- is the desired result type. */
+ is the desired result type.
+
+ LOC is the location of the original expression. */
static tree
-maybe_fold_offset_to_component_ref (tree record_type, tree base, tree offset,
+maybe_fold_offset_to_component_ref (location_t loc, tree record_type,
+ tree base, tree offset,
tree orig_type, bool base_is_ptr)
{
tree f, t, field_type, tail_array_field, field_offset;
@@ -1872,14 +1883,16 @@ maybe_fold_offset_to_component_ref (tree record_type, tree base, tree offset,
new_base = build1 (INDIRECT_REF, record_type, base);
else
new_base = base;
+ protected_set_expr_location (new_base, loc);
new_base = build3 (COMPONENT_REF, field_type, new_base, f, NULL_TREE);
+ protected_set_expr_location (new_base, loc);
/* Recurse to possibly find the match. */
- ret = maybe_fold_offset_to_array_ref (new_base, t, orig_type,
+ ret = maybe_fold_offset_to_array_ref (loc, new_base, t, orig_type,
f == TYPE_FIELDS (record_type));
if (ret)
return ret;
- ret = maybe_fold_offset_to_component_ref (field_type, new_base, t,
+ ret = maybe_fold_offset_to_component_ref (loc, field_type, new_base, t,
orig_type, false);
if (ret)
return ret;
@@ -1895,25 +1908,32 @@ maybe_fold_offset_to_component_ref (tree record_type, tree base, tree offset,
/* If we get here, we've got an aggregate field, and a possibly
nonzero offset into them. Recurse and hope for a valid match. */
if (base_is_ptr)
- base = build1 (INDIRECT_REF, record_type, base);
+ {
+ base = build1 (INDIRECT_REF, record_type, base);
+ SET_EXPR_LOCATION (base, loc);
+ }
base = build3 (COMPONENT_REF, field_type, base, f, NULL_TREE);
+ SET_EXPR_LOCATION (base, loc);
- t = maybe_fold_offset_to_array_ref (base, offset, orig_type,
+ t = maybe_fold_offset_to_array_ref (loc, base, offset, orig_type,
f == TYPE_FIELDS (record_type));
if (t)
return t;
- return maybe_fold_offset_to_component_ref (field_type, base, offset,
+ return maybe_fold_offset_to_component_ref (loc, field_type, base, offset,
orig_type, false);
}
/* Attempt to express (ORIG_TYPE)BASE+OFFSET as BASE->field_of_orig_type
- or BASE[index] or by combination of those.
+ or BASE[index] or by combination of those.
+
+ LOC is the location of original expression.
Before attempting the conversion strip off existing ADDR_EXPRs and
handled component refs. */
tree
-maybe_fold_offset_to_reference (tree base, tree offset, tree orig_type)
+maybe_fold_offset_to_reference (location_t loc, tree base, tree offset,
+ tree orig_type)
{
tree ret;
tree type;
@@ -1960,13 +1980,17 @@ maybe_fold_offset_to_reference (tree base, tree offset, tree orig_type)
return NULL_TREE;
type = TREE_TYPE (TREE_TYPE (base));
}
- ret = maybe_fold_offset_to_component_ref (type, base, offset,
+ ret = maybe_fold_offset_to_component_ref (loc, type, base, offset,
orig_type, base_is_ptr);
if (!ret)
{
if (base_is_ptr)
- base = build1 (INDIRECT_REF, type, base);
- ret = maybe_fold_offset_to_array_ref (base, offset, orig_type, true);
+ {
+ base = build1 (INDIRECT_REF, type, base);
+ SET_EXPR_LOCATION (base, loc);
+ }
+ ret = maybe_fold_offset_to_array_ref (loc,
+ base, offset, orig_type, true);
}
return ret;
}
@@ -1974,17 +1998,21 @@ maybe_fold_offset_to_reference (tree base, tree offset, tree orig_type)
/* Attempt to express (ORIG_TYPE)&BASE+OFFSET as &BASE->field_of_orig_type
or &BASE[index] or by combination of those.
+ LOC is the location of the original expression.
+
Before attempting the conversion strip off existing component refs. */
tree
-maybe_fold_offset_to_address (tree addr, tree offset, tree orig_type)
+maybe_fold_offset_to_address (location_t loc, tree addr, tree offset,
+ tree orig_type)
{
tree t;
gcc_assert (POINTER_TYPE_P (TREE_TYPE (addr))
&& POINTER_TYPE_P (orig_type));
- t = maybe_fold_offset_to_reference (addr, offset, TREE_TYPE (orig_type));
+ t = maybe_fold_offset_to_reference (loc, addr, offset,
+ TREE_TYPE (orig_type));
if (t != NULL_TREE)
{
tree orig = addr;
@@ -2021,7 +2049,9 @@ maybe_fold_offset_to_address (tree addr, tree offset, tree orig_type)
ptr_type = build_pointer_type (TREE_TYPE (t));
if (!useless_type_conversion_p (orig_type, ptr_type))
return NULL_TREE;
- return build_fold_addr_expr_with_type (t, ptr_type);
+ t = build_fold_addr_expr_with_type (t, ptr_type);
+ protected_set_expr_location (t, loc);
+ return t;
}
return NULL_TREE;
@@ -2035,6 +2065,7 @@ maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
{
tree t;
bool volatile_p = TREE_THIS_VOLATILE (expr);
+ location_t loc = EXPR_LOCATION (expr);
/* We may well have constructed a double-nested PLUS_EXPR via multiple
substitutions. Fold that down to one. Remove NON_LVALUE_EXPRs that
@@ -2075,7 +2106,7 @@ maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
return DECL_INITIAL (base);
/* Try folding *(&B+O) to B.X. */
- t = maybe_fold_offset_to_reference (base_addr, offset,
+ t = maybe_fold_offset_to_reference (loc, base_addr, offset,
TREE_TYPE (expr));
if (t)
{
@@ -2114,7 +2145,7 @@ maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
/* Try folding *(B+O) to B->X. Still an improvement. */
if (POINTER_TYPE_P (TREE_TYPE (base)))
{
- t = maybe_fold_offset_to_reference (base, offset,
+ t = maybe_fold_offset_to_reference (loc, base, offset,
TREE_TYPE (expr));
if (t)
return t;
@@ -2139,7 +2170,7 @@ maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
which may be able to propagate further. */
tree
-maybe_fold_stmt_addition (tree res_type, tree op0, tree op1)
+maybe_fold_stmt_addition (location_t loc, tree res_type, tree op0, tree op1)
{
tree ptd_type;
tree t;
@@ -2236,12 +2267,15 @@ maybe_fold_stmt_addition (tree res_type, tree op0, tree op1)
ptd_type = TREE_TYPE (TREE_TYPE (op0));
/* At which point we can try some of the same things as for indirects. */
- t = maybe_fold_offset_to_array_ref (op0, op1, ptd_type, true);
+ t = maybe_fold_offset_to_array_ref (loc, op0, op1, ptd_type, true);
if (!t)
- t = maybe_fold_offset_to_component_ref (TREE_TYPE (op0), op0, op1,
+ t = maybe_fold_offset_to_component_ref (loc, TREE_TYPE (op0), op0, op1,
ptd_type, false);
if (t)
- t = build1 (ADDR_EXPR, res_type, t);
+ {
+ t = build1 (ADDR_EXPR, res_type, t);
+ SET_EXPR_LOCATION (t, loc);
+ }
return t;
}
@@ -2740,7 +2774,8 @@ fold_gimple_assign (gimple_stmt_iterator *si)
&& POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (stmt))))
{
tree type = gimple_expr_type (stmt);
- tree t = maybe_fold_offset_to_address (gimple_assign_rhs1 (stmt),
+ tree t = maybe_fold_offset_to_address (gimple_location (stmt),
+ gimple_assign_rhs1 (stmt),
integer_zero_node, type);
if (t)
return t;
@@ -2760,7 +2795,8 @@ fold_gimple_assign (gimple_stmt_iterator *si)
(TREE_TYPE (gimple_assign_lhs (stmt)), type))
type = TREE_TYPE (gimple_assign_rhs1 (stmt));
}
- result = maybe_fold_stmt_addition (type,
+ result = maybe_fold_stmt_addition (gimple_location (stmt),
+ type,
gimple_assign_rhs1 (stmt),
gimple_assign_rhs2 (stmt));
}
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 8cf6ea12c1a..bbce3304c4e 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -874,7 +874,8 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
of the elements in X into &x[C1 + C2/element size]. */
if (TREE_CODE (rhs2) == INTEGER_CST)
{
- tree new_rhs = maybe_fold_stmt_addition (TREE_TYPE (def_rhs),
+ tree new_rhs = maybe_fold_stmt_addition (gimple_location (use_stmt),
+ TREE_TYPE (def_rhs),
def_rhs, rhs2);
if (new_rhs)
{
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index 0f3c829713e..b12f5c17826 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -185,7 +185,8 @@ create_vop_var (void)
gcc_assert (cfun->gimple_df->vop == NULL_TREE);
- global_var = build_decl (VAR_DECL, get_identifier (".MEM"),
+ global_var = build_decl (BUILTINS_LOCATION, VAR_DECL,
+ get_identifier (".MEM"),
void_type_node);
DECL_ARTIFICIAL (global_var) = 1;
TREE_READONLY (global_var) = 0;
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 13a79dcf39a..ada47e16c08 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -1258,7 +1258,7 @@ warn_uninit (tree t, const char *gmsgid, void *data)
if (xloc.file != floc.file
|| xloc.line < floc.line
|| xloc.line > LOCATION_LINE (cfun->function_end_locus))
- inform (input_location, "%J%qD was declared here", var, var);
+ inform (location, "%J%qD was declared here", var, var);
}
}
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 6f0343fe2a5..292c49cd126 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -499,6 +499,7 @@ build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi,
tree name, cst;
gimple load;
gimple_stmt_iterator gsi = gsi_for_stmt (swtch);
+ location_t loc = gimple_location (swtch);
gcc_assert (info.default_values[num]);
@@ -517,7 +518,7 @@ build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi,
ctor = build_constructor (array_type, info.constructors[num]);
TREE_CONSTANT (ctor) = true;
- decl = build_decl (VAR_DECL, NULL_TREE, array_type);
+ decl = build_decl (loc, VAR_DECL, NULL_TREE, array_type);
TREE_STATIC (decl) = 1;
DECL_INITIAL (decl) = ctor;
@@ -665,9 +666,9 @@ fix_phi_nodes (edge e1f, edge e2f, basic_block bbf)
static void
gen_inbound_check (gimple swtch)
{
- tree label_decl1 = create_artificial_label ();
- tree label_decl2 = create_artificial_label ();
- tree label_decl3 = create_artificial_label ();
+ tree label_decl1 = create_artificial_label (UNKNOWN_LOCATION);
+ tree label_decl2 = create_artificial_label (UNKNOWN_LOCATION);
+ tree label_decl3 = create_artificial_label (UNKNOWN_LOCATION);
gimple label1, label2, label3;
tree utype;
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index a0f4c3d2f3a..41a1beb2f2f 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -4971,7 +4971,7 @@ insert_range_assertions (void)
IGNORE_OFF_BY_ONE is true if the ARRAY_REF is inside a ADDR_EXPR. */
static void
-check_array_ref (tree ref, location_t location, bool ignore_off_by_one)
+check_array_ref (location_t location, tree ref, bool ignore_off_by_one)
{
value_range_t* vr = NULL;
tree low_sub, up_sub;
@@ -5067,7 +5067,7 @@ search_for_addr_array (tree t, location_t location)
do
{
if (TREE_CODE (t) == ARRAY_REF)
- check_array_ref (t, location, true /*ignore_off_by_one*/);
+ check_array_ref (location, t, true /*ignore_off_by_one*/);
t = TREE_OPERAND (t, 0);
}
@@ -5085,16 +5085,24 @@ check_array_bounds (tree *tp, int *walk_subtree, void *data)
{
tree t = *tp;
struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
- const location_t *location = (const location_t *) wi->info;
+ location_t location;
+
+ if (EXPR_HAS_LOCATION (t))
+ location = EXPR_LOCATION (t);
+ else
+ {
+ location_t *locp = (location_t *) wi->info;
+ location = *locp;
+ }
*walk_subtree = TRUE;
if (TREE_CODE (t) == ARRAY_REF)
- check_array_ref (t, *location, false /*ignore_off_by_one*/);
+ check_array_ref (location, t, false /*ignore_off_by_one*/);
if (TREE_CODE (t) == INDIRECT_REF
|| (TREE_CODE (t) == RETURN_EXPR && TREE_OPERAND (t, 0)))
- search_for_addr_array (TREE_OPERAND (t, 0), *location);
+ search_for_addr_array (TREE_OPERAND (t, 0), location);
if (TREE_CODE (t) == ADDR_EXPR)
*walk_subtree = FALSE;
diff --git a/gcc/tree.c b/gcc/tree.c
index 352c5534348..eb1ad157cfa 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -2352,6 +2352,7 @@ save_expr (tree expr)
return t;
t = build1 (SAVE_EXPR, TREE_TYPE (expr), t);
+ SET_EXPR_LOCATION (t, EXPR_LOCATION (expr));
/* This expression might be placed ahead of a jump to ensure that the
value was computed on both sides of the jump. So make sure it isn't
@@ -3537,15 +3538,19 @@ build_nt_call_vec (tree fn, VEC(tree,gc) *args)
/* Create a DECL_... node of code CODE, name NAME and data type TYPE.
We do NOT enter this node in any sort of symbol table.
+ LOC is the location of the decl.
+
layout_decl is used to set up the decl's storage layout.
Other slots are initialized to 0 or null pointers. */
tree
-build_decl_stat (enum tree_code code, tree name, tree type MEM_STAT_DECL)
+build_decl_stat (location_t loc, enum tree_code code, tree name,
+ tree type MEM_STAT_DECL)
{
tree t;
t = make_node_stat (code PASS_MEM_STAT);
+ DECL_SOURCE_LOCATION (t) = loc;
/* if (type == error_mark_node)
type = integer_type_node; */
@@ -3567,7 +3572,7 @@ tree
build_fn_decl (const char *name, tree type)
{
tree id = get_identifier (name);
- tree decl = build_decl (FUNCTION_DECL, id, type);
+ tree decl = build_decl (input_location, FUNCTION_DECL, id, type);
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
@@ -6336,7 +6341,8 @@ build_complex_type (tree component_type)
name = 0;
if (name != 0)
- TYPE_NAME (t) = build_decl (TYPE_DECL, get_identifier (name), t);
+ TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
+ get_identifier (name), t);
}
return build_qualified_type (t, TYPE_QUALS (component_type));
@@ -7451,7 +7457,8 @@ make_vector_type (tree innertype, int nunits, enum machine_mode mode)
build_index_type (index));
tree rt = make_node (RECORD_TYPE);
- TYPE_FIELDS (rt) = build_decl (FIELD_DECL, get_identifier ("f"), array);
+ TYPE_FIELDS (rt) = build_decl (UNKNOWN_LOCATION, FIELD_DECL,
+ get_identifier ("f"), array);
DECL_CONTEXT (TYPE_FIELDS (rt)) = rt;
layout_type (rt);
TYPE_DEBUG_REPRESENTATION_TYPE (t) = rt;
@@ -8139,19 +8146,22 @@ initializer_zerop (const_tree init)
}
}
-/* Build an empty statement. */
+/* Build an empty statement at location LOC. */
tree
-build_empty_stmt (void)
+build_empty_stmt (location_t loc)
{
- return build1 (NOP_EXPR, void_type_node, size_zero_node);
+ tree t = build1 (NOP_EXPR, void_type_node, size_zero_node);
+ SET_EXPR_LOCATION (t, loc);
+ return t;
}
-/* Build an OpenMP clause with code CODE. */
+/* Build an OpenMP clause with code CODE. LOC is the location of the
+ clause. */
tree
-build_omp_clause (enum omp_clause_code code)
+build_omp_clause (location_t loc, enum omp_clause_code code)
{
tree t;
int size, length;
@@ -8163,6 +8173,7 @@ build_omp_clause (enum omp_clause_code code)
memset (t, 0, size);
TREE_SET_CODE (t, OMP_CLAUSE);
OMP_CLAUSE_SET_CODE (t, code);
+ OMP_CLAUSE_LOCATION (t) = loc;
#ifdef GATHER_STATISTICS
tree_node_counts[(int) omp_clause_kind]++;
@@ -9108,13 +9119,15 @@ call_expr_arglist (tree exp)
}
-/* Create a nameless artificial label and put it in the current function
- context. Returns the newly created label. */
+/* Create a nameless artificial label and put it in the current
+ function context. The label has a location of LOC. Returns the
+ newly created label. */
tree
-create_artificial_label (void)
+create_artificial_label (location_t loc)
{
- tree lab = build_decl (LABEL_DECL, NULL_TREE, void_type_node);
+ tree lab = build_decl (loc,
+ LABEL_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (lab) = 1;
DECL_IGNORED_P (lab) = 1;
diff --git a/gcc/tree.h b/gcc/tree.h
index 3f695fddab4..f490af402ba 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1563,7 +1563,7 @@ struct GTY(()) tree_constructor {
/* True if a tree is an expression or statement that can have a
location. */
-#define CAN_HAVE_LOCATION_P(NODE) (EXPR_P (NODE))
+#define CAN_HAVE_LOCATION_P(NODE) ((NODE) && EXPR_P (NODE))
extern void protected_set_expr_location (tree, location_t);
@@ -1725,6 +1725,9 @@ extern void protected_set_expr_location (tree, location_t);
OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (OMP_CLAUSE_CHECK (NODE), \
OMP_CLAUSE_PRIVATE, \
OMP_CLAUSE_COPYPRIVATE), 0)
+#define OMP_CLAUSE_HAS_LOCATION(NODE) \
+ ((OMP_CLAUSE_CHECK (NODE))->omp_clause.locus != UNKNOWN_LOCATION)
+#define OMP_CLAUSE_LOCATION(NODE) (OMP_CLAUSE_CHECK (NODE))->omp_clause.locus
/* True on an OMP_SECTION statement that was the last lexical member.
This status is meaningful in the implementation of lastprivate. */
@@ -1919,6 +1922,7 @@ struct GTY(()) phi_arg_d {
struct GTY(()) tree_omp_clause {
struct tree_common common;
+ location_t locus;
enum omp_clause_code code;
union omp_clause_subcode {
enum omp_clause_default_kind default_kind;
@@ -3862,12 +3866,13 @@ extern tree build_tree_list_stat (tree, tree MEM_STAT_DECL);
#define build_tree_list(t,q) build_tree_list_stat(t,q MEM_STAT_INFO)
extern tree build_tree_list_vec_stat (const VEC(tree,gc) * MEM_STAT_DECL);
#define build_tree_list_vec(v) build_tree_list_vec_stat (v MEM_STAT_INFO)
-extern tree build_decl_stat (enum tree_code, tree, tree MEM_STAT_DECL);
+extern tree build_decl_stat (location_t, enum tree_code,
+ tree, tree MEM_STAT_DECL);
extern tree build_fn_decl (const char *, tree);
-#define build_decl(c,t,q) build_decl_stat (c,t,q MEM_STAT_INFO)
+#define build_decl(l,c,t,q) build_decl_stat (l,c,t,q MEM_STAT_INFO)
extern tree build_block (tree, tree, tree, tree);
-extern tree build_empty_stmt (void);
-extern tree build_omp_clause (enum omp_clause_code);
+extern tree build_empty_stmt (location_t);
+extern tree build_omp_clause (location_t, enum omp_clause_code);
extern tree build_vl_exp_stat (enum tree_code, int MEM_STAT_DECL);
#define build_vl_exp(c,n) build_vl_exp_stat (c,n MEM_STAT_INFO)
@@ -4619,7 +4624,7 @@ extern int operand_equal_for_phi_arg_p (const_tree, const_tree);
extern tree call_expr_arg (tree, int);
extern tree *call_expr_argp (tree, int);
extern tree call_expr_arglist (tree);
-extern tree create_artificial_label (void);
+extern tree create_artificial_label (location_t);
extern const char *get_name (tree);
extern bool stdarg_p (tree);
extern bool prototype_p (tree);
@@ -5169,9 +5174,9 @@ struct GTY(()) tree_priority_map {
#define tree_priority_map_marked_p tree_map_base_marked_p
/* In tree-ssa-ccp.c */
-extern tree maybe_fold_offset_to_reference (tree, tree, tree);
-extern tree maybe_fold_offset_to_address (tree, tree, tree);
-extern tree maybe_fold_stmt_addition (tree, tree, tree);
+extern tree maybe_fold_offset_to_reference (location_t, tree, tree, tree);
+extern tree maybe_fold_offset_to_address (location_t, tree, tree, tree);
+extern tree maybe_fold_stmt_addition (location_t, tree, tree, tree);
/* In tree-ssa-address.c. */
extern tree tree_mem_ref_addr (tree, tree);
diff --git a/gcc/varasm.c b/gcc/varasm.c
index c5de9ae7a73..40a47fada99 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -239,24 +239,28 @@ default_emutls_var_fields (tree type, tree *name ATTRIBUTE_UNUSED)
{
tree word_type_node, field, next_field;
- field = build_decl (FIELD_DECL, get_identifier ("__templ"), ptr_type_node);
+ field = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("__templ"), ptr_type_node);
DECL_CONTEXT (field) = type;
next_field = field;
- field = build_decl (FIELD_DECL, get_identifier ("__offset"),
+ field = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("__offset"),
ptr_type_node);
DECL_CONTEXT (field) = type;
TREE_CHAIN (field) = next_field;
next_field = field;
word_type_node = lang_hooks.types.type_for_mode (word_mode, 1);
- field = build_decl (FIELD_DECL, get_identifier ("__align"),
+ field = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("__align"),
word_type_node);
DECL_CONTEXT (field) = type;
TREE_CHAIN (field) = next_field;
next_field = field;
- field = build_decl (FIELD_DECL, get_identifier ("__size"), word_type_node);
+ field = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("__size"), word_type_node);
DECL_CONTEXT (field) = type;
TREE_CHAIN (field) = next_field;
@@ -280,7 +284,8 @@ get_emutls_object_type (void)
field = targetm.emutls.var_fields (type, &type_name);
if (!type_name)
type_name = get_identifier ("__emutls_object");
- type_name = build_decl (TYPE_DECL, type_name, type);
+ type_name = build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, type_name, type);
TYPE_NAME (type) = type_name;
TYPE_FIELDS (type) = field;
layout_type (type);
@@ -309,7 +314,8 @@ get_emutls_init_templ_addr (tree decl)
name = prefix_name (prefix, name);
}
- to = build_decl (VAR_DECL, name, TREE_TYPE (decl));
+ to = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, name, TREE_TYPE (decl));
SET_DECL_ASSEMBLER_NAME (to, DECL_NAME (to));
DECL_TLS_MODEL (to) = TLS_MODEL_EMULATED;
DECL_ARTIFICIAL (to) = 1;
@@ -369,7 +375,8 @@ emutls_decl (tree decl)
to = h->to;
else
{
- to = build_decl (VAR_DECL, get_emutls_object_name (name),
+ to = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, get_emutls_object_name (name),
get_emutls_object_type ());
h = GGC_NEW (struct tree_map);
@@ -5269,7 +5276,8 @@ weak_finish (void)
if (! decl)
{
- decl = build_decl (TREE_CODE (alias_decl), target,
+ decl = build_decl (DECL_SOURCE_LOCATION (alias_decl),
+ TREE_CODE (alias_decl), target,
TREE_TYPE (alias_decl));
DECL_EXTERNAL (decl) = 1;