Commit Graph

46 Commits

Author SHA1 Message Date
Jakub Jelinek 5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Manuel López-Ibáñez b93c07227e line-map.c (linemap_position_for_loc_and_offset): Add new linemap_assert_fails.
libcpp/ChangeLog:

2014-12-05  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* line-map.c (linemap_position_for_loc_and_offset): Add new
	linemap_assert_fails.

gcc/fortran/ChangeLog:

2014-12-05  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* scanner.c (gfc_next_char_literal): Use gfc_warning_now.
	(load_file): Use the line length as the column hint for
	linemap_line_start. Reserve a location for the highest column of
	the line.

From-SVN: r218407
2014-12-04 23:35:29 +00:00
Manuel López-Ibáñez 73bd83290a line-map.h (linemap_assert_fails): Declare.
libcpp/ChangeLog:

2014-12-02  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* include/line-map.h (linemap_assert_fails): Declare.
	* line-map.c (linemap_position_for_loc_and_offset): Use it.

From-SVN: r218277
2014-12-02 16:03:31 +00:00
Manuel López-Ibáñez 9c320ab1f1 line-map.c (linemap_add): Fix typo.
2014-12-02  Manuel López-Ibáñez  <manu@gcc.gnu.org>

        * line-map.c (linemap_add): Fix typo.
        (linemap_line_start): Fix whitespace.

From-SVN: r218276
2014-12-02 16:00:33 +00:00
Jakub Jelinek 43ba1c6c3e re PR preprocessor/60436 (C preprocessor segfaults on assembly file)
PR preprocessor/60436
	* line-map.c (linemap_line_start): If highest is above 0x60000000
	and we are still tracking columns or highest is above 0x70000000,
	force add_map.

From-SVN: r218042
2014-11-25 12:16:27 +01:00
Manuel López-Ibáñez 3aa34c1d8f re PR fortran/44054 (Handle -Werror, -Werror=, -fdiagnostics-show-option, !GCC$ diagnostic (pragmas) and color)
libcpp/ChangeLog:

2014-11-11  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
	* include/line-map.h (linemap_position_for_loc_and_offset):
	Declare.
	* line-map.c (linemap_position_for_loc_and_offset): New.


gcc/fortran/ChangeLog:

2014-11-11  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
	* gfortran.h (warn_use_without_only): Remove.
	(gfc_diagnostics_finish): Declare.
	* error.c: Include tree-diagnostics.h
	(gfc_format_decoder): New.
	(gfc_diagnostics_init): Use gfc_format_decoder. Set default caret
	char.
	(gfc_diagnostics_finish): Restore tree diagnostics defaults, but
	keep gfc_diagnostics_starter and finalizer. Restore default caret.
	* options.c: Remove all uses of warn_use_without_only.
	* lang.opt (Wuse-without-only): Add Var.
	* f95-lang.c (gfc_be_parse_file): Call gfc_diagnostics_finish.
	* module.c (gfc_use_module): Use gfc_warning_now_2.
	* parse.c (decode_statement): Likewise.
	(decode_gcc_attribute): Likewise.
	(next_free): Likewise.
	(next_fixed): Likewise.


gcc/testsuite/ChangeLog:

2014-11-11  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
	* lib/gfortran-dg.exp: Update regexp to match locus and message
	without caret.
	* gfortran.dg/use_without_only_1.f90: Add column numbers.
        * gfortran.dg/warnings_are_errors_1.f: Update.

From-SVN: r217383
2014-11-11 22:50:48 +00:00
Manuel López-Ibáñez 3aac09524b line-map.h (linemap_location_from_macro_expansion_p): const struct line_maps * argument.
libcpp/ChangeLog:

2014-10-14  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* include/line-map.h (linemap_location_from_macro_expansion_p):
	const struct line_maps * argument.
	(linemap_position_for_line_and_column): const struct line_map *
	argument.
	* line-map.c (linemap_add_macro_token): Use correct argument name
	in comment.
	(linemap_position_for_line_and_column): const struct line_map *
	argument.
	(linemap_macro_map_loc_to_def_point): Fix comment. Make static.
	(linemap_location_from_macro_expansion_p): const struct line_maps *
	argument.
	(linemap_resolve_location): Fix argument names in comment.

From-SVN: r216205
2014-10-14 14:45:36 +00:00
Dodji Seketeli c468587ac2 Support location tracking for built-in macro tokens
When a built-in macro is expanded, the location of the token in the
epansion list is the location of the expansion point of the built-in
macro.

This patch creates a virtual location for that token instead,
effectively tracking locations of tokens resulting from built-in macro
tokens.

libcpp/
	* include/line-map.h (line_maps::builtin_location): New data
	member.
	(line_map_init): Add a new parameter to initialize the new
	line_maps::builtin_location data member.
	* line-map.c (linemap_init): Initialize the
	line_maps::builtin_location data member.
	* macro.c (builtin_macro): Create a macro map and track the token
	resulting from the expansion of a built-in macro.
gcc/
	* input.h (is_location_from_builtin_token): New function
	declaration.
	* input.c (is_location_from_builtin_token): New function
	definition.
	* toplev.c (general_init): Tell libcpp what the pre-defined
	spelling location for built-in tokens is.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>

From-SVN: r212637
2014-07-16 12:33:27 +02:00
Jakub Jelinek acf601aefd re PR preprocessor/56824 (pragma GCC diagnostic push/pop fail with GCC diagnostic ignored "-Waggregate-return")
PR preprocessor/56824
	* line-map.c (get_combined_adhoc_loc, linemap_get_expansion_line,
	linemap_get_expansion_filename, linemap_location_in_system_header_p,
	linemap_location_from_macro_expansion_p,
	linemap_macro_loc_to_spelling_point, linemap_macro_loc_to_def_point,
	linemap_macro_loc_to_exp_point, linemap_expand_location): Fix
	formatting.
	(linemap_compare_locations): Look through adhoc locations for both
	l0 and l1.

	* gcc.dg/pr56824.c: New test.

From-SVN: r207606
2014-02-07 17:42:24 +01:00
Dodji Seketeli 7ecc3eb9e6 PR preprocessor/58580 - preprocessor goes OOM with warning for zero literals
In this problem report, the compiler is fed a (bogus) translation unit
in which some literals contain bytes whose value is zero.  The
preprocessor detects that and proceeds to emit diagnostics for that
king of bogus literals.  But then when the diagnostics machinery
re-reads the input file again to display the bogus literals with a
caret, it attempts to calculate the length of each of the lines it got
using fgets.  The line length calculation is done using strlen.  But
that doesn't work well when the content of the line can have several
zero bytes.  The result is that the read_line never sees the end of
the line because strlen repeatedly reports that the line ends before
the end-of-line character; so read_line thinks its buffer for reading
the line is too small; it thus increases the buffer, leading to a huge
memory consumption and disaster.

Here is what this patch does.

location_get_source_line is modified to return the length of a source
line that can now contain bytes with zero value.
diagnostic_show_locus() is then modified to consider that a line can
have characters of value zero, and so just shows a white space when
instructed to display one of these characters.

Additionally location_get_source_line is modified to avoid re-reading
each and every line from the beginning of the file until it reaches
the line number N that it is instructed to get; this was leading to
annoying quadratic behaviour when reading adjacent lines near the end
of (big) files.  So a cache is now associated to the file opened in
text mode.  When the content of the file is read, that content is
stashed in the file cache.  That file cache is searched for line
delimiters.  A number of line positions are saved in the cache and a
number of file caches are kept in memory.  That way when
location_get_source_line is asked to read line N + 1, it just has to
start reading from line N that it has already read.

