[PATCH] Make all usage of "input_location" be explicit

David Malcolm dmalcolm@redhat.com
Tue Jul 2 15:24:00 GMT 2013


As discussed in http://gcc.gnu.org/ml/gcc/2013-07/msg00008.html there
are four macros that create implicit uses of the input_location global.

I'm attaching a patch which removes these macros.

The patch converts most uses of the macros to a simple expansion of the
former definition, making the use of the input_location global explicit
(with line-length cleanups as necessary, sometimes introducing a
temporary when the same location is repeatedly used, etc).

In 7 places in c/c-decl.c there was a use of in_system_header where the
location was available in a different variable (or, at least, is used by
appropriately guarded code), allowing the removal of a use of
input_location in the patch.  Specifically:
  * (define_label): use the "location_t location" param
  * (grokdeclarator): use of "location_t loc" local:
    * line 5032: loc is used in the subsequent pedwarn_c99 calls
    * line 5299: loc is used in the directly guarded pedwarn call
    * line 5469: likewise
  * (build_enumerator): conversion of EXPR_LOC_OR_HERE to
    EXPR_LOC_OR_LOC using the "location_t loc" param
  * (store_parm_decls_newstyle):  conversion of in_system_header to use
    DECL_IN_SYSTEM_HEADER (fndecl), given that the guarded warning_at
    call uses DECL_SOURCE_LOCATION (fndecl)
  * (store_parm_decls_oldstyle): likewise.
  * (declspecs_add_type): use the "location_t loc" param

Successfully bootstrapped on x86_64-unknown-linux-gnu, and all testcases
show same results as an unpatched build (relative to r200588), with the
bizarre exception of:

  Tests that now work, but didn't before:

  g++.dg/ext/mv5.C -std=gnu++11 execution test
  g++.dg/ext/mv5.C -std=gnu++98 execution test

which appears to have been some kind of glitch in the *unpatched* build;
upon manually rerunning them they pass (32-core parallel build, maybe
some kind of race in the test harness?)

OK for trunk?

gcc/
2013-07-02  David Malcolm  <dmalcolm@redhat.com>

	* builtins.c (c_strlen): Remove use of EXPR_LOC_OR_HERE macro.
	* config/bfin/bfin.c (output_file_start): Remove use of
	input_filename macro.
	* gimplify.c (internal_get_tmp_var): Remove use of
	EXPR_LOC_OR_HERE macro.
	(shortcut_cond_expr)
	* input.h (input_line): Remove.
	(input_filename): Likewise.
	(in_system_header): Likewise.
	* tree-diagnostic.c (diagnostic_report_current_function): Remove
	use of input_filename macro.
	* tree.c (get_file_function_name): Likewise.
	* tree.h (EXPR_LOC_OR_HERE): Remove.

gcc/ada/
2013-07-02  David Malcolm  <dmalcolm@redhat.com>

	* gcc-interface/utils2.c (build_call_raise): Remove use of
	input_line macro.
	(build_call_raise_range): Likewise.
	(build_call_raise_column): Likewise.

gcc/c-family/
2013-07-02  David Malcolm  <dmalcolm@redhat.com>

	* c-common.c (unsafe_conversion_p): Remove use of
	EXPR_LOC_OR_HERE macro.
	(conversion_warning): Likewise.
	(warnings_for_convert_and_check): Likewise.
	(warn_for_collisions_1): Likewise.
	(shorten_compare): Likewise, and remove use of in_system_header
	macro, using the location from the former.
	* c-lex.c (dump_one_header): Remove use of input_filename macro.
	(cb_def_pragma): Remove use of in_system_header macro.
	(lex_string): Likewise.
	* c-pragma.c (handle_pragma_float_const_decimal64): Likewise.

gcc/c/
2013-07-02  David Malcolm  <dmalcolm@redhat.com>

	* c-decl.c (define_label): Remove use of in_system_header macro.
	(shadow_tag_warned): Likewise.
	(check_bitfield_type_and_width): Likewise.
	(grokdeclarator): Likewise.
	(grokparms): Likewise.
	(build_enumerator): Remove use of EXPR_LOC_OR_HERE macro.
	(store_parm_decls_newstyle): Remove use of in_system_header
	macro.
	(store_parm_decls_oldstyle): Likewise.
	(declspecs_add_type): Likewise.
	* c-parser.c (c_parser_set_source_position_from_token): Update
	comment.
	(c_parser_unary_expression): Remove use of in_system_header
	macro.
	* c-typeck.c: Likewise.

