aboutsummaryrefslogtreecommitdiff
path: root/libcpp
AgeCommit message (Collapse)AuthorFilesLines
2015-11-06Reimplement diagnostic_show_locus, introducing rich_location classesDavid Malcolm5-4/+374
gcc/ChangeLog: * diagnostic-color.c (color_dict): Eliminate "caret"; add "range1" and "range2". (parse_gcc_colors): Update comment to describe default GCC_COLORS. * diagnostic-core.h (warning_at_rich_loc): New declaration. (error_at_rich_loc): New declaration. (permerror_at_rich_loc): New declaration. (inform_at_rich_loc): New declaration. * diagnostic-show-locus.c (adjust_line): Delete. (struct point_state): New struct. (class colorizer): New class. (class layout_point): New class. (class layout_range): New class. (struct line_bounds): New. (class layout): New class. (colorizer::colorizer): New ctor. (colorizer::~colorizer): New dtor. (layout::layout): New ctor. (layout::print_source_line): New method. (layout::print_annotation_line): New method. (layout::get_state_at_point): New method. (layout::get_x_bound_for_row): New method. (diagnostic_show_locus): Reimplement in terms of class layout. (diagnostic_print_caret_line): Delete. * diagnostic.c (diagnostic_initialize): Replace MAX_LOCATIONS_PER_MESSAGE with rich_location::MAX_RANGES. (diagnostic_set_info_translated): Convert param from location_t to rich_location *. Eliminate calls to set_location on the message in favor of storing the rich_location ptr there. (diagnostic_set_info): Convert param from location_t to rich_location *. (diagnostic_build_prefix): Break out array into... (diagnostic_kind_color): New variable. (diagnostic_get_color_for_kind): New function. (diagnostic_report_diagnostic): Colorize the option_text using the color for the severity. (diagnostic_append_note): Update for change in signature of diagnostic_set_info. (diagnostic_append_note_at_rich_loc): New function. (emit_diagnostic): Update for change in signature of diagnostic_set_info. (inform): Likewise. (inform_at_rich_loc): New function. (inform_n): Update for change in signature of diagnostic_set_info. (warning): Likewise. (warning_at): Likewise. (warning_at_rich_loc): New function. (warning_n): Update for change in signature of diagnostic_set_info. (pedwarn): Likewise. (permerror): Likewise. (permerror_at_rich_loc): New function. (error): Update for change in signature of diagnostic_set_info. (error_n): Likewise. (error_at): Likewise. (error_at_rich_loc): New function. (sorry): Update for change in signature of diagnostic_set_info. (fatal_error): Likewise. (internal_error): Likewise. (internal_error_no_backtrace): Likewise. (source_range::debug): New function. * diagnostic.h (struct diagnostic_info): Eliminate field "override_column". Add field "richloc". (struct diagnostic_context): Add field "colorize_source_p". (diagnostic_override_column): Delete. (diagnostic_set_info): Convert param from location_t to rich_location *. (diagnostic_set_info_translated): Likewise. (diagnostic_append_note_at_rich_loc): New function. (diagnostic_num_locations): New function. (diagnostic_expand_location): Get the location from the rich_location. (diagnostic_print_caret_line): Delete. (diagnostic_get_color_for_kind): New declaration. * genmatch.c (linemap_client_expand_location_to_spelling_point): New. (error_cb): Update for change in signature of "error" callback. (fatal_at): Likewise. (warning_at): Likewise. * input.c (linemap_client_expand_location_to_spelling_point): New. * pretty-print.c (text_info::set_range): New method. (text_info::get_location): New method. * pretty-print.h (MAX_LOCATIONS_PER_MESSAGE): Eliminate this macro. (struct text_info): Eliminate "locations" array in favor of "m_richloc", a rich_location *. (textinfo::set_location): Add a "caret_p" param, and reimplement in terms of a call to set_range. (textinfo::get_location): Eliminate inline implementation in favor of an out-of-line reimplementation. (textinfo::set_range): New method. * rtl-error.c (diagnostic_for_asm): Update for change in signature of diagnostic_set_info. * tree-diagnostic.c (default_tree_printer): Update for new "caret_p" param for textinfo::set_location. * tree-pretty-print.c (percent_K_format): Likewise. gcc/c-family/ChangeLog: * c-common.c (c_cpp_error): Convert parameter from location_t to rich_location *. Eliminate the "column_override" parameter and the call to diagnostic_override_column. Update the "done_lexing" clause to set range 0 on the rich_location, rather than overwriting a location_t. * c-common.h (c_cpp_error): Convert parameter from location_t to rich_location *. Eliminate the "column_override" parameter. gcc/c/ChangeLog: * c-decl.c (warn_defaults_to): Update for change in signature of diagnostic_set_info. * c-errors.c (pedwarn_c99): Likewise. (pedwarn_c90): Likewise. * c-objc-common.c (c_tree_printer): Update for new "caret_p" param for textinfo::set_location. gcc/cp/ChangeLog: * error.c (cp_printer): Update for new "caret_p" param for textinfo::set_location. (pedwarn_cxx98): Update for change in signature of diagnostic_set_info. gcc/fortran/ChangeLog: * cpp.c (cb_cpp_error): Convert parameter from location_t to rich_location *. Eliminate the "column_override" parameter. * error.c (gfc_warning): Update for change in signature of diagnostic_set_info. (gfc_format_decoder): Update handling of %C/%L for changes to struct text_info. (gfc_diagnostic_starter): Use richloc when determining whether to print one locus or two. When handling a location that will involve a call to diagnostic_show_locus, only attempt to print the locus for the primary location, and don't call into diagnostic_print_caret_line. (gfc_warning_now_at): Update for change in signature of diagnostic_set_info. (gfc_warning_now): Likewise. (gfc_error_now): Likewise. (gfc_fatal_error): Likewise. (gfc_error): Likewise. (gfc_internal_error): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic-test-show-locus-bw.c: New file. * gcc.dg/plugin/diagnostic-test-show-locus-color.c: New file. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: New file. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add the above. * lib/gcc-dg.exp: Load multiline.exp. libcpp/ChangeLog: * errors.c (cpp_diagnostic): Update for change in signature of "error" callback. (cpp_diagnostic_with_line): Likewise, calling override_column on the rich_location. * include/cpplib.h (struct cpp_callbacks): Within "error" callback, convert param from source_location to rich_location *, and drop column_override param. * include/line-map.h (struct source_range): New struct. (struct location_range): New struct. (class rich_location): New class. (linemap_client_expand_location_to_spelling_point): New declaration. * line-map.c (rich_location::rich_location): New ctors. (rich_location::lazily_expand_location): New method. (rich_location::override_column): New method. (rich_location::add_range): New methods. (rich_location::set_range): New method. From-SVN: r229884
2015-11-06Add stats on adhoc table to dump_line_table_statisticsDavid Malcolm3-0/+11
gcc/ChangeLog: * input.c (dump_line_table_statistics): Dump stats on adhoc table. libcpp/ChangeLog: * include/line-map.h (struct linemap_stats): Add fields "adhoc_table_size" and "adhoc_table_entries_used". * line-map.c (linemap_get_statistics): Populate above fields. From-SVN: r229873
2015-11-04ENABLE_CHECKING refactoring: remove remaining occurrencesMikhail Maltsev4-8/+7
libcpp/ * config.in: Regenerate. * configure: Regenerate. * configure.ac: Remove ENABLE_CHECKING. gcc/ * cfganal.c (inverted_post_order_compute): Remove conditional compilation, use flag_checking. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Remove ENABLE_CHECKING. * genconditions.c: Do not #undef ENABLE_CHECKING. * sese.h (bb_in_region): Comment out broken check. * tree-ssa-loop-manip.c (rewrite_into_loop_closed_ssa_1): Remove conditional compilation, use flag_checking. From-SVN: r229758
2015-11-03lex.c (search_line_sse42): Correctly advance the pointer to an aligned address.Uros Bizjak2-3/+8
* lex.c (search_line_sse42): Correctly advance the pointer to an aligned address. From-SVN: r229718
2015-11-02libcpp: Improvements to description of source_location in line-map.hDavid Malcolm2-5/+25
libcpp/ChangeLog: * include/line-map.h (source_location): In the table in the descriptive comment, show UNKNOWN_LOCATION, BUILTINS_LOCATION, LINE_MAP_MAX_LOCATION_WITH_COLS, LINE_MAP_MAX_SOURCE_LOCATION. Add notes about ad-hoc values. From-SVN: r229673
2015-10-21[PATCH 2/9] ENABLE_CHECKING refactoring: libcppMikhail Maltsev4-25/+24
[PATCH 2/9] ENABLE_CHECKING refactoring: libcpp * include/line-map.h: Use CHECKING_P instead of ENABLE_CHECKING. * init.c: Likewise. * macro.c (struct macro_arg_token_iter, set_arg_token, macro_arg_token_iter_init, macro_arg_token_iter_forward, macro_arg_token_iter_get_token, macro_arg_token_iter_get_location, alloc_expanded_arg_mem, _cpp_backup_tokens): Likewise. From-SVN: r229154
2015-10-21[PATCH 1/9] ENABLE_CHECKING refactoringMikhail Maltsev5-3/+39
gcc/ * config.in: Regenerate. * configure: Regenerate. * configure.ac (CHECKING_P): Define. * system.h: Use CHECKING_P. libcpp/ * config.in: Regenerate. * configure: Regenerate. * configure.ac (CHECKING_P): Define. * system.h (fancy_abort): Declare. (abort): Define. (gcc_assert): Define. Use CHECKING_P. From-SVN: r229149
2015-10-13[PATCH 1/9] ENABLE_CHECKING refactoringMikhail Maltsev2-0/+13
[PATCH 1/9] ENABLE_CHECKING refactoring gcc/ChangeLog: 2015-10-05 Mikhail Maltsev <maltsevm@gmail.com> * common.opt: Add flag_checking. * system.h (CHECKING_P): Define. libcpp/ChangeLog: 2015-10-05 Mikhail Maltsev <maltsevm@gmail.com> * system.h (CHECKING_P, gcc_checking_assert): Define. From-SVN: r228787
2015-10-08* zh_TW.po: Update.Joseph Myers2-56/+28
From-SVN: r228603
2015-09-21Handle lines encoded into several maps in linemap_position_for_loc_and_offsetManuel López-Ibáñez2-14/+26
linemap_position_for_loc_and_offset() tries to generate a location_t encoding a column offset from the current location, for example, point to a certain character inside a string. This is trivial to do when the new location "fits within" the map of the original location. However, it may happen that the (long) line corresponding to the original location is encoded in several maps, thus the new location should actually be encoded in a subsequent map from the original location. This patch detects this case and adjusts the map correspondingly. (This shows that the line-map representation is quite wasteful in this case, because line-maps always start at column 0. That is, map[0] highest location may encode up to line 8 column 80, then map[1]->start_location starts encoding at line 8 column 0. Thus, there are two location_t values that point to the same source location.) libcpp/ChangeLog: 2015-09-21 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c/66415 * line-map.c (linemap_position_for_loc_and_offset): Handle the case of long lines encoded in multiple maps. gcc/testsuite/ChangeLog: 2015-09-21 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c/66415 * gcc.dg/cpp/pr66415-1.c: Test column number. From-SVN: r227975
2015-09-07system.h (INTTYPE_MINIMUM): Rewrite to avoid shift warning.Marek Polacek2-1/+5
* system.h (INTTYPE_MINIMUM): Rewrite to avoid shift warning. * system.h (INTTYPE_MINIMUM): Rewrite to avoid shift warning. From-SVN: r227516
2015-08-07Makefile.def (libiconv): Define bootstrap=true.Yaakov Selkowitz2-26/+131
2015-08-06 Yaakov Selkowitz <yselkowi@redhat.com> * Makefile.def (libiconv): Define bootstrap=true. Mark pdf/html/info as missing. (configure-gcc): Depend on all-libiconv. (all-gcc): Ditto. (configure-libcpp): Ditto. (all-libcpp): Ditto. (configure-intl): Ditto. (all-intl): Ditto. * Makefile.in: Regenerate. intl/ * configure: Reflects renaming of configure.in to configure.ac libcpp/ * configure: Regenerate. gcc/ * configure.ac: Define LIBICONV_DEP with in-tree libiconv. * configure: Regenerate. From-SVN: r226712
2015-07-31* sv.po: Update.Joseph Myers2-3/+7
From-SVN: r226423
2015-07-24* nl.po: Update.Joseph Myers2-62/+37
From-SVN: r226177
2015-07-08Address -Wsign-compare diagnosticsThomas Schwinge2-1/+6
... which have been introduced in r223152, for example hundreds of: [...]/gcc/input.h:37:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] libcpp/ * include/line-map.h (RESERVED_LOCATION_COUNT): Change type to source_location. From-SVN: r225558
2015-07-032015-07-03 Paolo Carlini <paolo.carlini@oracle.com>Paolo Carlini1-1/+1
* Fix component of my last ChangeLog entries. From-SVN: r225371
2015-07-02re PR preprocessor/53690 ([C++11] \u0000 and \U00000000 are wrongly encoded ↵Paolo Carlini4-20/+31
as U+0001.) /libcpp 2015-07-02 Paolo Carlini <paolo.carlini@oracle.com> PR c++/53690 * charset.c (_cpp_valid_ucn): Add cppchar_t * parameter and change return type to bool. Fix encoding of \u0000 and \U00000000 in C++. (convert_ucn): Adjust call. * lex.c (forms_identifier_p): Likewise. * internal.h (_cpp_valid_ucn): Adjust declaration. /gcc/testsuite 2015-07-02 Paolo Carlini <paolo.carlini@oracle.com> PR c++/53690 * g++.dg/cpp/pr53690.C: New. From-SVN: r225353
2015-07-02Regenerate .pot files.Joseph Myers2-169/+177
gcc/po: * gcc.pot: Regenerate. libcpp/po: * cpplib.pot: Regenerate. From-SVN: r225313
2015-06-30Implement N4197 - Adding u8 character literalsEdward Smith-Rowland7-24/+58
libcpp: 2015-06-30 Edward Smith-Rowland <3dw4rd@verizon.net> Implement N4197 - Adding u8 character literals * include/cpplib.h (UTF8CHAR, UTF8CHAR_USERDEF): New cpp tokens; (struct cpp_options): Add utf8_char_literals. * init.c (struct lang_flags): Add utf8_char_literals; (struct lang_flags lang_defaults): Add column for utf8_char_literals. * macro.c (stringify_arg()): Treat CPP_UTF8CHAR token; * expr.c (cpp_userdef_char_remove_type(), cpp_userdef_char_add_type()): Treat CPP_UTF8CHAR_USERDEF, CPP_UTF8CHAR tokens; (cpp_userdef_char_p()): Treat CPP_UTF8CHAR_USERDEF token; (eval_token(), _cpp_parse_expr()): Treat CPP_UTF8CHAR token. * lex.c (lex_string(), _cpp_lex_direct()): Include CPP_UTF8CHAR tokens. * charset.c (converter_for_type(), cpp_interpret_charconst()): Treat CPP_UTF8CHAR token. gcc/c-family: 2015-06-30 Edward Smith-Rowland <3dw4rd@verizon.net> Implement N4197 - Adding u8 character literals * c-family/c-ada-spec.c (print_ada_macros()): Treat CPP_UTF8CHAR like CPP_CHAR. * c-family/c-common.c (c_parse_error()): print CPP_UTF8CHAR and CPP_UTF8CHAR_USERDEF tokens. * c-family/c-lex.c (c_lex_with_flags()): Treat CPP_UTF8CHAR_USERDEF and CPP_UTF8CHAR tokens; (lex_charconst()): Treat CPP_UTF8CHAR token. gcc/cp: 2015-06-30 Edward Smith-Rowland <3dw4rd@verizon.net> Implement N4197 - Adding u8 character literals * parser.c (cp_parser_primary_expression()): Treat CPP_UTF8CHAR and CPP_UTF8CHAR_USERDEF tokens; (cp_parser_parenthesized_expression_list()): Treat CPP_UTF8CHAR token. gcc/testsuite: 2015-06-30 Edward Smith-Rowland <3dw4rd@verizon.net> Implement N4197 - Adding u8 character literals * g++.dg/cpp1z/utf8.C: New. * g++.dg/cpp1z/utf8-neg.C: New. * g++.dg/cpp1z/udlit-utf8char.C: New. From-SVN: r225185
2015-06-30lex.c (search_line_sse42): New main loop using asm flag outputs.Uros Bizjak2-5/+28
* lex.c (search_line_sse42) [__GCC_ASM_FLAG_OUTPUTS__]: New main loop using asm flag outputs. From-SVN: r225160
2015-06-08re PR c/66415 (ice in location_column_from_byte_offset)Marek Polacek2-3/+11
PR c/66415 * c-format.c (location_from_offset): Return LOC if LINE is null. * line-map.c (linemap_position_for_loc_and_offset): Remove linemap_assert_fails; reverse conditions. * gcc.dg/cpp/pr66415-1.c: New test. * gcc.dg/cpp/pr66415-2.c: New test. From-SVN: r224236
2015-05-26line-map.c (LINE_MAP_MAX_COLUMN_NUMBER ↵Manuel López-Ibáñez2-6/+28
LINE_MAP_MAX_LOCATION_WITH_COLS,LINE_MAP_MAX_SOURCE_LOCATION): New constants. libcpp/ChangeLog: 2015-05-26 Manuel López-Ibáñez <manu@gcc.gnu.org> * line-map.c (LINE_MAP_MAX_COLUMN_NUMBER LINE_MAP_MAX_LOCATION_WITH_COLS,LINE_MAP_MAX_SOURCE_LOCATION): New constants. (linemap_line_start): Use them. (linemap_position_for_column): Use them. From-SVN: r223705
2015-05-20libcpp: Eliminate most of the non-const/reference-returning inline fnsDavid Malcolm3-100/+33
gcc/java/ChangeLog: * jcf-parse.c (set_source_filename): Replace write through ORDINARY_MAP_FILE_NAME with direct access to "to_file". libcpp/ChangeLog: * include/line-map.h (MAP_START_LOCATION): Eliminate the non-const variant, and tweak comment for the const variant. (ORDINARY_MAP_STARTING_LINE_NUMBER): Drop the non-const variant. (ORDINARY_MAP_INCLUDER_FILE_INDEX): Likewise. (ORDINARY_MAP_IN_SYSTEM_HEADER_P): Likewise. (SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS): Delete. (ORDINARY_MAP_FILE_NAME): Drop the non-const variant. (MACRO_MAP_MACRO): Likewise. (MACRO_MAP_NUM_MACRO_TOKENS): Likewise. (MACRO_MAP_LOCATIONS): Likewise. (MACRO_MAP_EXPANSION_POINT_LOCATION): Likewise. * line-map.c (linemap_add): Replace writes through macros with direct field accesses. (linemap_enter_macro): Likewise. (linemap_line_start): Likewise. From-SVN: r223435
2015-05-19Replace line_map union with C++ class hierarchyDavid Malcolm8-308/+524
gcc/ChangeLog: * diagnostic.c (diagnostic_report_current_module): Strengthen local "new_map" from const line_map * to const line_map_ordinary *. * genmatch.c (error_cb): Likewise for local "map". (output_line_directive): Likewise for local "map". * input.c (expand_location_1): Likewise for local "map". Pass NULL rather than &map to linemap_unwind_to_first_non_reserved_loc, since the value is never read from there, and the value written back not read from here. (is_location_from_builtin_token): Strengthen local "map" from const line_map * to const line_map_ordinary *. (dump_location_info): Strengthen locals "map" from line_map *, one to const line_map_ordinary *, the other to const line_map_macro *. * tree-diagnostic.c (loc_map_pair): Strengthen field "map" from const line_map * to const line_map_macro *. (maybe_unwind_expanded_macro_loc): Add a call to linemap_check_macro when writing to the "map" field of the loc_map_pair. Introduce local const line_map_ordinary * "ord_map", using it in place of "map" in the part of the function where we know we have an ordinary map. Strengthen local "m" from const line_map * to const line_map_ordinary *. gcc/ada/ChangeLog: * gcc-interface/trans.c (Sloc_to_locus1): Strenghthen local "map" from line_map * to line_map_ordinary *. gcc/c-family/ChangeLog: * c-common.h (fe_file_change): Strengthen param from const line_map * to const line_map_ordinary *. (pp_file_change): Likewise. * c-lex.c (fe_file_change): Likewise. (cb_define): Use linemap_check_ordinary when invoking SOURCE_LINE. (cb_undef): Likewise. * c-opts.c (c_finish_options): Use linemap_check_ordinary when invoking cb_file_change. (c_finish_options): Likewise. (push_command_line_include): Likewise. (cb_file_change): Strengthen param "new_map" from const line_map * to const line_map_ordinary *. * c-ppoutput.c (cb_define): Likewise for local "map". (pp_file_change): Likewise for param "map" and local "from". gcc/fortran/ChangeLog: * cpp.c (maybe_print_line): Strengthen local "map" from const line_map * to const line_map_ordinary *. (cb_file_change): Likewise for param "map" and local "from". (cb_line_change): Likewise for local "map". libcpp/ChangeLog: * directives.c (do_line): Strengthen local "map" from const line_map * to const line_map_ordinary *. (do_linemarker): Likewise. (_cpp_do_file_change): Assert that we're not dealing with a macro map. Introduce local "ord_map" via a call to linemap_check_ordinary, guarded within the check for non-NULL. Use it for typesafety. * files.c (cpp_make_system_header): Strengthen local "map" from const line_map * to const line_map_ordinary *. * include/cpplib.h (struct cpp_callbacks): Likewise for second parameter of "file_change" callback. * include/line-map.h (struct line_map): Convert from a struct containing a union to a base class. (struct line_map_ordinary): Convert to a subclass of line_map. (struct line_map_macro): Likewise. (linemap_check_ordinary): Strengthen return type from line_map * to line_map_ordinary *, and add a const-variant. (linemap_check_macro): New pair of functions. (ORDINARY_MAP_STARTING_LINE_NUMBER): Strengthen param from const line_map * to const line_map_ordinary *, eliminating call to linemap_check_ordinary. Likewise for the non-const variant. (ORDINARY_MAP_INCLUDER_FILE_INDEX): Likewise. (ORDINARY_MAP_IN_SYSTEM_HEADER_P): Likewise. (ORDINARY_MAP_NUMBER_OF_COLUMN_BITS): Likewise. (ORDINARY_MAP_FILE_NAME): Likewise. (MACRO_MAP_MACRO): Strengthen param from const line_map * to const line_map_macro *. Likewise for the non-const variant. (MACRO_MAP_NUM_MACRO_TOKENS): Likewise. (MACRO_MAP_LOCATIONS): Likewise. (MACRO_MAP_EXPANSION_POINT_LOCATION): Likewise. (struct maps_info): Replace with... (struct maps_info_ordinary):...this and... (struct maps_info_macro): ...this. (struct line_maps): Convert fields "info_ordinary" and "info_macro" to the above new structs. (LINEMAPS_MAP_INFO): Delete both functions. (LINEMAPS_MAPS): Likewise. (LINEMAPS_ALLOCATED): Rewrite both variants to avoid using LINEMAPS_MAP_INFO. (LINEMAPS_USED): Likewise. (LINEMAPS_CACHE): Likewise. (LINEMAPS_MAP_AT): Likewise. (LINEMAPS_ORDINARY_MAPS): Strengthen return type from line_map * to line_map_ordinary *. (LINEMAPS_ORDINARY_MAP_AT): Likewise. (LINEMAPS_LAST_ORDINARY_MAP): Likewise. (LINEMAPS_LAST_ALLOCATED_ORDINARY_MAP): Likewise. (LINEMAPS_MACRO_MAPS): Strengthen return type from line_map * to line_map_macro *. (LINEMAPS_MACRO_MAP_AT): Likewise. (LINEMAPS_LAST_MACRO_MAP): Likewise. (LINEMAPS_LAST_ALLOCATED_MACRO_MAP): Likewise. (linemap_map_get_macro_name): Strengthen param from const line_map * to const line_map_macro *. (SOURCE_LINE): Strengthen first param from const line_map * to const line_map_ordinary *, removing call to linemap_check_ordinary. (SOURCE_COLUMN): Likewise. (LAST_SOURCE_LINE_LOCATION): Likewise. (LAST_SOURCE_LINE): Strengthen first param from const line_map * to const line_map_ordinary *. (LAST_SOURCE_COLUMN): Likewise. (INCLUDED_FROM): Strengthen return type from line_map * to line_map_ordinary *., and second param from const line_map * to const line_map_ordinary *, removing call to linemap_check_ordinary. (MAIN_FILE_P): Strengthen param from const line_map * to const line_map_ordinary *, removing call to linemap_check_ordinary. (linemap_position_for_line_and_column): Strengthen param from const line_map * to const line_map_ordinary *. (LINEMAP_FILE): Strengthen param from const line_map * to const line_map_ordinary *, removing call to linemap_check_ordinary. (LINEMAP_LINE): Likewise. (LINEMAP_SYSP): Likewise. (linemap_resolve_location): Strengthen final param from const line_map ** to const line_map_ordinary **. * internal.h (CPP_INCREMENT_LINE): Likewise for local "map". (linemap_enter_macro): Strengthen return type from const line_map * to const line_map_macro *. (linemap_add_macro_token): Likewise for first param. * line-map.c (linemap_check_files_exited): Strengthen local "map" from const line_map * to const line_map_ordinary *. (new_linemap): Introduce local "map_size" and use it when calculating how large the buffer should be. Rewrite based on change of info_macro and info_ordinary into distinct types. (linemap_add): Strengthen locals "map" and "from" from line_map * to line_map_ordinary *. (linemap_enter_macro): Strengthen return type from const line_map * to const line_map_macro *, and local "map" from line_map * to line_map_macro *. (linemap_add_macro_token): Strengthen param "map" from const line_map * to const line_map_macro *. (linemap_line_start): Strengthen local "map" from line_map * to line_map_ordinary *. (linemap_position_for_column): Likewise. (linemap_position_for_line_and_column): Strengthen first param from const line_map * to const line_map_ordinary *. (linemap_position_for_loc_and_offset): Strengthen local "map" from const line_map * to const line_map_ordinary *. (linemap_ordinary_map_lookup): Likewise for return type and locals "cached" and "result". (linemap_macro_map_lookup): Strengthen return type and locals "cached" and "result" from const line_map * to const line_map_macro *. (linemap_macro_map_loc_to_exp_point): Likewise for param "map". (linemap_macro_map_loc_to_def_point): Likewise. (linemap_macro_map_loc_unwind_toward_spelling): Likewise. (linemap_get_expansion_line): Strengthen local "map" from const line_map * to const line_map_ordinary *. (linemap_get_expansion_filename): Likewise. (linemap_map_get_macro_name): Strengthen param from const line_map * to const line_map_macro *. (linemap_location_in_system_header_p): Add call to linemap_check_ordinary in region guarded by !linemap_macro_expansion_map_p. Introduce local "macro_map" via linemap_check_macro in other region, using it in place of "map" for typesafety. (first_map_in_common_1): Add calls to linemap_check_macro. (trace_include): Strengthen param "map" from const line_map * to const line_map_ordinary *. (linemap_macro_loc_to_spelling_point): Strengthen final param from const line_map ** to const line_map_ordinary **. Replace a C-style cast with a const_cast, and add calls to linemap_check_macro and linemap_check_ordinary. (linemap_macro_loc_to_def_point): Likewise. (linemap_macro_loc_to_exp_point): Likewise. (linemap_resolve_location): Strengthen final param from const line_map ** to const line_map_ordinary **. (linemap_unwind_toward_expansion): Introduce local "macro_map" via a checked cast and use it in place of *map. (linemap_unwind_to_first_non_reserved_loc): Strengthen local "map1" from const line_map * to const line_map_ordinary *. (linemap_expand_location): Introduce local "ord_map" via a checked cast and use it in place of map. (linemap_dump): Make local "map" const. Strengthen local "includer_map" from line_map * to const line_map_ordinary *. Introduce locals "ord_map" and "macro_map" via checked casts and use them in place of "map" for typesafety. (linemap_dump_location): Strengthen local "map" from const line_map * to const line_map_ordinary *. (linemap_get_file_highest_location): Update for elimination of union. (linemap_get_statistics): Strengthen local "cur_map" from line_map * to const line_map_macro *. Update uses of sizeof to use the appropriate line_map subclasses. * macro.c (_cpp_warn_if_unused_macro): Add call to linemap_check_ordinary. (builtin_macro): Strengthen local "map" from const line_map * to const line_map_macro *. (enter_macro_context): Likewise. (replace_args): Likewise. (tokens_buff_put_token_to): Likewise for param "map". (tokens_buff_add_token): Likewise. From-SVN: r223365
2015-05-13libcpp/input.c: Add a way to visualize the linemaps (-fdump-internal-locations)David Malcolm3-1/+225
gcc/ChangeLog: * common.opt (fdump-internal-locations): New option. * input.c: Include diagnostic-core.h. (get_end_location): New function. (write_digit): New function. (write_digit_row): New function. (dump_location_range): New function. (dump_labelled_location_range): New function. (dump_location_info): New function. * input.h (dump_location_info): New prototype. * toplev.c (compile_file): Handle flag_dump_locations. libcpp/ChangeLog: * include/line-map.h (source_location): Add a reference to location-example.txt to the descriptive comment. * location-example.txt: New file. From-SVN: r223163
2015-05-13libcpp: Replace macro usage with C++ constructsDavid Malcolm3-113/+517
libcpp/ChangeLog: * include/line-map.h (MAX_SOURCE_LOCATION): Convert from a macro to a const source_location. (RESERVED_LOCATION_COUNT): Likewise. (linemap_check_ordinary): Convert from a macro to a pair of inline functions, for const/non-const arguments. (MAP_START_LOCATION): Likewise. (ORDINARY_MAP_STARTING_LINE_NUMBER): Likewise. (ORDINARY_MAP_INCLUDER_FILE_INDEX): Likewise. (ORDINARY_MAP_IN_SYSTEM_HEADER_P): Likewise. (ORDINARY_MAP_NUMBER_OF_COLUMN_BITS): Convert from a macro to a pair of inline functions, for const/non-const arguments, where the latter is named... (SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS): New function. (ORDINARY_MAP_FILE_NAME): Convert from a macro to a pair of inline functions, for const/non-const arguments. (MACRO_MAP_MACRO): Likewise. (MACRO_MAP_NUM_MACRO_TOKENS): Likewise. (MACRO_MAP_LOCATIONS): Likewise. (MACRO_MAP_EXPANSION_POINT_LOCATION): Likewise. (LINEMAPS_MAP_INFO): Likewise. (LINEMAPS_MAPS): Likewise. (LINEMAPS_ALLOCATED): Likewise. (LINEMAPS_USED): Likewise. (LINEMAPS_CACHE): Likewise. (LINEMAPS_ORDINARY_CACHE): Likewise. (LINEMAPS_MACRO_CACHE): Likewise. (LINEMAPS_MAP_AT): Convert from a macro to an inline function. (LINEMAPS_LAST_MAP): Likewise. (LINEMAPS_LAST_ALLOCATED_MAP): Likewise. (LINEMAPS_ORDINARY_MAPS): Likewise. (LINEMAPS_ORDINARY_MAP_AT): Likewise. (LINEMAPS_ORDINARY_ALLOCATED): Likewise. (LINEMAPS_ORDINARY_USED): Likewise. (LINEMAPS_LAST_ORDINARY_MAP): Likewise. (LINEMAPS_LAST_ALLOCATED_ORDINARY_MAP): Likewise. (LINEMAPS_MACRO_MAPS): Likewise. (LINEMAPS_MACRO_MAP_AT): Likewise. (LINEMAPS_MACRO_ALLOCATED): Likewise. (LINEMAPS_MACRO_USED): Likewise. (LINEMAPS_MACRO_LOWEST_LOCATION): Likewise. (LINEMAPS_LAST_MACRO_MAP): Likewise. (LINEMAPS_LAST_ALLOCATED_MACRO_MAP): Likewise. (IS_ADHOC_LOC): Likewise. (COMBINE_LOCATION_DATA): Likewise. (SOURCE_LINE): Likewise. (SOURCE_COLUMN): Likewise. (LAST_SOURCE_LINE_LOCATION): Likewise. (LAST_SOURCE_LINE): Likewise. (LAST_SOURCE_COLUMN): Likewise. (LAST_SOURCE_LINE_LOCATION) (INCLUDED_FROM): Likewise. (MAIN_FILE_P): Likewise. (LINEMAP_FILE): Likewise. (LINEMAP_LINE): Likewise. (LINEMAP_SYSP): Likewise. (linemap_location_before_p): Likewise. * line-map.c (linemap_check_files_exited): Make local "map" const. (linemap_add): Use SET_ORDINARY_MAP_NUMBER_OF_COLUMN_BITS. (linemap_line_start): Likewise. From-SVN: r223152
2015-05-13libcpp: Bump to automake 1.11.6Michael Haubenwallner2-2/+7
2015-05-13 Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com> * aclocal.m4: Regenerated with automake-1.11.6. From-SVN: r223133
2015-05-13line-map.h: move linemap_assert and friends higher up within the fileDavid Malcolm2-35/+44
libcpp/ChangeLog: * include/line-map.h (linemap_assert): Move up within the file to before all of the map accessor macros. (linemap_assert_fails): Likewise. (linemap_check_ordinary): Likewise. (linemap_macro_expansion_map_p): Likewise. From-SVN: r223121
2015-05-12Implement -Wmisleading-indentationDavid Malcolm3-2/+14
gcc/ChangeLog: * doc/invoke.texi (Warning Options): Add -Wmisleading-indentation. (-Wmisleading-indentation): New option. * Makefile.in (C_COMMON_OBJS): Add c-family/c-indentation.o. gcc/c-family/ChangeLog: * c-common.h (warn_for_misleading_indentation): New prototype. * c-indentation.c: New file. * c.opt (Wmisleading-indentation): New option. gcc/c/ChangeLog: * c-parser.c (c_parser_if_body): Add param "if_loc", use it to add a call to warn_for_misleading_indentation. (c_parser_else_body): Likewise, adding param "else_loc". (c_parser_if_statement): Check for misleading indentation. (c_parser_while_statement): Likewise. (c_parser_for_statement): Likewise. gcc/cp/ChangeLog: * parser.c (cp_parser_selection_statement): Add location and guard_kind arguments to calls to cp_parser_implicitly_scoped_statement. (cp_parser_iteration_statement): Likewise for calls to cp_parser_already_scoped_statement. (cp_parser_implicitly_scoped_statement): Add "guard_loc" and "guard_kind" params; use them to warn for misleading indentation. (cp_parser_already_scoped_statement): Likewise. gcc/testsuite/ChangeLog: * c-c++-common/Wmisleading-indentation.c: New testcase. * c-c++-common/Wmisleading-indentation-2.c: New testcase. * c-c++-common/Wmisleading-indentation-2.md: New file. libcpp/ChangeLog: * directives.c (do_line): Set seen_line_directive on line_table. (do_linemarker): Likewise. * include/line-map.h (struct line_maps): Add new field "seen_line_directive". From-SVN: r223098
2015-05-09lex.c (lex_string): Add -Wc++11-compat warning.Jason Merrill4-1/+19
libcpp/ * lex.c (lex_string): Add -Wc++11-compat warning. * include/cpplib.h: Add CPP_W_CXX11_COMPAT. (struct cpp_options): Add cpp_warn_cxx11_compat. * init.c (cpp_create_reader): Initialize it. gcc/c-family/ * c.opt (Wc++0x-compat): Set it. From-SVN: r222961
2015-05-05Fix indentation issues seen by -Wmisleading-indentationDavid Malcolm2-1/+6
gcc/ChangeLog: * auto-profile.c (afdo_find_equiv_class): Fix indentation so that it reflects the block structure. (afdo_propagate_edge): Likewise. (afdo_calculate_branch_prob): Likewise. (afdo_annotate_cfg): Likewise. * cfgcleanup.c (equal_different_set_p): Likewise. (try_crossjump_to_edge): Likewise. * cgraph.c (cgraph_node::verify_node): Likewise. * cgraphunit.c (expand_all_functions): Likewise. * config/i386/i386.c (ix86_expand_copysign): Likewise. (exact_dependency_1): Likewise. * dwarf2asm.c (dw2_output_indirect_constants): Likewise. * dwarf2out.c (tree_add_const_value_attribute_for_decl): Likewise. * gensupport.c (process_define_subst): Likewise. * lto-wrapper.c (merge_and_complain): Likewise. * tree-if-conv.c (if_convertible_bb_p): Likewise. * tree-ssa-loop-prefetch.c (find_or_create_group): Likewise. * tree-ssa-tail-merge.c (gsi_advance_fw_nondebug_nonlocal): Likewise. * tree-vect-data-refs.c (vect_grouped_load_supported): Likewise. * tree-vect-loop.c (vectorizable_reduction): Likewise. * tree-vect-slp.c (vect_transform_slp_perm_load): Likewise. * tree-vect-stmts.c (vectorizable_shift): Likewise. * tree-vrp.c (vrp_finalize): Likewise. * tree.c (variably_modified_type_p): Likewise. gcc/cp/ChangeLog: * parser.c (cp_parser_asm_definition): Only test for error_mark_node if "outputs" was just set. (cp_parser_asm_definition): Likewise for "inputs". gcc/fortran/ChangeLog: * expr.c (check_inquiry): Fix indentation so that it reflects the block structure. * interface.c (compare_parameter): Likewise. * parse.c (parse_oacc_structured_block): Likewise. * target-memory.c (expr_to_char): Likewise. * trans-types.c (gfc_init_kinds): Likewise. libcpp/ChangeLog: * pch.c (cpp_valid_state): Fix indentation so that it reflects the block structure. From-SVN: r222823
2015-05-05libcpp: Improvements to comments in line-map.h/cDavid Malcolm3-3/+78
libcpp/ChangeLog: * include/line-map.h: Fix comment at the top of the file. (source_location): Rewrite and expand the comment for this typedef, adding an ascii-art table to clarify how source_location values are allocated. * line-map.c: Fix comment at the top of the file. From-SVN: r222806
2015-05-01* sv.po: Update.Joseph Myers2-2/+6
From-SVN: r222692
2015-04-30be.po, [...]: Update.Joseph Myers22-1241/+1247
* be.po, ca.po, da.po, de.po, el.po, eo.po, es.po, fi.po, fr.po, id.po, ja.po, nl.po, pr_BR.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po, zh_TW.po: Update. From-SVN: r222646
2015-04-13gcc.pot: Regenerate.Joseph Myers2-9/+13
gcc/po: * gcc.pot: Regenerate. libcpp/po: * cpplib.pot: Regenerate. From-SVN: r222061
2015-04-12* sr.po: Update.Joseph Myers2-49/+25
From-SVN: r222021
2015-04-11* fr.po: Update.Joseph Myers2-180/+141
From-SVN: r221996
2015-04-10* fr.po: Update.Joseph Myers2-19185/+217
From-SVN: r221989
2015-04-09re PR pch/65550 (ICE (segfault) with pch)Richard Biener2-5/+13
2015-04-09 Richard Biener <rguenther@suse.de> PR pch/65550 * files.c (pch_open_file): Allow main and pre-included files when trying to open a PCH. From-SVN: r221949
2015-04-07* da.po: Update.Joseph Myers2-15495/+240
From-SVN: r221908
2015-04-07gcc.pot: Regenerate.Joseph Myers2-63/+67
gcc/po: * gcc.pot: Regenerate. libcpp/po: * cpplib.pot: Regenerate. From-SVN: r221904
2015-04-06re PR preprocessor/61977 (powerpc preprocessor breaks on lines that end with ↵Jakub Jelinek2-2/+11
"vector") PR preprocessor/61977 * lex.c (cpp_peek_token): If peektok is CPP_EOF, back it up with all tokens peeked by the current function. * gcc.dg/cpp/pr61977.c: New test. From-SVN: r221882
2015-04-02re PR preprocessor/61977 (powerpc preprocessor breaks on lines that end with ↵Jakub Jelinek2-0/+12
"vector") PR preprocessor/61977 * lex.c (cpp_peek_token): Temporarily clear pfile->cb.line_change. * gcc.target/powerpc/pr61977-1.c: New test. * gcc.target/powerpc/pr61977-2.c: New test. From-SVN: r221839
2015-03-24* fr.po: Update.Joseph Myers2-2/+6
From-SVN: r221638
2015-03-23* fr.po: Update.Joseph Myers2-6/+11
From-SVN: r221598
2015-03-23re PR preprocessor/65238 (__has_attribute is not handled properly with ↵Jakub Jelinek4-18/+163
-traditional-cpp.) PR preprocessor/65238 * internal.h (_cpp_scan_out_logical_line): Add third argument. * directives.c (prepare_directive_trad): Pass false to it. * traditional.c (_cpp_read_logical_line_trad, _cpp_create_trad_definition): Likewise. (struct fun_macro): Add paramc field. (fun_like_macro): New function. (maybe_start_funlike): Handle NODE_BUILTIN macros. Initialize macro->paramc field. (save_argument): Use macro->paramc instead of macro->node->value.macro->paramc. (push_replacement_text): Formatting fix. (recursive_macro): Use fun_like_macro helper. (_cpp_scan_out_logical_line): Likewise. Add BUILTIN_MACRO_ARG argument. Initialize fmacro.paramc field. Handle builtin function-like macros. * c-c++-common/cpp/pr65238-1.c: New test. * gcc.dg/cpp/pr65238-2.c: New test. * gcc.dg/cpp/trad/pr65238-3.c: New test. * gcc.dg/cpp/trad/pr65238-4.c: New test. From-SVN: r221587
2015-03-17re PR c++/64626 (C++14 single quote should not always be a digit separator)Edward Smith-Rowland2-0/+9
libcpp/ 2015-03-16 Edward Smith-Rowland <3dw4rd@verizon.net> PR c++/64626 * lex.c (lex_number): If a number ends with digit-seps (') skip back and let lex_string take them. gcc/testsuite/ 2015-03-16 Edward Smith-Rowland <3dw4rd@verizon.net> PR c++/64626 g++.dg/cpp1y/pr64626-1.C: New. g++.dg/cpp1y/pr64626-2.C: New. g++.dg/cpp1y/digit-sep-neg.C: Adjust errors and warnings. From-SVN: r221470
2015-03-04re PR target/65261 (bootstrap-ubsan ppc64le: gcc/libcpp/lex.c:552:30: ↵Markus Trippelsdorf2-0/+6
runtime error: load of misaligned address 0x01002172dfc6 for type 'const uchar', which requires 16 byte alignment) Fix PR65261 Running bootstrap-ubsan on ppc64le shows many instances of: libcpp/lex.c:552:30: runtime error: load of misaligned address 0x01001f31d37a for type 'const uchar', which requires 16 byte alignment But the unaligned vector loads are intended in this case, because they are preferable to forced-alignment on POWER8. So just silence the ubsan errors. 2015-03-02 Markus Trippelsdorf <markus@trippelsdorf.de> include/ PR target/65261 * ansidecl.h (ATTRIBUTE_NO_SANITIZE_UNDEFINED): New macro. libcpp/ PR target/65261 * lex.c (search_line_fast): Silence ubsan errors. From-SVN: r221190
2015-02-25be.po, [...]: Update.Joseph Myers22-7254/+5705
* be.po, ca.po, da.po, de.po, el.po, eo.po, es.po, fi.po, fr.po, id.po, ja.po, nl.po, pr_BR.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po, zh_TW.po: Update. From-SVN: r220976
2015-02-03PR preprocessor/64803 - __LINE__ inside macro is not constantDodji Seketeli3-3/+45
Consider the example code mentionned in this PR: $ cat -n test.c 1 #define C(a, b) a ## b 2 #define L(x) C(L, x) 3 #define M(a) goto L(__LINE__); __LINE__; L(__LINE__): 4 M(a /* --> this is the line of the expansion point of M. */ 5 ); /* --> this is the line of the end of the invocation of M. */ $ "cc1 -quiet -E test.c" yields: goto L5; 5; L4: ; Notice how we have a 'L4' there, where it should be L5. That is the issue. My understanding is that during the *second* expansion of __LINE__ (the one between the two L(__LINE__)), builtin_macro() is called by enter_macro_context() with the location of the expansion point of M (which is at line 4). Then _cpp_builtin_macro_text() expands __LINE__ into the line number of the location of the last token that has been lexed, which is the location of the closing parenthesis of the invocation of M, at line 5. So that invocation of __LINE__ is expanded into 5. Now let's see why the last invocation of __LINE__ is expanded into 4. In builtin_macro(), we have this code at some point: /* Set pfile->cur_token as required by _cpp_lex_direct. */ pfile->cur_token = _cpp_temp_token (pfile); cpp_token *token = _cpp_lex_direct (pfile); /* We should point to the expansion point of the builtin macro. */ token->src_loc = loc; The first two statements insert a new token in the stream of lexed token and pfile->cur_token[-1], is the "new" last token that has been lexed. But the location of pfile->cur_token[-1] is the same location as the location of the "previous" pfile->cur_token[-1], by courtesy of _cpp_temp_token(). So normally, in subsequent invocations of builtin_macro(), the location of pfile->cur_token[-1] should always be the location of the closing parenthesis of the invocation of M at line 5. Except that that code in master now has the statement "token->src_loc = loc;" on the next line. That statement actually sets the location of pfile->cur_token[-1] to 'loc'. Which is the location of the expansion point of M, which is on line 4. So in the subsequent call to builtin_macro() (for the last expansion of __LINE__ in L(__LINE__)), for _cpp_builtin_macro_text(), pfile->cur_token[-1].src_loc is going to have a line number of 4. I think the core issue here is that the location that is passed to builtin_macro() from enter_macro_context() is not correct when we are in presence of a top-most function-like macro invocation; in that case, that location should be the location of the closing parenthesis of the macro invocation. Otherwise, if we are in presence of a a top-most object-like macro invocation then the location passed down to builtin_macro should be the location of the expansion point of the macro. That way, in the particular case of the input code above, the location received by builtin_macro() will always have line number 5. Boostrapped and tested on x86_64-unknown-linux-gnu against trunk. libcpp/ChangeLog: * internal.h (cpp_reader::top_most_macro_node): New data member. * macro.c (enter_macro_context): Pass the location of the end of the top-most invocation of the function-like macro, or the location of the expansion point of the top-most object-like macro. (cpp_get_token_1): Store the top-most macro node in the new pfile->top_most_macro_node data member. (_cpp_pop_context): Clear the new cpp_reader::top_most_macro_node data member. gcc/testsuite/ChangeLog: * gcc.dg/cpp/builtin-macro-1.c: New test case. Signed-off-by: Dodji Seketeli <dodji@redhat.com> From-SVN: r220367