libcpp/ChangeLog:

	* include/line-map.h (linemap_get_file_highest_location): Declare
	new function.
	* line-map.c (linemap_get_file_highest_location): Define it.

gcc/ChangeLog:

	* input.h (location_get_source_line): Take an additional line_size
	parameter.
	(void diagnostics_file_cache_fini): Declare new function.
	* input.c (struct fcache): New type.
	(fcache_tab_size, fcache_buffer_size, fcache_line_record_size):
	New static constants.
	(diagnostic_file_cache_init, total_lines_num)
	(lookup_file_in_cache_tab, evicted_cache_tab_entry)
	(add_file_to_cache_tab, lookup_or_add_file_to_cache_tab)
	(needs_read, needs_grow, maybe_grow, read_data, maybe_read_data)
	(get_next_line, read_next_line, goto_next_line, read_line_num):
	New static function definitions.
	(diagnostic_file_cache_fini): New function.
	(location_get_source_line): Take an additional output line_len
	parameter.  Re-write using lookup_or_add_file_to_cache_tab and
	read_line_num.
	* diagnostic.c (diagnostic_finish): Call
	diagnostic_file_cache_fini.
	(adjust_line): Take an additional input parameter for the length
	of the line, rather than calculating it with strlen.
	(diagnostic_show_locus): Adjust the use of
	location_get_source_line and adjust_line with respect to their new
	signature.  While displaying a line now, do not stop at the first
	null byte.  Rather, display the zero byte as a space and keep
	going until we reach the size of the line.
	* Makefile.in: Add vec.o to OBJS-libcommon

gcc/testsuite/ChangeLog:

	* c-c++-common/cpp/warning-zero-in-literals-1.c: New test file.

Signed-off-by: Dodji Seketeli <dodji@seketeli.org>

From-SVN: r206957
2014-01-23 10:13:08 +01:00
Richard Sandiford 35c3d610e3 Update copyright years in libcpp/
From-SVN: r206293
2014-01-02 22:24:45 +00:00
Richard Sandiford 500f3ed906 Update copyright years in libcpp.
From-SVN: r195162
2013-01-14 18:13:59 +00:00
Marc Glisse 8ac16127cf re PR bootstrap/50167 (gmp memory functions are extern "C" (graphite))
2013-01-03  Marc Glisse  <marc.glisse@inria.fr>

	PR bootstrap/50167
gcc/
	* graphite-interchange.c (pdr_stride_in_loop): Use gmp_fprintf.
	* graphite-poly.c (debug_gmp_value): Likewise.

	PR bootstrap/50177
libcpp/
	* line-map.c (get_combined_adhoc_loc): Cast from extern "C" type.
	(new_linemap): Likewise.
	(linemap_enter_macro): Likewise.

From-SVN: r194868
2013-01-03 20:06:49 +00:00
Dehao Chen ec6e039992 re PR middle-end/54704 (three-fold increase in compile-time between r191483 and r191569)
libcpp:
	2012-09-25  Dehao Chen  <dehao@google.com>

	PR middle-end/54704
	* line-map.c (location_adhoc_data_hash): Fix the hash function.

From-SVN: r191747
2012-09-25 21:32:29 +00:00
Dehao Chen 5218700874 re PR middle-end/54645 (Many testsuite failures)
gcc:
	2012-09-25  Dehao Chen  <dehao@google.com>

	PR middle-end/54645
	* c-family/c-pch.c (c_common_read_pch): Rebuild the location_adhoc_data
	map when read in the pch.

libcpp:
	2012-09-25  Dehao Chen  <dehao@google.com>

	PR middle-end/54645
	* include/line-map.h (location_adhoc_data): Move location_adhoc_data
	into GC.
	(location_adhoc_data_map): Likewise.
	(line_maps): Likewise.
	(rebuild_location_adhoc_htab): New Function.
	* line-map.c (+rebuild_location_adhoc_htab): new Funcion.
	(get_combined_adhoc_loc): Move location_adhoc_data into GC.
	(location_adhoc_data_fini): Likewise.
	(linemap_init): Likewise.
	(location_adhoc_data_init): Remove Function.