gcc/cp/
2013-07-02  David Malcolm  <dmalcolm@redhat.com>

	* call.c (build_integral_nontype_arg_conv): Remove use of
	EXPR_LOC_OR_HERE macro.
	(convert_like_real): Likewise.
	(convert_arg_to_ellipsis): Likewise.
	(build_cxx_call): Likewise.
	(perform_implicit_conversion_flags): Likewise.
	(initialize_reference): Likewise.
	* cvt.c (cp_convert_to_pointer): Likewise.
	(convert_to_reference): Likewise.
	(ocp_convert): Likewise.
	(convert_to_void): Likewise.
	* decl.c (pop_label): Update comment.
	(pop_switch): Remove use of EXPR_LOC_OR_HERE macro.
	(check_tag_decl): Remove use of in_system_header macro.
	(make_rtl_for_nonlocal_decl): Remove use of input_filename
	macro.
	(compute_array_index_type): Remove use of in_system_header
	macro.
	(grokdeclarator): Likewise.
	* error.c (dump_global_iord): Remove use of input_filename
	macro.
	(location_of): Remove use of EXPR_LOC_OR_HERE macro.
	(maybe_warn_cpp0x): Remove use of in_system_header macro.
	* init.c (build_new_1): Remove use of EXPR_LOC_OR_HERE macro.
	* lex.c (handle_pragma_interface): Remove use of input_filename
	macro.
	(handle_pragma_implementation): Likewise.
	(cxx_make_type): Likewise.
	(in_main_input_context): Likewise.
	* name-lookup.c (push_binding_level): Remove use of
	input_line macro.
	(leave_scope): Likewise.
	(resume_scope): Likewise.
	* parser.c (cp_parser_unqualified_id): Remove use of
	in_system_header macro.
	(cp_parser_cast_expression): Likewise.
	(cp_parser_declaration_seq_opt): Likewise.
	(cp_parser_enumerator_list): Likewise.
	(cp_parser_parameter_declaration_clause): Likewise.
	(cp_parser_exception_specification_opt): Likewise.
	* pt.c (convert_nontype_argument): Remove use of
	EXPR_LOC_OR_HERE macro.
	(push_tinst_level): Remove use of in_system_header macro.
	(tsubst_copy_and_build): Remove use of EXPR_LOC_OR_HERE
	macros.
	(do_decl_instantiation): Remove use of in_system_header macro.
	(do_type_instantiation): Likewise.
	* semantics.c (finish_call_expr): Remove use of EXPR_LOC_OR_HERE
	macro.
	(begin_class_definition): Remove use of input_filename macro.
	(cxx_eval_call_expression): Remove use of EXPR_LOC_OR_HERE
	macro.
	(cxx_eval_constant_expression): Likewise.
	(potential_constant_expression_1): Likewise.
	* typeck.c (decay_conversion): Likewise.
	(rationalize_conditional_expr): Likewise.
	(build_x_compound_expr_from_list): Likewise.
	(convert_for_assignment): Likewise.
	* typeck2.c (check_narrowing): Likewise.

gcc/fortran/
2013-07-02  David Malcolm  <dmalcolm@redhat.com>

	* trans.c (trans_runtime_error_vararg): Remove use of input_line
	macro.

gcc/java/
2013-07-02  David Malcolm  <dmalcolm@redhat.com>

	* class.c (maybe_layout_super_class): Update comment.
	* decl.c (java_add_stmt): Remove use of input_filename macro.
	* jcf-parse.c (set_source_filename): Remove use of
	input_filename macro.
	(parse_class_file): Remove use of input_line and input_filename
	macros.
	(java_parse_file): Remove use of input_filename macro.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: remove-input_location-macros.patch
Type: text/x-patch
Size: 45984 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20130702/5cfb979e/attachment.bin>


More information about the Gcc-patches mailing list