diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2009-06-12 22:06:47 +0000 |
---|---|---|
committer | Aldy Hernandez <aldyh@gcc.gnu.org> | 2009-06-12 22:06:47 +0000 |
commit | c2255bc4884a7624b32185e188fdb94a4167a35c (patch) | |
tree | 67f495ddc3964a90084152e177995da72e7bce30 /gcc/c-decl.c | |
parent | 312243969e3a0022c0eabe6f974c24abd4a2211b (diff) | |
download | gcc-c2255bc4884a7624b32185e188fdb94a4167a35c.zip gcc-c2255bc4884a7624b32185e188fdb94a4167a35c.tar.gz gcc-c2255bc4884a7624b32185e188fdb94a4167a35c.tar.bz2 |
java-gimplify.c (java_gimplify_block): New argument to build_empty_stmt.
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.
From-SVN: r148442
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 574 |
1 files changed, 332 insertions, 242 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 9159b3c..03d6dbd 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", - ¤t_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", - ¤t_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); |