From-SVN: r191706
2012-09-25 13:19:33 +00:00
Dehao Chen 5368224f42 Integrate lexical block into source_location.
gcc:
	2012-09-19  Dehao Chen  <dehao@google.com>

	* toplev.c (general_init): Init block_locations.
	* tree.c (tree_set_block): New.
	(tree_block): Change to use LOCATION_BLOCK.
	* tree.h (TREE_SET_BLOCK): New.
	* final.c (reemit_insn_block_notes): Change to use LOCATION_BLOCK.
	(final_start_function): Likewise.
	* input.c (expand_location_1): Likewise.
	* input.h (LOCATION_LOCUS): New.
	(LOCATION_BLOCK): New.
	(IS_UNKNOWN_LOCATION): New.
	* fold-const.c (expr_location_or): Change to use new location.
	* reorg.c (emit_delay_sequence): Likewise.
	(try_merge_delay_insns): Likewise.
	* modulo-sched.c (dump_insn_location): Likewise.
	* lto-streamer-out.c (lto_output_location_bitpack): Likewise.
	* lto-cgraph.c (output_node_opt_summary): Likewise.
	* jump.c (rtx_renumbered_equal_p): Likewise.
	* ifcvt.c (noce_try_move): Likewise.
	(noce_try_store_flag): Likewise.
	(noce_try_store_flag_constants): Likewise.
	(noce_try_addcc): Likewise.
	(noce_try_store_flag_mask): Likewise.
	(noce_try_cmove): Likewise.
	(noce_try_cmove_arith): Likewise.
	(noce_try_minmax): Likewise.
	(noce_try_abs): Likewise.
	(noce_try_sign_mask): Likewise.
	(noce_try_bitop): Likewise.
	(noce_process_if_block): Likewise.
	(cond_move_process_if_block): Likewise.
	(find_cond_trap): Likewise.
	* ipa-prop.c (ipa_set_jf_constant): Likewise.
	(ipa_write_jump_function): Likewise.
	* dwarf2out.c (add_src_coords_attributes): Likewise.
	* expr.c (expand_expr_real): Likewise.
	* tree-parloops.c (create_loop_fn): Likewise.
	* recog.c (peep2_attempt): Likewise.
	* function.c (free_after_compilation): Likewise.
	(expand_function_end): Likewise.
	(set_insn_locations): Likewise.
	(thread_prologue_and_epilogue_insns): Likewise.
	* print-rtl.c (print_rtx): Likewise.
	* profile.c (branch_prob): Likewise.
	* trans-mem.c (ipa_tm_scan_irr_block): Likewise.
	* gimplify.c (gimplify_call_expr): Likewise.
	* except.c (duplicate_eh_regions_1): Likewise.
	* emit-rtl.c (try_split): Likewise.
	(make_insn_raw): Likewise.
	(make_debug_insn_raw): Likewise.
	(make_jump_insn_raw): Likewise.
	(make_call_insn_raw): Likewise.
	(emit_pattern_after_setloc): Likewise.
	(emit_pattern_after): Likewise.
	(emit_debug_insn_after): Likewise.
	(emit_pattern_before): Likewise.
	(emit_insn_before_setloc): Likewise.
	(emit_jump_insn_before): Likewise.
	(emit_call_insn_before_setloc): Likewise.
	(emit_call_insn_before): Likeise.
	(emit_debug_insn_before_setloc): Likewise.
	(emit_copy_of_insn_after): Likewise.
	(insn_locators_alloc): Remove.
	(insn_locators_finalize): Remove.
	(insn_locators_free): Remove.
	(set_curr_insn_source_location): Remove.
	(get_curr_insn_source_location): Remove.
	(set_curr_insn_block): Remove.
	(get_curr_insn_block): Remove.
	(locator_scope): Remove.
	(insn_scope): Change to use new location.
	(locator_location): Remove.
	(insn_line): Change to use new location.
	(locator_file): Remove.
	(insn_file): Change to use new location.
	(locator_eq): Remove.
	(insn_locations_init): New.
	(insn_locations_finalize): New.
	(set_curr_insn_location): New.
	(curr_insn_location): New.
	* cfgexpand.c (gimple_assign_rhs_to_tree): Change to use new location.
	(expand_gimple_cond): Likewise.
	(expand_call_stmt): Likewise.
	(expand_gimple_stmt_1): Likewise.
	(expand_gimple_basic_block): Likewise.
	(construct_exit_block): Likewise.
	(gimple_expand_cfg): Likewise.
	* cfgcleanup.c (try_forward_edges): Likewise.
	* tree-ssa-live.c (remove_unused_scope_block_p): Likewise.
	(dump_scope_block): Likewise.
	(remove_unused_locals): Likewise.
	* rtl.c (rtx_equal_p_cb): Likewise.
	(rtx_equal_p): Likewise.
	* rtl.h (XUINT): New.
	(INSN_LOCATOR): Remove.
	(CURR_INSN_LOCATION): Remove.
	(INSN_LOCATION): New.
	(INSN_HAS_LOCATION): New.
	* tree-inline.c (remap_gimple_op_r): Change to use new location.
	(copy_tree_body_r): Likewise.
	(copy_phis_for_bb): Likewise.
	(expand_call_inline): Likewise.
	* tree-streamer-in.c (lto_input_ts_exp_tree_pointers): Likewise.
	* tree-streamer-out.c (write_ts_decl_minimal_tree_pointers): Likewise.
	* gimple-streamer-out.c (output_gimple_stmt): Likewise.
	* combine.c (try_combine): Likewise.
	* tree-outof-ssa.c (set_location_for_edge): Likewise.
	(insert_partition_copy_on_edge): Likewise.
	(insert_value_copy_on_edge): Likewise.
	(insert_rtx_to_part_on_edge): Likewise.
	(insert_part_to_rtx_on_edge): Likewise.
	* basic-block.h (edge_def): Remove field.
	* gimple.h (gimple_statement_base): Remove field.
	(gimple_bb): Change to use new location.
	(gimple_set_block): Likewise.
	(gimple_has_location): Likewise.
	* tree-cfg.c (make_cond_expr_edges): Likewise.
	(make_goto_expr_edges): Likewise.
	(gimple_can_merge_blocks_p): Likewise.
	(move_stmt_op): Likewise.
	(move_block_to_fn): Likewise.
	* config/alpha/alpha.c (alpha_output_mi_thunk_osf): Likewise.
	* config/sparc/sparc.c (sparc_output_mi_thunk): Likewise.
	* config/i386/i386.c (x86_output_mi_thunk): Likewise.
	* config/tilegx/tilegx.c (tilegx_output_mi_thunk): Likewise.
	* config/sh/sh.c (sh_output_mi_thunk): Likewise.
	* config/ia64/ia64.c (ia64_output_mi_thunk): Likewise.
	* config/rs6000/rs6000.c (rs6000_output_mi_thunk): Likewise.
	* config/score/score.c (score_output_mi_thunk): Likewise.
	* config/tilepro/tilepro.c (tilepro_asm_output_mi_thunk): Likewise.
	* config/mips/mips.c (mips_output_mi_thunk): Likewise.
	* cfgrtl.c (unique_locus_on_edge_between_p): Likewise.
	(unique_locus_on_edge_between_p): Likewise.
	(emit_nop_for_unique_locus_between): Likewise.
	(force_nonfallthru_and_redirect): Likewise.
	(fixup_reorder_chain): Likewise.
	(cfg_layout_merge_blocks): Likewise.
	* stmt.c (emit_case_nodes): Likewise.

gcc/lto:
	2012-09-19  Dehao Chen  <dehao@google.com>

	* lto/lto.c (lto_fixup_prevailing_decls): Remove tree.exp.block field.

libcpp:
	2012-09-19  Dehao Chen  <dehao@google.com>

	* include/line-map.h (MAX_SOURCE_LOCATION): New value.
	(location_adhoc_data_fini): New.
	(get_combined_adhoc_loc): New.
	(get_data_from_adhoc_loc): New.
	(get_location_from_adhoc_loc): New.
	(location_adhoc_data_map): New.
	(COMBINE_LOCATION_DATA): New.
	(IS_ADHOC_LOC): New.
	(expanded_location): New field.
	(line_maps): New field.
	* line-map.c (location_adhoc_data): New.
	(location_adhoc_data_hash): New.
	(location_adhoc_data_eq): New.
	(location_adhoc_data_update): New.
	(get_combined_adhoc_loc): New.
	(get_data_from_adhoc_loc): New.
	(get_location_from_adhoc_loc): New.
	(location_adhoc_data_init): New.
	(location_adhoc_data_fini): New.
	(linemap_init): Initialize location_adhoc_data.
	(linemap_lookup): Change to use new location.
	(linemap_ordinary_map_lookup): Likewise.
	(linemap_macro_map_lookup): Likewise.
	(linemap_macro_map_loc_to_def_point): Likewise.
	(linemap_macro_map_loc_unwind_toward_spel): Likewise.
	(linemap_get_expansion_line): Likewise.
	(linemap_get_expansion_filename): Likewise.
	(linemap_location_in_system_header_p): Likewise.
	(linemap_location_from_macro_expansion_p): Likewise.
	(linemap_macro_loc_to_spelling_point): Likewise.
	(linemap_macro_loc_to_def_point): Likewise.
	(linemap_macro_loc_to_exp_point): Likewise.
	(linemap_resolve_location): Likewise.
	(linemap_unwind_toward_expansion): Likewise.
	(linemap_unwind_to_first_non_reserved_loc): Likewise.
	(linemap_expand_location): Likewise.
	(linemap_dump_location): Likewise.
	(linemap_line_start): Likewise.

From-SVN: r191494
2012-09-19 19:56:42 +00:00
Dimitrios Apostolou d86d21192b line-map.c (linemap_enter_macro): Don't zero max_column_hint in every macro.
* line-map.c (linemap_enter_macro): Don't zero max_column_hint in
 	every macro. This improves performance by reducing the number of
 	reallocations when track-macro-expansion is on.

From-SVN: r188242
2012-06-05 10:25:46 -04:00
Dodji Seketeli 7ca643e17e PR preprocessor/53463 - Fix system header detection for built-in macro tokens
The location for a built-in macro token is BUILTIN_LOCATION.  When we
see that location value, we cannot know if that token was used in a
system header or not.  And that can trigger some unwanted warnings on
e.g, the use of __LONG_LONG_MAX__ built-in macro in system headers
when we compile with -pedantic, like in the test case accompanying
this patch.

In that case, I think we ought to step-up to see where the built-in
macro has been expanded, until we see a location that is not for a
built-in macro.  Then we can check if the resulting location is in a
system header or not.

Now that we step up to the location of first non-built-in-macro token,
it appeared that for
testsuite/c-c++-common/dfp/convert-int-saturate.c, G++ then fails to
emit the warning in:

    volatile unsigned int usi;
    int
    main ()
    {
      usi = DEC32_MAX;  /* { dg-warning "overflow in implicit constant conversion" } */
     ...
    }

Because DEC32_MAX is defined in the system header float.h as a
built-in macro:

    #define DEC32_MAX	__DEC32_MAX__

And during the parsing of the assignment expression that should have
led to the warning above, input_location is set to the location for
the DEC32_MAX, which is actually the location for the built-in
__DECL32_MAX_EXP.

A possible fix is to use the location of the "=" operator as the
default location for assignment expressions.  This is what the patch
does.

I had to adjust a couple of tests to arrange for this.

Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk.

libcpp/

	PR preprocessor/53463
	* line-map.c (linemap_location_in_system_header_p): For built-in
	macro tokens, check the first expansion point location for that is
	not for a token coming from a built-in macro.

gcc/cp/

	PR preprocessor/53463
	* parser.c (cp_parser_assignment_expression): Use the location
	for the LHS as the default location for the expression.

gcc/testsuite/

	PR preprocessor/53463
	* g++.dg/cpp/limits.C: New test.
	* g++.dg/parse/error19.C: Adjust.
	* g++.dg/warn/Wconversion-real-integer2.C: Likewise.
	* g++.dg/warn/pr35635.C: Likewise.
	* g++.old-deja/g++.pt/assign1.C: Likewise.

From-SVN: r188203
2012-06-04 21:19:58 +02:00
Joseph Myers 7d9641ccfa directives.c: Fix typos.
* directives.c: Fix typos.
	* include/line-map.h: Fix typos.
	* line-map.c: Fix typos.
	* macro.c: Fix typos.

From-SVN: r187966
2012-05-29 15:53:50 +01:00
Dodji Seketeli c4ca1a0961 Strip "<built-in>" loc from displayed expansion context
Now that diagnostics for tokens coming from macro expansions point to
the spelling location of the relevant token (and then displays the
context of the expansion), some ugly (not so seldom) corner cases can
happen.

When the relevant token is a built-in token (which means the location
of that token is BUILTINS_LOCATION) the location prefix displayed to
the user in the diagnostic line is the "<built-in>:0:0" string.  For
instance:

    <built-in>:0:0: warning: conversion to 'float' alters 'int' constant value

For the user, I think this is surprising and useless.

A more user-friendly approach would be to refer to the first location
that (in the reported macro expansion context) is for a location in
real source code, like what is shown in the new test case
gcc/testsuite/g++.dg/warn/Wconversion-real-integer2.C accompanying
this patch.

To do this, I am making the line-map module provide a new
linemap_unwind_to_first_non_reserved_loc function that resolves a
virtual location to the first spelling location that is in real source
code.

I am then using that facility in the diagnostics printing module and
in the macro unwinder to avoid printing diagnostics lines that refer
to the locations for built-ins or more generally for reserved
locations.  Note that when I start the dance of skipping a built-in
location I also skip locations that are in system headers, because it
turned out that a lot of those built-ins are actually used in system
headers (e.g, "#define INT_MAX __INT_MAX__" where __INT_MAX__ is a
built-in).

Besides the user-friendliness gain, this patch allows a number of
regression tests to PASS unchanged with and without
-ftrack-macro-expansion.

Tested and bootstrapped on x86_64-unknown-linux-gnu against trunk.

Note that the bootstrap with -ftrack-macro-expansion exhibits other
separate issues that are addressed in subsequent patches.  This patch
just fixes one class of problems.

The patch does pass bootstrap with -ftrack-macro-expansion turned off,
though.

libcpp/

	* include/line-map.h (linemap_unwind_toward_expansion): Fix typo
	in comment.
	(linemap_unwind_to_first_non_reserved_loc): Declare new function.
	* line-map.c (linemap_unwind_to_first_non_reserved_loc): Define
	new function.

gcc/

	* input.c (expand_location_1): When expanding to spelling location
	in a context of a macro expansion, skip reserved system header
	locations.  Update comments.  * tree-diagnostic.c
	(maybe_unwind_expanded_macro_loc): Likewise.

gcc/testsuite/

	* g++.dg/warn/Wconversion-real-integer2.C: New test.
	* g++.dg/warn/Wconversion-real-integer-3.C: Likewise.
	* g++.dg/warn/conversion-real-integer-3.h: New header used by the
	new test above.

From-SVN: r186970
2012-04-30 13:42:12 +02:00
Manuel López-Ibáñez 1d72e96f53 tree-diagnostic.c (maybe_unwind_expanded_macro_loc): Fix comment.
2012-04-26  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* tree-diagnostic.c (maybe_unwind_expanded_macro_loc): Fix
	comment. Delete unused parameter first_exp_point_map.
	(virt_loc_aware_diagnostic_finalizer): Update call.
libcpp/
	* line-map.c (linemap_resolve_location): Synchronize comments with
	those in line-map.h.
	* include/line-map.h (linemap_resolve_location): Fix spelling in
	comment.

From-SVN: r186860
2012-04-26 07:14:01 +00:00
Diego Novillo 8dcf72a862 line-map.h (linemap_dump): Declare.
* include/line-map.h (linemap_dump): Declare.
	(line_table_dump): Declare.
	* line-map.c (linemap_dump): New.
	(line_table_dump): New.

From-SVN: r181625
2011-11-22 11:13:00 -05:00
Dodji Seketeli 3bb0c8dbb0 Fix lookup of macro maps
* line-map.c (linemap_macro_map_lookup): Fix logic.

From-SVN: r180427
2011-10-25 10:59:07 +02:00
Dodji Seketeli 84756fd40a Support expansion of reserved locations wrapped in virtual locations
libcpp/

	* include/line-map.h (linemap_expand_location): Take a line table
	parameter.  Update comment.
	(linemap_resolve_location): Update comment.
	(linemap_expand_location_full): Remove.
	* line-map.c (linemap_resolve_location):  Handle reserved
	locations; return a NULL map in those cases.
	(linemap_expand_location): If location is reserved, return a
	zeroed expanded location.  Update comment.  Take a line table to
	assert that the function takes non-virtual locations only.
	(linemap_expand_location_full): remove.
	(linemap_dump_location): Handle the fact that
	linemap_resolve_location can return NULL line maps when the
	location resolves to a reserved location.

gcc/
	* input.c (expand_location): Rewrite using
	linemap_resolve_location and linemap_expand_location.  Add a
	comment.

From-SVN: r180426
2011-10-25 10:58:54 +02:00
Dodji Seketeli d17687f6f0 Fix bootstrap on !NO_IMPLICIT_EXTERN_C and ia32 targets
libcpp/

	* include/line-map.h (struct linemap_stats): Change the type of
	the members from size_t to long.
	* macro.c (macro_arg_token_iter_init): Unconditionally initialize
	iter->location_ptr.

gcc/c-family/

	* c-lex.c (fe_file_change): Use LINEMAP_SYSP when
	!NO_IMPLICIT_EXTERN_C.

gcc/
	* input.c (dump_line_table_statistics): Use long, not size_t.

From-SVN: r180124
2011-10-18 10:44:49 +02:00
Dodji Seketeli 411f92de7a Fix bootstrapping with --disable-checking
libcpp/ChangeLog

	* line-map.c (linemap_macro_map_loc_to_exp_point): Avoid setting a
	variable without using it if ENABLE_CHECKING is not defined.  Mark
	the LOCATION parameter as being unused.

From-SVN: r180090
2011-10-17 16:01:37 +02:00
Tom Tromey b9bd6f7438 Reduce memory waste due to non-power-of-2 allocs
This patch basically arranges for the allocation size of line_map
buffers to be as close as possible to a power of two.  This
*significantly* decreases peak memory consumption as (macro) maps are
numerous and stay live during all the compilation.

The patch adds a new ggc_round_alloc_size interface to the ggc
allocator.  In each of the two main allocator implementations ('page'
and 'zone') the function has been extracted from the main allocation
function code and returns the actual size of the allocated memory
region, thus giving a chance to the caller to maximize the amount of
memory it actually uses from the allocated memory region.  In the
'none' allocator implementation (that uses xmalloc) the
ggc_round_alloc_size just returns the requested allocation size.

Co-Authored-By: Dodji Seketeli <dodji@redhat.com>

From-SVN: r180086
2011-10-17 12:00:07 +02:00
Tom Tromey 64a1a422db Add line map statistics to -fmem-report output
This patch adds statistics about line maps' memory consumption and
macro expansion to the output of -fmem-report.  It has been useful in
trying to reduce the memory consumption of the macro maps support.

Co-Authored-By: Dodji Seketeli <dodji@redhat.com>

From-SVN: r180085
2011-10-17 11:59:52 +02:00
Tom Tromey 847e697a24 Support -fdebug-cpp option
This patch adds -fdebug-cpp option. When used with -E this dumps the
relevant macro map before every single token. This clutters the output
a lot but has proved to be invaluable in tracking some bugs during the
development of the virtual location support.

Co-Authored-By: Dodji Seketeli <dodji@redhat.com>

From-SVN: r180084
2011-10-17 11:59:40 +02:00
Tom Tromey 92582b753e Generate virtual locations for tokens
This second instalment uses the infrastructure of the previous patch
to allocate a macro map for each macro expansion and assign a virtual
location to each token resulting from the expansion.

To date when cpp_get_token comes across a token that happens to be a
macro, the macro expander kicks in, expands the macro, pushes the
resulting tokens onto a "token context" and returns a dummy padding
token. The next call to cpp_get_token goes look into the token context
for the next token [which is going to result from the previous macro
expansion] and returns it.  If the token is a macro, the macro expander
kicks in and you know the story.

This patch piggy-backs on that macro expansion process, so to speak.
First it modifies the macro expander to make it create a macro map for
each macro expansion. It then allocates a virtual location for each
resulting token.  Virtual locations of tokens resulting from macro
expansions are then stored on a special kind of context called an
"expanded tokens context".  In other words, in an expanded tokens
context, there are tokens resulting from macro expansion and their
associated virtual locations.  cpp_get_token_with_location is modified
to return the virtual location of tokens resulting from macro
expansion.  Note that once all tokens from an expanded token context have
been consumed and the context and is freed, the memory used to store the
virtual locations of the tokens held in that context is freed as well.
This helps reducing the overall peak memory consumption.

The client code that was getting macro expansion point location from
cpp_get_token_with_location now gets virtual location from it. Those
virtual locations can in turn be resolved into the different
interesting physical locations thanks to the linemap API exposed by
the previous patch.

Expensive progress. Possibly. So this whole virtual location
allocation business is switched off by default. So by default no
extended token is created. No extended token context is created
either. One has to use -ftrack-macro-expansion to switch this on. This
complicates the code but I believe it can be useful as some of our
friends found out at http://llvm.org/bugs/show_bug.cgi?id=5610

The patch tries to reduce the memory consumption by freeing some token
context memory that was being reused before. I didn't notice any
compilation slow down due to this immediate freeing on my GNU/Linux
system.

As no client code tries to resolve virtual locations to anything but
what was being done before, no new test case has been added.

Co-Authored-By: Dodji Seketeli <dodji@redhat.com>

From-SVN: r180082
2011-10-17 11:59:12 +02:00
Tom Tromey 46427374e1 Linemap infrastructure for virtual locations
This is the first instalment of a set which goal is to track locations
of tokens across macro expansions.  Tom Tromey did the original work
and attached the patch to PR preprocessor/7263.  This opus is a
derivative of that original work.

This patch modifies the linemap module of libcpp to add virtual
locations support.

A virtual location is a mapped location that can resolve to several
different physical locations.  It can always resolve to the spelling
location of a token.  For tokens resulting from macro expansion it can
resolve to:
  - either the location of the expansion point of the macro.
  - or the location of the token in the definition of the
  macro
  - or, if the token is an argument of a function-like macro,
  the location of the use of the matching macro parameter in
  the definition of the macro

The patch creates a new type of line map called a macro map.  For every
single macro expansion, there is a macro map that generates a virtual
location for every single resulting token of the expansion.

The good old type of line map we all know is now called an ordinary
map.  That one still encodes spelling locations as it has always had.

As a result linemap_lookup as been extended to return a macro map when
given a virtual location resulting from a macro expansion.  The layout
of structs line_map has changed to support this new type of map.  So
did the layout of struct line_maps.  Accessor macros have been
introduced to avoid messing with the implementation details of these
datastructures directly.  This helped already as we have been testing
different ways of arranging these datastructure.  Having to constantly
adjust client code that is too tied with the internals of line_map and
line_maps would have been even more painful.

Of course, many new public functions have been added to the linemap
module to handle the resolution of virtual locations.

This patch introduces the infrastructure but no part of the compiler
uses virtual locations yet.

However the client code of the linemap data structures has been
adjusted as per the changes.  E.g, it's not anymore reliable for a
client code to manipulate struct line_map directly if it just wants to
deal with spelling locations, because struct line_map can now
represent a macro map as well.  In that case, it's better to use the
convenient API to resolve the initial (possibly virtual) location to a
spelling location (or to an ordinary map) and use that.

This is the reason why the patch adjusts the Java, Ada and Fortran
front ends.

Also, note that virtual locations are not supposed to be ordered for
relations '<' and '>' anymore.  To test if a virtual location appears
"before" another one, one has to use a new operator exposed by the
line map interface.  The patch updates the only spot (in the
diagnostics module) I have found that was making the assumption that
locations were ordered for these relations.  This is the only change
that introduces a use of the new line map API in this patch, so I am
adding a regression test for it only.

From-SVN: r180081
2011-10-17 11:58:56 +02:00
Dodji Seketeli 892a371f3b Fix the use of linemap_add and remove unnecessary kludge
libcpp/

	* line-map.c (linemap_add): Assert that reason must not be
	LC_RENAME when called for the first time on a "main input file".

c-family/

	* c-pch.c (c_common_read_pch): Call linemap_add with LC_ENTER as it's
	the first time it's being called on this main TU.

gcc/lto/

	* lto-lang.c (lto_init): Likewise.  Also, avoid calling
	linemap_add twice.

gcc/fortran/

	* scanner.c (load_file): Don't abuse LC_RENAME reason while
	(indirectly) calling linemap_add.

From-SVN: r178146
2011-08-28 22:14:46 +02:00
Gabriel Charette 0681d04c47 line-map.h (struct line_maps): Remove unused field last_listed.
* include/line-map.h (struct line_maps):
Remove unused field last_listed. Update all users.

From-SVN: r176898
2011-07-28 20:57:20 +00:00
Kai Tietz 4489800d00 files.c (file_hash_eq): Use filename_cmp instead of strcmp.
2011-03-25  Kai Tietz  <ktietz@redhat.com>

	* files.c (file_hash_eq): Use filename_cmp
	instead of strcmp.
	(nonexistent_file_hash_eq): Likewise.
	(remap_filename): Likewise.
	Handle absolute DOS-path,
	(append_file_to_dir): Check for IS_DIR_SEPARATOR
	instead of slash.
	(read_name_map): Likewise.
	* linemap.c (linemap_add): Use filename_cmp
	instead of strcmp.
	* mkdeps.c (apply_vpath): Use filename_ncmp
	instead of strncmp.
	(deps_restore): Use filename_cmp instead of
	strcmp.
	* init.c (read_original_directory): Use
	IS_DIR_SEPARATOR instead of checking for slash.

From-SVN: r171521
2011-03-25 20:11:26 +01:00
Jakub Jelinek 96c169e156 re PR preprocessor/41543 (BUILTINS_LOCATION wrong with -fpreprocessed)
PR preprocessor/41543
	* input.h (BUILTINS_LOCATION): Change to 1 from 2.
	Assert BUILTINS_LOCATION < RESERVED_LOCATION_COUNT.
	* tree.c: Include intl.h.
	(expand_location): Handle BUILTINS_LOCATION.
	* Makefile.in (tree.o): Depend on intl.h.

	* include/line-map.h (RESERVED_LOCATION_COUNT): Define.
	* line-map.c (linemap_init): Initialize highest_location and
	highest_line to RESERVED_LOCATION_COUNT-1 instead of 0.

	* gcc.dg/debug/dwarf2/pr41543.c: New test.

From-SVN: r152761
2009-10-14 12:04:22 +02:00
Joseph Myers c7f9c0b983 re PR preprocessor/39646 (__FILE__ breaks for empty file name)
libcpp:
	PR preprocessor/39646
	* include/line-map.h (enum lc_reason): Add LC_RENAME_VERBATIM.
	* line-map.c (linemap_add): Handle LC_RENAME_VERBATIM.
	* directives.c (do_line, do_linemarker): Use LC_RENAME_VERBATIM in
	place of LC_RENAME.

gcc/testsuite:
	* gcc.dg/cpp/line8.c: New test.

From-SVN: r146319
2009-04-18 18:36:28 +01:00
Jakub Jelinek 748086b7b2 Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
From-SVN: r145841
2009-04-09 17:00:19 +02:00
Tom Tromey c1a8a3c6ff re PR preprocessor/39512 (linemap_init in lex.c does not initialize reallocator)
PR preprocessor/39512:
	* line-map.c (linemap_init): Initialize 'reallocator' field.

From-SVN: r145300
2009-03-30 15:25:42 +00:00
Joseph Myers 148e4216a4 re PR preprocessor/34695 (Preprocessor warning->error conversion from -Werror is silent)
PR preprocessor/34695

gcc:
	* Makefile.in (c-opts.o): Depend on c-tree.h.
	* c-common.c: Move down include of diagnostic.h.
	(done_lexing, c_cpp_error): New.
	* c-common.h (done_lexing): Declare.
	* c-decl.c (c_write_global_declarations): Don't check cpp_errors
	(parse_in).
	* c-opts.c: Include c-tree.h.
	(c_common_init_options): Set preprocessor error callback.
	(c_common_handle_option): Do not set preprocessor
	inhibit_warnings, warnings_are_errors, warn_system_headers,
	pedantic_errors or inhibit_warnings flags.
	(c_common_post_options): Do not check cpp_errors (parse_in).
	(c_common_finish): Do not output dependencies if there were
	errors.  Do not check return value of cpp_finish.
	* c-ppoutput.c (pp_file_change): Set input_location.
	* c-tree.h (c_cpp_error): Declare.
	* diagnostic.c (diagnostic_set_info_translated): Also initialize
	override_column.
	(diagnostic_build_prefix): Check override_column.
	* diagnostic.h (diagnostic_info): Add override_column field.
	(diagnostic_override_column): Define.

gcc/cp:
	* cp-tree.h (cp_cpp_error): Remove.
	* error.c (cp_cpp_error): Remove.
	* parser.c (cp_lexer_new_main): Set done_lexing instead of
	client_diagnostic and error callback.

gcc/fortran:
	* cpp.c (cb_cpp_error): New.
	(gfc_cpp_post_options): Don't set cpp_option->inhibit_warnings.
	Don't check cpp_errors (cpp_in).
	(gfc_cpp_init_0): Set cb->error.

gcc/testsuite:
	* gcc.dg/builtin-redefine.c, gcc.dg/cpp/redef2.c,
	gcc.dg/cpp/redef3.c, gcc.dg/cpp/trad/redef2.c: Use dg-message
	instead of dg-warning for "previous definition" messages.
	* gcc.dg/cpp/Wvariadic-1.c, gcc.dg/cpp/Wvariadic-3.c: Expect
	"warnings being treated as errors" message.
	* gcc.dg/fltconst-1.c: Use -fshow-column.

libcpp:
	* makedepend.c: Remove.
	* Makefile.in (makedepend_OBJS, makedepend$(EXEEXT)): Remove.
	(all, clean, TAGS_SOURCES, include): Remove makedepend handling.
	* directives.c (cpp_errors): Remove.
	* errors.c (print_location, _cpp_begin_message, v_message):
	Remove.
	(cpp_error, cpp_error_with_line): Always use error callback.
	(cpp_error, cpp_error_with_line, cpp_errno): Return bool.
	* include/cpplib.h (cpp_options): Remove pedantic_errors,
	inhibit_warnings, warn_system_headers, inhibit_errors,
	warnings_are_errors, client_diagnostic.
	(cpp_callbacks): Add extra arguments to error callback; make it
	return bool.
	(cpp_finish): Return void.
	(cpp_destroy): Remove inaccurate comment about return value.
	(cpp_errors, CPP_DL_EXTRACT, CPP_DL_WARNING_P): Remove.
	(CPP_DL_NOTE): Define.
	* include/line-map.h (linemap_print_containing_files): Remove.
	* init.c (cpp_finish): Do not check for or return number of
	errors.
	* internal.h (cpp_reader): Remove errors field.
	* line-map.c (linemap_print_containing_files): Remove.
	* macro.c (_cpp_create_definition): Use CPP_DL_NOTE for message
	about previous definition.  Only emit it if previous diagnostic
	was emitted.

From-SVN: r145263
2009-03-29 23:56:07 +01:00
Manuel López-Ibáñez 1bb64668d0 line-map.h (linenum_type): New typedef.
2008-07-21  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	* include/line-map.h (linenum_type): New typedef.
	(struct line_map): Use it.
	(SOURCE_LINE): Second arguments is a LOCATION not a LINE.
	(SOURCE_COLUMN): Likewise.
	* macro.c (_cpp_builtin_macro_text): Use linenum_type. Don't store
	source_location values in a variable of type linenum_type.
	* directives.c (struct if_stack): Use linenum_type.
	(strtoul_for_line): Rename as strtolinenum.
	(do_line): Use linenum_type.
	(do_linemarker): Use linenum_type and strtolinenum.
	(_cpp_do_file_change): Use linenum_t.
	* line-map.c (linemap_add): Likewise.
	(linemap_line_start): Likewise.
	* traditional.c (struct fun_macro): 'line' is a source_location.
	* errors.c (print_location): Use linenum_type.
	* directives-only.c (_cpp_preprocess_dir_only): Likewise.
	* internal.h (CPP_INCREMENT_LINE): Likewise.
	* lex.c (_cpp_skip_block_comment): Use source_location.

From-SVN: r138026
2008-07-21 09:33:38 +00:00
Tom Tromey 2bf41bf05d traditional.c (lex_identifier): Use CPP_HASHNODE.
* traditional.c (lex_identifier): Use CPP_HASHNODE.
	* lex.c (lex_identifier): Use CPP_HASHNODE.
	* include/line-map.h (LINEMAP_POSITION_FOR_COLUMN): Wrap in
	do-while.
	* identifiers.c (alloc_node): Change return type.
	(_cpp_init_hashtable): Don't cast 'alloc_node'.
	(proxy_assertion_broken): New declaration.
	(cpp_forall_identifiers): Move comment.
	* line-map.c (linemap_add): Comment fix.
	(linemap_line_start): Indentation fix.

From-SVN: r132467
2008-02-20 02:16:43 +00:00
Tom Tromey 5ffeb913b1 tree-cfg.c (remove_bb): Only warn if line is non-zero.
gcc:
	* tree-cfg.c (remove_bb): Only warn if line is non-zero.
	* c-pch.c (c_common_read_pch): Restore current location after
	reading PCH file.
	* tree.c (expand_location): Update.
	(expr_filename): Changed return type.  Unified the two cases.
	(expr_lineno): Likewise.
	(annotate_with_file_line): Don't use EXPR_LINENO and EXPR_FILENAME
	as lvalues.
	* toplev.c (line_table): Changed type.
	(general_init): Update.
	(realloc_for_line_map): New function.
	(general_init): Allocate line_table using GC.
	* fix-header.c (line_table): Changed type.
	(read_scan_file): Update.
	(read_scan_file): Update.
	* c-ppoutput.c (maybe_print_line): Update.
	(print_line): Update.
	(cb_line_change): Update.
	(cb_define): Update.
	(pp_file_change): Update.
	* c-opts.c (c_common_init_options): Update.
	(finish_options): Update.
	(push_command_line_include): Update.
	* c-lex.c (cb_line_change): Update.
	(cb_def_pragma): Update.
	(cb_define): Update.
	(cb_undef): Update.
	(c_lex_with_flags): Use cpp_get_token_with_location.
	* input.h (line_table): Changed type.
	(location_from_locus): New macro.
	* tree.h (EXPR_FILENAME): No longer an lvalue.
	(EXPR_LINENO): Likewise.
	(expr_locus, set_expr_locus): Declare separately for
	USE_MAPPED_LOCATION.
	(expr_filename, expr_lineno): Changed return type.
	* gimplify.c (tree_to_gimple_tuple): Use SET_EXPR_LOCUS.
	* cfgexpand.c (expand_gimple_cond_expr): Use location_from_locus.
	(expand_gimple_basic_block): Likewise.
	* final.c (final_scan_insn): Use expanded_location.
gcc/cp:
	* decl.c (finish_function): Put return's location on line zero of
	file.
gcc/fortran:
	* scanner.c (get_file): Update.
	(load_file): Update.
	(gfc_next_char_literal): Use gfc_linebuf_linenum.
	* f95-lang.c (gfc_init): Update.
	* gfortran.h (gfc_linebuf_linenum): New macro.
gcc/java:
	* lang.c (java_post_options): Update.
	* jcf-parse.c (set_source_filename): Update.
	(give_name_to_class): Update.
	(jcf_parse): Update.
	(duplicate_class_warning): Update.
	(parse_class_file): Update.
	(java_parse_file): Update.
	* expr.c (expand_byte_code): Update.
gcc/testsuite:
	* lib/g++.exp (g++_target_compile): Use -fno-show-column.
gcc/treelang:
	* tree1.c (treelang_init): Update.
	(treelang_parse_file): Update.
	(treelang_parse_file): Update.
	(treelang_parse_file): Update.
	* lex.l: Update.
	(update_lineno_charno): Likewise.
libcpp:
	* internal.h (struct cpp_reader) <invocation_location>: New
	field.
	(struct cpp_reader) <set_invocation_location>: Likewise.
	* init.c (cpp_set_line_map): New function.
	* line-map.c (linemap_add): Use linemap's allocator.
	* include/line-map.h (GTY): Define.
	(line_map_realloc): New typedef.
	(struct line_map): Mark with GTY.
	(struct line_maps): Likewise.
	(struct line_maps) <maps>: Likewise.
	(struct line_maps) <reallocator>: New field.
	* include/symtab.h (GTY): Conditionally define.
	* include/cpplib.h (cpp_set_line_map): Declare.
	(cpp_get_token_with_location): Declare.
	* macro.c (cpp_get_token): Set invocation_location on the reader.
	(cpp_get_token_with_location): New function.

From-SVN: r128190
2007-09-06 16:24:05 +00:00
Kelley Cook 200031d1d5 all files: Update FSF address in copyright headers.
2005-06-29  Kelley Cook  <kcook@gcc.gnu.org>

	* all files: Update FSF address in copyright headers.
	* makeucnid.c (write_copyright): Update outputted FSF address.

From-SVN: r101413
2005-06-29 02:34:39 +00:00
Gabriel Dos Reis c3f829c1a6 configure.ac: Check declarations for asprintf and vasprintf.
* configure.ac: Check declarations for asprintf and vasprintf.
	* config.in: Regenerate.
	* configure: Likewise.

	* charset.c (conversion_loop): Use XRESIZEVEC.
	(convert_no_conversion): Likewise.
	(convert_using_iconv): Likewise.
	(init_iconv_desc): Cast return value of alloca.
	(cpp_host_to_exec_charset): Use XNEWVEC.
	(emit_numeric_escape): Use XRESIZEVEC.
	(cpp_interpret_string): Use XNEWVEC.
	(cpp_interpret_string): Use XRESIZEVEC.
	(_cpp_interpret_identifier): Cast return value of alloca.
	(_cpp_convert_input): Use XNEWVEC and XRESIZEVEC.
	* directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC.
	(parse_include): Use XNEWVEC.
	(insert_pragma_entry): Rename local variable "new" to
	"new_entry".
	(save_registered_pragmas): Cast return value of xmemdup.
	(destringize_and_run): Same for alloca.
	(parse_assertion): Likewise.
	(do_assert): Cast allocated storage to proper type.
	(cpp_define): Likewise.
	(_cpp_define_builtin): Likewise.
	(cpp_undef): Likewise.
	(handle_assertion): Likewise.
	(cpp_push_buffer): Rename local variable "new" to "new_buffer".
	* expr.c (CPP_UPLUS): Cast value to type cpp_ttype.
	(CPP_UMINUS): Likewise.
	(struct cpp_operator): Rename from struct operator.
	(_cpp_expand_op_stack): Use XRESIZEVEC.
	* files.c (pch_open_file): Use XNEWVEC.
	(pch_open_file): Use XRESIZEVEC.
	(read_file_guts): Use XNEWVEC and XRESIZEVEC.
	(dir_name_of_file): Use XNEWVEC.
	(make_cpp_file): Use XCNEW.
	(make_cpp_dir): Likewise.
	(allocate_file_hash_entries): USE XNEWVEC.
	(cpp_included): Cast return value of htab_find_with_hash.
	(append_file_to_dir): Use XNEWVEC.
	(read_filename_string): Likewise. Use XRESIZEVEC too.
	(read_name_map): Cast return value of alloca.  Use XRESIZEVEC.
	(remap_filename): Use XNEWVEC.
	(struct pchf_entry): Move definition out of struct pchf_data.
	(_cpp_save_file_entries): Use XCNEWVAR.
	(_cpp_read_file_entries): Use XNEWVAR.
	* identifiers.c (alloc_node): Use XOBNEW.
	* init.c (cpp_create_reader): Use XCNEW.
	(cpp_init_builtins): Cast of b->value to enum builtin_type.
	(read_original_directory): Cast return value of alloca.
	* lex.c (add_line_note): Use XRESIZEVEC.
	(warn_about_normalization): Use XNEWVEC.
	(_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype).
	(new_buff): Use XNEWVEC.
	* line-map.c (linemap_add): Use XRESIZEVEC.
	* macro.c (builtin_macro): Cast return value of alloca.
	(paste_tokens): Likewise.
	(expand_arg): Use XNEWVEC and XRESIZEVEC.
	(_cpp_save_parameter): Use XRESIZEVEC.
	(create_iso_definition): Cast allocated storage to proper type.
	(_cpp_create_definition): Likewise.
	(cpp_macro_definition): Use XRESIZEVEC.
	* makedepend.c (add_clm): Use XNEW.
	(add_dir): Likewise.
	* mkdeps.c (munge): Use XNEWVEC.
	(deps_init): Use XCNEW.
	(deps_add_target): Use XRESIZEVEC.
	(deps_add_default_target): Cast return value of alloca.
	(deps_add_dep): Use XRESIZEVEC.
	(deps_add_vpath): Likewise.  Use XNEWVEC too.
	(deps_restore): Likewise.
	* pch.c (save_idents): Use XNEW and XNEWVEC.
	(cpp_save_state): Use XNEW.
	(count_defs): Cast return value of htab_find.
	(write_defs): Likewise.
	(cpp_write_pch_deps): Use XNEWVEC.
	(collect_ht_nodes): Use XRESIZEVEC.
	(cpp_valid_state): Use XNEWVEC.
	(save_macros): Use XRESIZEVEC.  Cast return value of xmemdup.
	* symtab.c (ht_create): Use XCNEW.
	(ht_lookup_with_hash): Cast return value of obstack_copy0.
	(ht_expand): Use XCNEWVEC.
	* system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus.
	(bool): Do not define if __cplusplus.

From-SVN: r100295
2005-05-28 15:52:48 +00:00
Per Bothner c1fc50476c re PR preprocessor/20907 (long comments throw off line numbers)
PR preprocessor/20907
	* line-map.c (linemap_line_start): Fix bug when we need to increse
	column_bits but can re-use the current line_map.

From-SVN: r98515
2005-04-21 10:08:27 -07:00
Paolo Bonzini 4f4e53dd85 Makefile.def (host_modules): add libcpp.
ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* Makefile.def (host_modules): add libcpp.
	* Makefile.tpl: Add dependencies on and for libcpp.
	* Makefile.in: Regenerate.
	* configure.in: Add libcpp host module.
	* configure: Regenerate.

config/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* acx.m4 (ACX_HEADER_STDBOOL, ACX_HEADER_STRING):
	From gcc.

gcc/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	Move libcpp to the toplevel.
	* Makefile.in: Remove references to libcpp files,
	use CPPLIBS instead of libcpp.a.  Define SYMTAB_H
	and change hashtable.h to that.
	* aclocal.m4 (gcc_AC_HEADER_STDBOOL,
	gcc_AC_HEADER_STRING, gcc_AC_C__BOOL): Remove.
	* configure.ac (gcc_AC_C__BOOL, HAVE_UCHAR): Remove tests.
	* configure: Regenerate.
	* config.in: Regenerate.
	* c-ppoutput.c: Include ../libcpp/internal.h instead of cpphash.h.
	* cppcharset.c: Removed.
	* cpperror.c: Removed.
	* cppexp.c: Removed.
	* cppfiles.c: Removed.
	* cpphash.c: Removed.
	* cpphash.h: Removed.
	* cppinit.c: Removed.
	* cpplex.c: Removed.
	* cpplib.c: Removed.
	* cpplib.h: Removed.
	* cppmacro.c: Removed.
	* cpppch.c: Removed.
	* cpptrad.c: Removed.
	* cppucnid.h: Removed.
	* cppucnid.pl: Removed.
	* cppucnid.tab: Removed.
	* hashtable.c: Removed.
	* hashtable.h: Removed.
	* line-map.c: Removed.
	* line-map.h: Removed.
	* mkdeps.c: Removed.
	* mkdeps.h: Removed.
	* stringpool.h: Include symtab.h instead of hashtable.h.
	* tree.h: Include symtab.h instead of hashtable.h.
	* system.h (O_NONBLOCK, O_NOCTTY): Do not define.

gcc/cp/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* Make-lang.in: No need to specify $(LIBCPP).

gcc/java/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* Make-lang.in: Link in $(LIBCPP) instead of mkdeps.o.

libcpp/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	Moved libcpp from the gcc subdirectory to the toplevel.
	* Makefile.am: New file.
	* Makefile.in: Regenerate.
	* configure.ac: New file.
	* configure: Regenerate.
	* config.in: Regenerate.
	* charset.c: Moved from gcc/cppcharset.c.  Add note about
	brokenness of input charset detection.  Adjust for change
	in name of cppucnid.h.
	* errors.c: Moved from gcc/cpperror.c.  Do not include intl.h.
	* expr.c: Moved from gcc/cppexp.c.
	* files.c: Moved from gcc/cppfiles.c.  Do not include intl.h.
	Remove #define of O_BINARY, it is in system.h.
	* identifiers.c: Moved from gcc/cpphash.c.
	* internal.h: Moved from gcc/cpphash.h.  Change header
	guard name.  All other files adjusted to match name change.
	* init.c: Moved from gcc/cppinit.c.
	(init_library) [ENABLE_NLS]: Call bindtextdomain.
	* lex.c: Moved from gcc/cpplex.c.
	* directives.c: Moved from gcc/cpplib.c.
	* macro.c: Moved from gcc/cppmacro.c.
	* pch.c: Moved from gcc/cpppch.c.  Do not include intl.h.
	* traditional.c: Moved from gcc/cpptrad.c.
	* ucnid.h: Moved from gcc/cppucnid.h.  Change header
	guard name.
	* ucnid.pl: Moved from gcc/cppucnid.pl.
	* ucnid.tab: Moved from gcc/cppucnid.tab.  Change header
	guard name.
	* symtab.c: Moved from gcc/hashtable.c.
	* line-map.c: Moved from gcc.  Do not include intl.h.
	* mkdeps.c: Moved from gcc.
	* system.h: New file.

libcpp/include/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* cpplib.h: Moved from gcc.  Change header guard name.
	* line-map.h: Moved from gcc.  Change header guard name.
	* mkdeps.h: Moved from gcc.  Change header guard name.
	* symtab.h: Moved from gcc/hashtable.h.  Change header
	guard name.

libcpp/po/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* be.po: Extracted from gcc/po/be.po.
	* ca.po: Extracted from gcc/po/ca.po.
	* da.po: Extracted from gcc/po/da.po.
	* de.po: Extracted from gcc/po/de.po.
	* el.po: Extracted from gcc/po/el.po.
	* es.po: Extracted from gcc/po/es.po.
	* fr.po: Extracted from gcc/po/fr.po.
	* ja.po: Extracted from gcc/po/ja.po.
	* nl.po: Extracted from gcc/po/nl.po.
	* sv.po: Extracted from gcc/po/sv.po.
	* tr.po: Extracted from gcc/po/tr.po.

From-SVN: r82199
2004-05-24 10:50:45 +00:00