aboutsummaryrefslogtreecommitdiff
path: root/libcpp
AgeCommit message (Collapse)AuthorFilesLines
2018-11-07iconv.m4 (AM_ICONV_LINK): Don't overwrite CPPFLAGS.Hafiz Abid Qadeer2-1/+5
2018-11-06 Hafiz Abid Qadeer <abidh@codesourcery.com> * config/iconv.m4 (AM_ICONV_LINK): Don't overwrite CPPFLAGS. Append $INCICONV to it. gcc/ * configure: Regenerated. libcpp/ * configure: Likewise. libstdc++-v3/ * configure: Likewise. intl/ * configure: Likewise. From-SVN: r265896
2018-11-05Do not use %zu format in libcpp.Martin Liska2-1/+5
2018-11-05 Martin Liska <mliska@suse.cz> * symtab.c (ht_dump_statistics): Replace %zu with %lu format. From-SVN: r265811
2018-11-05Fix printf call in symtab.c.Martin Liska2-2/+8
2018-11-05 Martin Liska <mliska@suse.cz> * symtab.c (ht_dump_statistics): Fix format and pass missing argument. From-SVN: r265810
2018-11-05Fix string pool statistics.Martin Liska2-4/+15
2018-11-05 Martin Liska <mliska@suse.cz> * symtab.c (ht_dump_statistics): Make dump conditional based on alloc_subobject. From-SVN: r265797
2018-10-31Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856).Joseph Myers5-490/+581
This patch updates GCC to use autoconf 2.69 and automake 1.15.1. (That's not the latest automake version, but it's the one used by binutils-gdb, with which consistency is desirable, and in any case seems a useful incremental update that should make a future update to 1.16.1 easier.) The changes are generally similar to the binutils-gdb ones, and are copied from there where shared files and directories are involved (there are some further changes to such shared directories, however, which I'd expect to apply to binutils-gdb once this patch is in GCC). Largely, obsolete AC_PREREQ calls are removed, while many AC_LANG_SOURCE calls are added to avoid warnings from aclocal and autoconf. Multilib support is no longer included in core automake, meaning that multilib.am needs copying from automake's contrib directory into the GCC source tree. Autoconf 2.69 has Go support, so local copies of that support are removed. I hope the D support will soon be submitted to upstream autoconf so the local copy of that can be removed in a future update. Changes to how automake generates runtest calls mean quotes are removed from RUNTEST definitions in five lib*/testsuite/Makefile.am files (libatomic, libgomp, libitm, libphobos, libvtv; some others have RUNTEST definitions without quotes, which are still OK); libgo and libphobos also get -Wno-override added to AM_INIT_AUTOMAKE so those overrides of RUNTEST do not generate automake warnings. Note that the regeneration did not include regeneration of fixincludes/config.h.in (attempting such regeneration resulted in all the USED_FOR_TARGET conditionals disappearing; and I don't see anything in the fixincludes/ directory that would result in such conditionals being generated, unlike in the gcc/ directory). Also note that libvtv/testsuite/other-tests/Makefile.in was not regenerated; that directory is not listed as a subdirectory for which Makefile.in gets regenerated by calling "automake" in libvtv/, so I'm not sure how it's meant to be regenerated. While I mostly fixed warnings should running aclocal / automake / autoconf, there were various such warnings from automake in the libgfortran, libgo, libgomp, liboffloadmic, libsanitizer, libphobos directories that I did not fix, preferring to leave those to the relevant subsystem maintainers. Specifically, most of those warnings were of the following form (example from libgfortran): Makefile.am:48: warning: source file 'caf/single.c' is in a subdirectory, Makefile.am:48: but option 'subdir-objects' is disabled automake: warning: possible forward-incompatibility. automake: At least a source file is in a subdirectory, but the 'subdir-objects' automake: automake option hasn't been enabled. For now, the corresponding output automake: object file(s) will be placed in the top-level directory. However, automake: this behaviour will change in future Automake versions: they will automake: unconditionally cause object files to be placed in the same subdirectory automake: of the corresponding sources. automake: You are advised to start using 'subdir-objects' option throughout your automake: project, to avoid future incompatibilities. I think it's best for the relevant maintainers to add subdir-objects and do any other associated Makefile.am changes needed. In some cases the paths in the warnings involved ../; I don't know if that adds any extra complications to the use of subdir-objects. I've tested this with native, cross and Canadian cross builds. The risk of any OS-specific issues should I hope be rather lower than if a libtool upgrade were included (we *should* do such an upgrade at some point, but it's more complicated - it involves identifying all our local libtool changes to see if any aren't included in the upstream version we update to, and reverting an upstream libtool patch that's inappropriate for use in GCC); I think it would be better to get this update into GCC so that people can test in different configurations and we can fix any issues found, rather than to try to get more and more testing done before it goes in. top level: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * multilib.am: New file. From automake. Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * libtool.m4: Use AC_LANG_SOURCE. * configure.ac: Remove AC_PREREQ, use AC_LANG_SOURCE. * ar-lib: New file. * test-driver: New file. * configure: Re-generate. config: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * math.m4, tls.m4: Use AC_LANG_SOURCE. Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * override.m4 (_GCC_AUTOCONF_VERSION): Bump from 2.64 to 2.69. fixincludes: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * aclocal.m4, configure: Regenerate. gcc: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. Use single line for second argument of AC_DEFINE_UNQUOTED. * doc/install.texi (Tools/packages necessary for modifying GCC): Update to autoconf 2.69 and automake 1.15.1. * aclocal.m4, config.in, configure: Regenerate. gnattools: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * configure: Regenerate. gotools: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * config/go.m4: Remove file. * Makefile.am (ACLOCAL_AMFLAGS): Do not use -I ./config. * configure.ac: Remove AC_PREREQ. Do not include config/go.m4. * Makefile.in, aclocal.m4, configure: Regenerate. intl: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * configure.ac: Add AC_USE_SYSTEM_EXTENSIONS, remove AC_PREREQ. * configure: Re-generate. * config.h.in: Re-generate. * aclocal.m4: Re-generate. libada: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * configure: Regenerate. libatomic: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * acinclude.m4: Use AC_LANG_SOURCE. * configure.ac: Remove AC_PREREQ. * testsuite/Makefile.am (RUNTEST): Remove quotes. * Makefile.in, aclocal.m4, configure, testsuite/Makefile.in: Regenerate. libbacktrace: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. * Makefile.in, aclocal.m4, config.h.in, configure: Regenerate. libcc1: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, configure: Regenerate. libcpp: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. * aclocal.m4, config.in, configure: Regenerate. libdecnumber: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * configure.ac: Remove AC_PREREQ. * configure: Re-generate. * aclocal.m4. libffi: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. (AUTOMAKE_OPTIONS): Add info-in-builddir. (CLEANFILES): Remove doc/libffi.info. * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, configure, fficonfig.h.in, include/Makefile.in, man/Makefile.in, testsuite/Makefile.in: Regenerate. libgcc: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. * configure: Regenerate. libgfortran: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, config.h.in, configure: Regenerate. libgo [logically part of this change but omitted from the commit]: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * config/go.m4: Remove file. * config/libtool.m4: Use AC_LANG_SOURCE. * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. Use -Wno-override in AM_INIT_AUTOMAKE call. * Makefile.in, aclocal.m4, configure, testsuite/Makefile.in: Regenerate. libgomp: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am (AUTOMAKE_OPTIONS): Add info-in-builddir. (CLEANFILES): Remove libgomp.info. * configure.ac: Remove AC_PREREQ. * testsuite/Makefile.am (RUNTEST): Remove quotes. * Makefile.in, aclocal.m4, configure, testsuite/Makefile.in: Regenerate. libhsail-rt: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, configure: Regenerate. libiberty: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * configure.ac: Remove AC_PREREQ. * configure: Re-generate. * config.in: Re-generate. libitm: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. (AUTOMAKE_OPTIONS): Add info-in-builddir. (CLEANFILES): Remove libitm.info. * configure.ac: Remove AC_PREREQ. * testsuite/Makefile.am (RUNTEST): Remove quotes. * Makefile.in, aclocal.m4, configure, testsuite/Makefile.in: Regenerate. libobjc: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * aclocal.m4, config.h.in, configure: Regenerate. liboffloadmic: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. * plugin/Makefile.am: Include multilib.am. * plugin/configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, configure, plugin/Makefile.in, plugin/aclocal.m4, plugin/configure: Regenerate. libphobos: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. Use -Wno-override in AM_INIT_AUTOMAKE call. * m4/autoconf.m4: Add extra argument to AC_LANG_DEFINE call. * m4/druntime/os.m4: Use AC_LANG_SOURCE. * testsuite/Makefile.am (RUNTEST): Remove quotes. * Makefile.in, aclocal.m4, configure, libdruntime/Makefile.in, src/Makefile.in, testsuite/Makefile.in: Regenerate. libquadmath: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. (AUTOMAKE_OPTIONS): Remove 1.8. Add info-in-builddir. (all-local): Define outside conditional code. (CLEANFILES): Remove libquadmath.info. * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, config.h.in, configure: Regenerate. libsanitizer: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. * Makefile.in, aclocal.m4, asan/Makefile.in, configure, interception/Makefile.in, libbacktrace/Makefile.in, lsan/Makefile.in, sanitizer_common/Makefile.in, tsan/Makefile.in, ubsan/Makefile.in: Regenerate. libssp: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. (AUTOMAKE_OPTIONS): Remove 1.9.5. * configure.ac: Remove AC_PREREQ. Quote argument to AC_RUN_IFELSE. * Makefile.in, aclocal.m4, configure: Regenerate. libstdc++-v3: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, configure, doc/Makefile.in, include/Makefile.in, libsupc++/Makefile.in, po/Makefile.in, python/Makefile.in, src/Makefile.in, src/c++11/Makefile.in, src/c++17/Makefile.in, src/c++98/Makefile.in, src/filesystem/Makefile.in, testsuite/Makefile.in: Regenerate. libvtv: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. * testsuite/Makefile.am (RUNTEST): Remove quotes. * Makefile.in, aclocal.m4, configure, testsuite/Makefile.in: Regenerate. lto-plugin: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. * Makefile.in, aclocal.m4, config.h.in, configure: Regenerate. zlib: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * configure.ac: Modernize AC_INIT call, remove AC_PREREQ. * Makefile.am (AUTOMAKE_OPTIONS): Remove 1.8, cygnus, add foreign. * Makefile.in: Re-generate. * aclocal.m4: Re-generate. * configure: Re-generate. From-SVN: r265695
2018-10-31[6/6] Preprocessor forced macro locationNathan Sidwell5-11/+18
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg02044.html libcpp/ * internal.h (struct cpp_reader): Rename forced_token_location_p to forced_token_location and drop its pointerness. * include/cpplib.h (cpp_force_token_locations): Take location, not pointer to one. * init.c (cpp_create_reader): Adjust. * lex.c (cpp_read_main_file): gcc/c-family/ * c-opts.c (c_finish_options): Adjust cpp_force_token_locations call. gcc/fortran/ * cpp.c (gfc_cpp_init): Adjust cpp_force_token_locations call. From-SVN: r265692
2018-10-31[5/6] Preprocessor includeNathan Sidwell2-14/+13
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg02041.html * directives.c (do_include_common): Commonize cleanup path. (_cpp_pop_buffer): Fix leak. From-SVN: r265690
2018-10-31[4/7] Preprocessor location-kind predicatesNathan Sidwell3-10/+29
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg02040.html * include/line-map.h (IS_ORDINARY_LOC, IS_MACRO_LOC): New predicates. (IS_ADHOC_LOC): Move earlier. (MAP_ORDINARY_P): Use IS_ORDINARY_LOC. * line-map.c (linemap_location_from_macro_expansion_p): Use IS_MACRO_LOC. From-SVN: r265689
2018-10-31[3/7] Preprocessor macro locNathan Sidwell3-16/+14
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg02039.html * include/cpplib.h (cpp_macro_definition_location): Make inline. * macro.c (warn_of_redefinition): Fix comments, examine macro type, use C++ for. (cpp_macro_definition_location): Don't define here. From-SVN: r265688
2018-10-31[2/7] Preprocessor node accessNathan Sidwell2-3/+6
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg02038.html * include/cpplib.h (HT_NODE): Don't cast NODE. (NODE_LEN, NODE_NAME): Use HT_NODE. From-SVN: r265687
2018-10-31[1/7] Preprocessor cleanupNathan Sidwell3-28/+29
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg02037.html * directives.c (DIRECTIVE_TABLE): Drop historical frequency comments. * files.c (_cpp_stack_file): Fix indentation. From-SVN: r265685
2018-10-18Add -std=c2x, -std=gnu2x, -Wc11-c2x-compat, C2X _Static_assert support.Joseph Myers3-1/+13
Now new features are starting to be added to a C2X draft (in the C2x branch of the C standard git repository, no public WG14 document yet), it's time to add -std=c2x and associated options to GCC for use in enabling C2X features. This patch adds the expected set of options: -std=c2x, -std=gnu2x, -Wc11-c2x-compat. A first C2X feature is added (the only one so far in the repository that's obviously relevant to GCC): support (as in C++) for the string constant to be omitted in _Static_assert. This feature is duly also supported as an extension in earlier standard modes (diagnosed with -pedantic, unless -Wno-c11-c2x-compat is given, or with -Wc11-c2x-compat even in C2X mode). Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/ * doc/cpp.texi (__STDC_VERSION__): Document C2X handling. * doc/invoke.texi (-std=c2x, -std=gnu2x): Document new options. * doc/standards.texi (C Language): Document C2X. * dwarf2out.c (highest_c_language), config/rl78/rl78.c (rl78_option_override): Handle "GNU C2X" language name. gcc/c/ * c-errors.c (pedwarn_c11): New function. * c-parser.c (disable_extension_diagnostics): Save warn_c11_c2x_compat and set it to 0. (restore_extension_diagnostics): Restore warn_c11_c2x_compat. (c_parser_static_assert_declaration_no_semi): Handle _Static_assert without string constant. * c-tree.h (pedwarn_c11): New prototype. gcc/c-family/ * c-common.c (flag_isoc2x): New variable. * c-common.h (clk_c): Update comment to reference C2X. (flag_isoc99, flag_isoc11): Update comments to reference future standard versions in general. (flag_isoc2x): Declare. * c-opts.c (set_std_c2x): New function. (c_common_handle_option): Handle -std=c2x and -std=gnu2x. (set_std_c89, set_std_c99, set_std_c11, set_std_c17): Set flag_isoc2x to 0. * c.opt (Wc11-c2x-compat, std=c2x, std=gnu2x): New options. gcc/testsuite/ * gcc.dg/c11-static-assert-7.c, gcc.dg/c11-static-assert-8.c, gcc.dg/c11-static-assert-9.c, gcc.dg/c2x-static-assert-1.c, gcc.dg/c2x-static-assert-2.c, gcc.dg/c99-static-assert-2.c, gcc.dg/gnu2x-static-assert-1.c: New tests. * gcc.dg/missing-symbol-3.c: Update expected fix-it text. libcpp/ * include/cpplib.h (enum c_lang): Add CLK_GNUC2X and CLK_STDC2X. * init.c (lang_defaults): Add GNUC2X and STDC2X entries. (cpp_init_builtins): Define __STDC_VERSION__ to 202000L for C2X. From-SVN: r265251
2018-10-11libcpp: show macro definition when used with wrong argument countDavid Malcolm2-0/+9
Consider: demo.c: In function 'test': demo.c:5:40: error: macro "LOG_2" requires 3 arguments, but only 2 given 5 | LOG_2 ("loading file: %s\n", filename); | ^ This patch adds a note showing the definition of the macro in question, giving: demo.c: In function 'test': demo.c:5:40: error: macro "LOG_2" requires 3 arguments, but only 2 given 5 | LOG_2 ("loading file: %s\n", filename); | ^ In file included from demo.c:1: logging.h:1: note: macro "LOG_2" defined here 1 | #define LOG_2(FMT, ARG0, ARG1) do { fprintf (stderr, (FMT), (ARG0), (ARG1)); } | gcc/testsuite/ChangeLog: * g++.dg/diagnostic/macro-arg-count.C: Move to... * c-c++-common/cpp/macro-arg-count-1.c: ...here, generalizing output for C vs C++. Expect notes showing the definitions of the macros. * c-c++-common/cpp/macro-arg-count-2.c: New test, adapted from the above. libcpp/ChangeLog: * macro.c (_cpp_arguments_ok): If the argument count is wrong, add a note showing the definition of the macro. From-SVN: r265040
2018-10-11[PATCH] A couple of line map fixesNathan Sidwell3-14/+15
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00623.html * include/line-map.h (LINEMAPS_MACRO_LOWEST_LOCATION): Fix off-by-one error. * line-map.c (linemap_enter_macro): Use RAII. Clear all of the macro_locations. From-SVN: r265037
2018-10-09Cleanup of libcpp diagnostic callbacksDavid Malcolm6-123/+191
This patch renames the "error" callback within libcpp to "diagnostic", and uses the pair of enums in cpplib.h, rather than passing two different kinds of "int" around. gcc/c-family/ChangeLog: * c-common.c (c_option_controlling_cpp_error): Rename to... (c_option_controlling_cpp_diagnostic): ...this, and convert "reason" from int to enum. (c_cpp_error): Rename to... (c_cpp_diagnostic): ...this, converting level and reason to enums. * c-common.h (c_cpp_error): Rename to... (c_cpp_diagnostic): ...this, converting level and reason to enums. * c-opts.c (c_common_init_options): Update for renaming. gcc/fortran/ChangeLog: * cpp.c (gfc_cpp_init_0): Update for renamings. (cb_cpp_error): Rename to... (cb_cpp_diagnostic): ...this, converting level and reason to enums. gcc/ChangeLog: * genmatch.c (error_cb): Rename to... (diagnostic_cb): ...this, converting int params to enums. (fatal_at): Update for renaming. (warning_at): Likewise. (main): Likewise. * input.c (selftest::ebcdic_execution_charset::apply): Update for renaming of... (selftest::ebcdic_execution_charset::on_error): ...this, renaming to... (selftest::ebcdic_execution_charset::on_diagnostic): ...this, converting level and reason to enums. (class selftest::lexer_error_sink): Rename to... (class selftest::lexer_test_options): ...this, renaming field "m_errors" to "m_diagnostics". (selftest::lexer_test_options::apply): Update for renaming of... (selftest::lexer_test_options::on_error): ...this, renaming to... (selftest::lexer_test_options::on_diagnostic): ...this converting level and reason to enums. (selftest::test_lexer_string_locations_raw_string_unterminated): Update for renamings. * opth-gen.awk (struct cpp_reason_option_codes_t): Use enum for "reason". libcpp/ChangeLog: * charset.c (noop_error_cb): Rename to... (noop_diagnostic_cb): ...this, converting params to enums. (cpp_interpret_string_ranges): Update for renaming and enums. * directives.c (check_eol_1): Convert reason to enum. (do_diagnostic): Convert code and reason to enum. (do_error): Use CPP_W_NONE rather than 0. (do_pragma_dependency): Likewise. * errors.c (cpp_diagnostic_at): Convert level and reason to enums. Update for renaming. (cpp_diagnostic): Convert level and reason to enums. (cpp_error): Convert level to enum. (cpp_warning): Convert reason to enums. (cpp_pedwarning): Likewise. (cpp_warning_syshdr): Likewise. (cpp_diagnostic_with_line): Convert level and reason to enums. Update for renaming. (cpp_error_with_line): Convert level to enum. (cpp_warning_with_line): Convert reason to enums. (cpp_pedwarning_with_line): Likewise. (cpp_warning_with_line_syshdr): Likewise. (cpp_error_at): Convert level to enum. (cpp_errno): Likewise. (cpp_errno_filename): Likewise. * include/cpplib.h (enum cpp_diagnostic_level): Name this enum, and move to before struct cpp_callbacks. (enum cpp_warning_reason): Likewise. (cpp_callbacks::diagnostic): Convert params from int to enums. (cpp_error): Convert int param to enum cpp_diagnostic_level. (cpp_warning): Convert int param to enum cpp_warning_reason. (cpp_pedwarning): Likewise. (cpp_warning_syshdr): Likewise. (cpp_errno): Convert int param to enum cpp_diagnostic_level. (cpp_errno_filename): Likewise. (cpp_error_with_line): Likewise. (cpp_warning_with_line): Convert int param to enum cpp_warning_reason. (cpp_pedwarning_with_line): Likewise. (cpp_warning_with_line_syshdr): Likewise. (cpp_error_at): Convert int param to enum cpp_diagnostic_level. * macro.c (create_iso_definition): Convert int to enum. (_cpp_create_definition): Likewise. From-SVN: r264999
2018-09-17Add range_idx param to range_label::get_textDavid Malcolm2-2/+9
This patch updates the pure virtual function range_label::get_text (and its implementations) so that the index of the range is passed in, allowing for one label instance to be shared by multiple ranges. gcc/c-family/ChangeLog: * c-format.c (range_label_for_format_type_mismatch::get_text): Update for new param. gcc/c/ChangeLog: * c-objc-common.c (range_label_for_type_mismatch::get_text): Update for new param. * c-typeck.c (maybe_range_label_for_tree_type_mismatch::get_text): Likewise. gcc/cp/ChangeLog: * error.c (range_label_for_type_mismatch::get_text): Update for new param. gcc/ChangeLog: * diagnostic-show-locus.c (class layout_range): Add field "m_original_idx". (layout_range::layout_range): Add "original_idx" param and use it to initialize new field. (make_range): Use 0 for original_idx. (layout::layout): Pass in index to calls to maybe_add_location_range. (layout::maybe_add_location_range): Add param "original_idx" and pass it on to layout_range. (layout::print_any_labels): Pass on range->m_original_idx to get_text call. (gcc_rich_location::add_location_if_nearby): Use 0 for original_idx. * gcc-rich-location.h (text_range_label::get_text): Update for new param. (range_label_for_type_mismatch::get_text): Likewise. libcpp/ChangeLog: * include/line-map.h (range_label::get_text): Add param "range_idx". From-SVN: r264376
2018-08-30[libcpp] fix some line map commentsNathan Sidwell2-14/+13
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01978.html * include/line-map.h (enum lc_reason): Comment each member separately. (struct line_maps): Fix reallocator comment. From-SVN: r263987
2018-08-27Replace 8 spaces with a tabular in ChangeLog files.Martin Liska1-4/+4
From-SVN: r263886
2018-08-27Less verbose fix-it hints for missing header files (PR 87091)David Malcolm3-19/+72
This patch tweaks maybe_add_include_fixit so that if we're emitting a note about adding the header file, the note's primary location will be replaced by that of the fix-it hint, to avoid repeating a location we've already emitted (or one close to it). For example, this simplifies: ../x86_64-pc-linux-gnu/libstdc++-v3/include/vector:87:27: error: msg 1 87 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>; | ^~~~~~ ../x86_64-pc-linux-gnu/libstdc++-v3/include/vector:87:22: note: msg 2 73 | # include <debug/vector> +++ |+#include <vector> 74 | #endif .... 87 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>; | ^~~ to: ../x86_64-pc-linux-gnu/libstdc++-v3/include/vector:87:27: error: msg 1 87 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>; | ^~~~~~ ../x86_64-pc-linux-gnu/libstdc++-v3/include/vector:74:1: note: msg 2 73 | # include <debug/vector> +++ |+#include <vector> 74 | #endif eliminating the repetition of line 87 in the note. Doing so requires converting show_caret_p to a tri-state, to avoid meaninglessly printing a caret for the first column in the next line (and colorizing it): ../x86_64-pc-linux-gnu/libstdc++-v3/include/vector:74:1: note: msg 2 73 | # include <debug/vector> +++ |+#include <vector> 74 | #endif | ^ gcc/c-family/ChangeLog: PR 87091 * c-common.c (c_cpp_error): Update for conversion of show_caret_p to a tri-state. (maybe_suggest_missing_token_insertion): Likewise. (maybe_add_include_fixit): Add param "override_location". If set, and source-printing is enabled, then override the rich_location's primary location with that of the insertion point for the fix-it hint, marking it with SHOW_LINES_WITHOUT_RANGE. * c-common.h (extern void maybe_add_include_fixit): Add bool param. * c-format.c (selftest::test_type_mismatch_range_labels): Update for conversion of show_caret_p to a tri-state. * c-warn.c (warn_for_restrict): Likewise. * known-headers.cc (suggest_missing_header::~suggest_missing_header): Update call to maybe_add_include_fixit to suggest overriding the location, as it is for a note. gcc/c/ChangeLog: PR 87091 * c-decl.c (implicitly_declare): Update call to maybe_add_include_fixit to suggest overriding the location, as it is for a note. * c-objc-common.c (c_tree_printer): Update for conversion of show_caret_p to a tri-state. gcc/cp/ChangeLog: PR 87091 * decl.c (grokdeclarator): Update for conversion of show_caret_p to a tri-state. * error.c (cp_printer): Likewise. * name-lookup.c (maybe_suggest_missing_std_header): Update call to maybe_add_include_fixit to suggest overriding the location, as it is for a note. * parser.c (cp_parser_string_literal): Update for conversion of show_caret_p to a tri-state. (cp_parser_elaborated_type_specifier): Likewise. (set_and_check_decl_spec_loc): Likewise. * pt.c (listify): Update call to maybe_add_include_fixit to not override the location, as it is for an error. * rtti.c (typeid_ok_p): Likewise. gcc/ChangeLog: PR 87091 * diagnostic-show-locus.c (class layout_range): Update for conversion of show_caret_p to a tri-state. (layout_range::layout_range): Likewise. (make_range): Likewise. (layout::maybe_add_location_range): Likewise. (layout::should_print_annotation_line_p): Don't show annotation lines for ranges that are SHOW_LINES_WITHOUT_RANGE. (layout::get_state_at_point): Update for conversion of show_caret_p to a tri-state. Bail out early for SHOW_LINES_WITHOUT_RANGE, so that such ranges don't affect underlining or source colorization. (gcc_rich_location::add_location_if_nearby): Update for conversion of show_caret_p to a tri-state. (selftest::test_one_liner_multiple_carets_and_ranges): Likewise. (selftest::test_one_liner_fixit_replace_equal_secondary_range): Likewise. (selftest::test_one_liner_labels): Likewise. * gcc-rich-location.c (gcc_rich_location::add_expr): Update for conversion of show_caret_p to a tri-state. * pretty-print.c (text_info::set_location): Likewise. * pretty-print.h (text_info::set_location): Likewise. * substring-locations.c (format_warning_n_va): Likewise. * tree-diagnostic.c (default_tree_printer): Likewise. * tree-pretty-print.c (newline_and_indent): Likewise. gcc/fortran/ChangeLog: PR 87091 * error.c (gfc_format_decoder): Update for conversion of show_caret_p to a tri-state. gcc/testsuite/ChangeLog: PR 87091 * gcc.dg/empty.h: New file. * gcc.dg/fixits-pr84852-1.c: Update for move of fix-it hint to top of file and removal of redundant second printing of warning location. * gcc.dg/fixits-pr84852-2.c: Likewise. * gcc.dg/missing-header-fixit-3.c: Likewise. * gcc.dg/missing-header-fixit-4.c: New test. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Update for conversion of show_caret_p to a tri-state. libcpp/ChangeLog: PR 87091 * include/line-map.h (enum range_display_kind): New enum. (struct location_range): Replace field "m_show_caret_p" with "m_range_display_kind", converting from bool to the new enum. (class rich_location): Add example of line insertion fix-it hint. (rich_location::add_range): Convert param "show_caret_p" from bool to enum range_display_kind and rename to "range_display_kind", giving it a default of SHOW_RANGE_WITHOUT_CARET. (rich_location::set_range): Likewise, albeit without a default. * line-map.c (rich_location::rich_location): Update for conversion of show_caret_p to tri-state enum. (rich_location::add_range): Likewise. (rich_location::set_range): Likewise. From-SVN: r263885
2018-08-24Set start_location to 0 if we ran out of line map spaceH.J. Lu2-0/+15
With profiledbootstrap and --with-build-config=bootstrap-lto, linemap_add may create a macro map when we run out of line map space. This patch changes start_location to UNKNOWN_LOCATION (0) in this case. Tested with profiledbootstrap and --with-build-config=bootstrap-lto on Linux/x86-64. PR bootstrap/86872 * line-map.c (pure_location_p): Return true if linemap_lookup returns NULL. (linemap_add): Set start_location to 0 if we run out of line map space. From-SVN: r263845
2018-08-20[CPP PATCH] node field bitsNathan Sidwell2-3/+8
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01171.html * include/cpplib.h: Fixup some whitespace. (cpp_hashnode): Reduce type to 2 bit & flags to 8. From-SVN: r263669
2018-08-20[CPP PATCH] node typeNathan Sidwell7-152/+139
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01164.html * include/cpplib.h (NODE_BUILTIN, NODE_MACRO_ARG): Delete. Renumber others. (enum node_type): Replace NT_MACRO with NT_USER_MACRO, NT_BUILTIN_MACRO, NT_MACRO_ARG. Delete NT_ASSERTION. (NTV_MACRO, NTV_ANSWER, NTV_BUILTIN, NTV_ARGUMENT, NTV_NONE): Delete. (CPP_HASHNODE_VALUE_IDX): Delete. (union _cpp_hashnode_value): GTY tag from enum node_type directly. (struct cpp_hashnode): Adjust GTY desc for value field. (cpp_user_macro_p, cpp_builtin_macro_p, cpp_macro_p): Adjust. * directives.c (undefine_macros): Clear value.anwers, adjust flag clearing. (_cpp_test_assertion): No need to check NT_ASSERTION. (do_assert, do_unassert): Likewise. * init.c (cpp_init_special_builtins): Set type not flags. * macro.c (struct macro_arg_saved_data): Add type field. (cpp_get_token_1): Check type not NT_VOID. (_cpp_free_definition): Adjust flag clearing. Nullify value.answers. (_cpp_save_parameter, _cpp_unsave_parameters): Save and restore type. (lex_expansion_token): Check type not flags. (_cpp_create_definition): Set type to NT_USER_MACRO. (_cpp_notify_macro_use): Adjust type checking. * pch.c (write_macdef, count_defs, write_defs, cpp_valid_state) (save_macros): Adjust node type/flag handling. * traditional.c (_cpp_scan_out_logical_line): Check type not flags. From-SVN: r263667
2018-08-20[CPP PATCH] Fix warning & other cleanups.Nathan Sidwell4-14/+14
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01162.html * directives.c (do_undef): Use cpp_macro_p & cpp_builtin_macro_p. * include/cpplib.h (enum cpp_macro_kind): Remove trailing comma. (cpp_fun_like_macro_p): Make inline, define. * macro.c (cpp_define_lazily): Use UCHAR_MAX. (cpp_fun_like_macro_p): Delete. From-SVN: r263666
2018-08-20[PATCH] Kill cpp-id-data.hNathan Sidwell4-23/+7
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01149.html libcpp/ * Makefile.in (TAGS_SOURCES): Remove cpp-id-data.h. * include/cpp-id-data.h: Delete. * internal.h: Include cpplib.h not cpp-id-data.h. gcc/ * Makefile.in (CPP_ID_DATA_H): Delete. (CPP_INTERNAL_H): Don't add it. (GTFILES): Replace CPP_ID_DATA_H with CPPLIB_H. * gengtype.c (open_base_files): Replace cpp-id-data.h with cpplib.h From-SVN: r263663
2018-08-20[PATCH] #assert becomes macro-likeNathan Sidwell6-121/+120
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01140.html libcpp/ * include/cpp-id-data.h (struct answer): Delete. * include/cpplib.h (struct answer): Don't forward-declare. (enum cpp_macro_kind): Add cmk_assert. (struct cpp_macro): Union parms and next assert chain. (union _cpp_hashnode_value): 'answer' field is cpp_macro. * directives.c (parse_answer): Convert to use cpp_macro. Return true on success. (parse_assertion, find_answer, _cpp_test_assertion, cpp_do_assert) (cpp_do_unassert): Convert to use cpp_macro. * macro.c (warn_of_redefinition, _cpp_new_macro) (check_trad_stringification, cpp_macro_definition): Adjust macro parm access. * traditional.c (_cpp_replacement_text_len) (_cpp_copy_replacement_text, _cpp_create_trad_definition): Likewise. gcc/c-family/ * c-ada-spec.c (macro_length, dump_ada_macros): Adjust macro parm access. From-SVN: r263658
2018-08-17[PATCH] Adjust lazy macro definitionNathan Sidwell4-51/+60
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01072.html libcpp/ * include/cpplib.h (struct cpp_callbacks): Replace user_builtin_macro with user_lazy_macro. (struct cpp_macro): add lazy field. (enum cpp_builtin_type): Remove BT_FIRST_USER, BT_LAST_USER. (cpp_define_lazily): Declare. * macro.c (enter_macro_context) Use _cpp_maybe_notify_macro_use. (warn_of_redefinition): Use cpp_builtin_macro_p, directly call user_lazy_macro hook. (_cpp_new_macro): Clear lazy field. (cpp_define_lazily): Define. (_cpp_notify_macro_use): Adjust lazy definition code. (cpp_macro_definition): No need to do lazy definition here. * pch.c (write_macdef, save_macros): Likewise. gcc/c-family/ * c-cppbuiltin.c (struct lazy_hex_fp_value_struct): Remove macro field. (laxy_hex_fp_value_count): Make unsigned. (lazy_hex_fp_value): Provided with macro & lazy number. Directly manipulate the macro. (builtin_defin_with_hex_fp_value): Adjust callback name, use cpp_define_lazily. From-SVN: r263640
2018-08-17[PATCH] Macro body is trailing arrayNathan Sidwell6-161/+221
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01037.html * include/cpplib.h (enum cpp_macro_kind): New. (struct cpp_macro): Make body trailing array. Add kind field, delete traditional flag. * internal.h (_cpp_new_macro): Declare. (_cpp_reserve_room): New inline. (_cpp_commit_buf): Declare. (_cpp_create_trad_definition): Return new macro. * lex.c (_cpp_commit_buff): New. * macro.c (macro_real_token_count): Count backwards. (replace_args): Pointer equality not orderedness. (_cpp_save_parameter): Use _cpp_reserve_room. (alloc_expansion_token): Delete. (lex_expansion_token): Return macro pointer. Use _cpp_reserve_room. (create_iso_definition): Allocate macro itself. Adjust for different allocation ordering. (_cpp_new_macro): New. (_cpp_create_definition): Adjust for API changes. * traditional.c (push_replacement_text): Don't set traditional flag. (save_replacement_text): Likewise. (_cpp_create_trad_definition): Allocate macro itself, Adjust for different allocation ordering. From-SVN: r263622
2018-08-17[PATCH] Move cpp_macro to cpplib.hNathan Sidwell4-56/+64
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01016.html libcpp/ * cpp-id-data.h (uchar, UC): Move to internal.h (struct cpp_macro): Move to cpplib.h. * internal.h (uchar, UC): From cpp-id-data.h. * include/cpplib.h (struct cpp_macro): From cpp-id-data.h. gcc/c-family/ * c-ada-spec.c: Don't #include "cpp-id-data.h" * c-cppbuiltin.c: Likewise. gcc/ * cppbuiltin.c: Include "cpplib.h", not "cpp-id-data.h". From-SVN: r263618
2018-08-16[PATCH] Macro definition parameter parsingNathan Sidwell4-139/+177
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg00977.html libcpp/ * internal.h (_cpp_save_parameter): Take parmno, not macro. (_cpp_unsave_parameters): Declare. * macro.c (_cpp_save_parameter): Take parm number, not macro. Return true on success. (_cpp_unsave_parameters): New. (parse_params): Take parm_no and variadic pointers, not macro. Reimplement parsing logic. (create_iso_definition): Adjust parse_params changes. Call _cpp_unsave_parameters here. (_cpp_create_definition): Don't unsave params here. * traditional.c (scan_parameters): Take n_param pointer, adjust. (_cpp_create_trad_definition): Ajust scan_parameters change. Call _cpp_unsave_parameters. gcc/testsuite/ * gcc.dg/cpp/macsyntx.c: Adjust expected errors. * gcc.dg/cpp/macsyntx2.c: likewise. From-SVN: r263600
2018-08-16[PATCH] CPP Macro predicatesNathan Sidwell10-90/+107
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg00897.html libcpp/ * include/cpplib.h (cpp_user_macro_p, cpp_builtin_macro_p) (cpp_macro_p): New inlines. * directives.c (do_pragma_poison): Use cpp_macro_p. (do_ifdef, do_ifndef): Likewise. Use _cpp_maybe_notify_macro_use. (cpp_pop_definition): Use cpp_macro_p. Move _cpp_free_definition earlier. Don't zap node directly. * expr.c (parse_defined): Use _cpp_maybe_notify_macro_use & cpp_macro_p. * files.c (should_stack_file): Use cpp_macro_p. * identifiers.c (cpp_defined): Likewise. * internal.h (_cpp_mark_macro): Use cpp_user_macro_p. (_cpp_notify_macro_use): Declare. (_cpp_maybe_notify_macro_use): New inline. * lex.c (is_macro): Use cpp_macro_p. * macro.c (_cpp_warn_if_unused_macro): Use cpp_user_macro_p. (enter_macro_context): Likewise. (_cpp_create_definition): Use cpp_builtin_macro_p, cpp_user_macro_p. Move _cpp_free_definition earlier. (_cpp_notify_macro_use): New, broken out of multiple call sites. * traditional.c (fun_like_macro_p): Use cpp_builtin_macro_p. (maybe_start_funlike, _cpp_scan_out_logical_line) (push_replacement_text): Likewise. gcc/c-family/ * c-ada-spec.c (count_ada_macro): Use cpp_user_macro_p. (store_ada_macro): Likewise. * c-ppoutput.c (cb_used_define, dump_macro): Likewise. * c-spellcheck.cc (should-suggest_as_macro_p): Likewise, gcc/ * config/rs6000/rs6000-c.c (rs6000_macro_to_expend): Use cpp_macro_p. * config/powerpcspc/powerpcspe-c.c (rs6000_macro_to_expend): Likewise. gcc/cp/ * name-lookup.c (lookup_name_fuzzy): Likewise. gcc/fortran/ * cpp.c (dump_macro): Use cpp_user_macro_p. From-SVN: r263587
2018-08-15diagnostics: add labeling of source rangesDavid Malcolm3-11/+90
This patch adds the ability to label source ranges within a rich_location, to be printed by diagnostic_show_locus. For example: pr69554-1.c:11:18: error: invalid operands to binary + (have 'const char *' and 'const char *') 11 | return (p + 1) + (q + 1); | ~~~~~~~ ^ ~~~~~~~ | | | | | const char * | const char * The patch implements labels for various type mismatch errors in the C and C++ frontends, and in -Wformat. I implemented it wherever accurate location information was guaranteed (there are other places that could benefit, but we need better location information in those places). The labels can be disabled via -fno-diagnostics-show-labels. Similarly: param-type-mismatch.C: In function 'int test_1(int, int, float)': param-type-mismatch.C:11:27: error: invalid conversion from 'int' to 'const char*' [-fpermissive] 11 | return callee_1 (first, second, third); | ^~~~~~ | | | int param-type-mismatch.C:7:43: note: initializing argument 2 of 'int callee_1(int, const char*, float)' 7 | extern int callee_1 (int one, const char *two, float three); | ~~~~~~~~~~~~^~~ where the first "error" describing the bad argument gets a label describing the type inline (since it's non-obvious from "second"). The "note" describing the type of the param of the callee *doesn't* get a label, since that information is explicit there in the source ("const char *two"). The idea is that in any diagnostic where two aspects of the source aren't in sync it ought to be easier for the user if we directly show them the mismatching aspects inline (e.g. types). As well as type mismatch errors, perhaps labels could also be used for buffer overflow warnings, for describing the capacity of the destination buffer vs the size of what's being written: sprintf (buf, "filename: %s\n", file); ^~~ ~~~~~~~~~~~^~~ | | capacity: 32 10 + strlen(file) + 2 or somesuch. Another idea might be for macro expansion warnings: warning: repeated side effects in macro expansion... x = MIN (p++, q++); ~~~~^~~~~~~~~~ note: ...expanded here as #define MIN(X,Y) (X<Y?X:Y) ^~~ ~ ~ ~ ~ ~ ~ | | | | | | | | | | | q++ | | | | p++ | | | q++ | q++ p++ p++ The patch removes some logic from multiline.exp which special-cased lines ending with a '|' character (thus complicating testing of this patch). I believe that this was a vestige from experiments I did to support strippng dg directives from the output; it was present in the earliest version of multiline.exp I posted: "[RFC, stage1] Richer source location information for gcc 6 (location ranges etc)" https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00837.html and I believe was neved used. gcc/c-family/ChangeLog: * c-format.c: Include "selftest-diagnostic.h" and "gcc-rich-location.h". (format_warning_at_char): Pass NULL for new label params of format_warning_va. (class indirection_suffix): New class. (class range_label_for_format_type_mismatch): New class. (format_type_warning): Move logic for generating "*" suffix to class indirection_suffix. Create "fmt_label" and "param_label" to show their types, and pass them to the format_warning_at_substring calls. (selftest::test_type_mismatch_range_labels): New test. (selftest::c_format_c_tests): Call it. gcc/c/ChangeLog: * c-objc-common.c: Include "gcc-rich-location.h". (c_tree_printer): Move implemenation of '%T' to... (print_type): ...this new function. (range_label_for_type_mismatch::get_text): New function. * c-typeck.c (convert_for_assignment): Add type labels to the rhs range for the various ic_argpass cases. (class maybe_range_label_for_tree_type_mismatch): New class. (build_binary_op): Use it when calling binary_op_error. gcc/cp/ChangeLog: * call.c: Include "gcc-rich-location.h". (convert_like_real): Add range label for "invalid conversion" diagnostic. (perform_implicit_conversion_flags): Add type label to the "could not convert" error. * error.c: Include "gcc-rich-location.h". (range_label_for_type_mismatch::get_text): New function. * typeck.c (convert_for_assignment): Add type label to the "cannot convert" error if a location is available. gcc/ChangeLog: * common.opt (fdiagnostics-show-labels): New option. * diagnostic-show-locus.c (class layout_range): Add field "m_label". (class layout): Add field "m_show_labels_p". (layout_range::layout_range): Add param "label" and use it to initialize m_label. (make_range): Pass in NULL for new "label" param of layout_range's ctor. (layout::layout): Initialize m_show_labels_p. (layout::maybe_add_location_range): Pass in loc_range->m_label when constructing layout_range instances. (struct line_label): New struct. (layout::print_any_labels): New member function. (layout::print_line): Call it if label-printing is enabled. (selftest::test_one_liner_labels): New test. (selftest::test_diagnostic_show_locus_one_liner): Call it. * diagnostic.c (diagnostic_initialize): Initialize context->show_labels_p. * diagnostic.h (struct diagnostic_context): Add field "show_labels_p". * doc/invoke.texi (Diagnostic Message Formatting Options): Add -fno-diagnostics-show-labels. * dwarf2out.c (gen_producer_string): Add OPT_fdiagnostics_show_labels to the ignored options. * gcc-rich-location.c (gcc_rich_location::add_expr): Add "label" param. (gcc_rich_location::maybe_add_expr): Likewise. * gcc-rich-location.h (gcc_rich_location::gcc_rich_location): Add label" param, defaulting to NULL. (gcc_rich_location::add_expr): Add "label" param. (gcc_rich_location::maybe_add_expr): Likewise. (class text_range_label): New class. (class range_label_for_type_mismatch): New class. * gimple-ssa-sprintf.c (fmtwarn): Pass NULL for new label params of format_warning_va. (fmtwarn_n): Likewise for new params of format_warning_n_va. * lto-wrapper.c (merge_and_complain): Add OPT_fdiagnostics_show_labels to the "pick one setting" options. (append_compiler_options): Likewise to the dropped options. (append_diag_options): Likewise to the passed-on options. * opts.c (common_handle_option): Handle the new option. * selftest-diagnostic.c (test_diagnostic_context::test_diagnostic_context): Enable show_labels_p. * substring-locations.c: Include "gcc-rich-location.h". (format_warning_n_va): Add "fmt_label" and "param_label" params and use them as appropriate. (format_warning_va): Add "fmt_label" and "param_label" params, passing them on to format_warning_n_va. (format_warning_at_substring): Likewise. (format_warning_at_substring_n): Likewise. * substring-locations.h (format_warning_va): Add "fmt_label" and "param_label" params. (format_warning_n_va): Likewise. (format_warning_at_substring): Likewise. (format_warning_at_substring_n): Likewise. * toplev.c (general_init): Initialize global_dc->show_labels_p. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/aka3.C: New test. * g++.dg/diagnostic/param-type-mismatch-2.C: Update expected output to show range labels. * g++.dg/diagnostic/param-type-mismatch.C: Likewise. * g++.dg/plugin/plugin.exp (plugin_test_list): Add... * g++.dg/plugin/show-template-tree-color-labels.C: New test. * gcc.dg/bad-binary-ops.c: Update expected output to show range labels. Add an "aka" example. * gcc.dg/cpp/pr66415-1.c: Update expected output to show range labels. * gcc.dg/format/diagnostic-ranges.c: Likewise. * gcc.dg/format/pr72858.c: Likewise. * gcc.dg/format/pr78498.c: Likewise. * gcc.dg/param-type-mismatch.c: Add "-Wpointer-sign" to options. Update expected output to show range labels. Add examples of -Wincompatible-pointer-types and -Wpointer-sign for parameters. * gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c: Update expected output to show range labels. * gcc.dg/plugin/diagnostic-test-show-locus-bw.c: Likewise. (test_very_wide_line): Adjust so that label is at left-clipping boundary. (test_very_wide_line_2): New test. * gcc.dg/plugin/diagnostic-test-show-locus-color-line-numbers.c: Update expected output to show range labels. * gcc.dg/plugin/diagnostic-test-show-locus-color.c: Likewise. * gcc.dg/plugin/diagnostic-test-show-locus-no-labels.c: New test. * gcc.dg/plugin/diagnostic_plugin_show_trees.c (show_tree): Update for new param to gcc_rich_location::add_expr. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (add_range): Add "label" param. (test_show_locus): Add examples of labels to various tests. Tweak the "very wide_line" test case and duplicate it, to cover the boundary values for clipping of labels against the left-margin. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add diagnostic-test-show-locus-no-labels.c. * gcc.dg/pr69554-1.c: Update expected output to show range labels. Update line numbers of dg-locus directives. * gcc.dg/pr69627.c: Update expected output to show range labels. * lib/multiline.exp (proc _build_multiline_regex): Remove special-case handling of lines with trailing '|'. libcpp/ChangeLog: * include/line-map.h (struct location_range): Add "m_label" field. (class rich_location): Add description of labels to leading comment. (rich_location::rich_location): Add "label" param, defaulting to NULL. (rich_location::add_range): Likewise. (struct label_text): New struct. (class range_label): New abstract base class. * line-map.c (rich_location::rich_location): Add "label" param; use it. (rich_location::add_range): Likewise. From-SVN: r263564
2018-08-08[PATCH] line-map include-from representationNathan Sidwell4-74/+64
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg00554.html Make linemap::included_from a location libcpp/ * include/line-map.h (struct line_map_ordinary): Replace included_from map index with included_at source_location. (ORDINARY_MAP_INCLUDER_FILE_INDEX): Delete. (LAST_SOURCE_LINE_LOCATION): Delete. (LAST_SOURCE_LINE, LAST_SOURCE_COLUMN): Delete. (linemap_included_from): New. (linemap_included_from_linemap): Declare. (MAIN_FILE_P): Adjust. * line-map.c (linemap_included_from_linemap): New. (lonemap_check_files_exited): Use linemap_included_at. (linemap_add): Adjust inclusion setting. (linemap_dump, linemap_dump_location): Adjust. * directives.c (do_linemarker): Use linemap_included_at. gcc/ * diagnostic.c (diagnostic_report_current_module): Use linemap_included_from & linemap_included_from_linemap. gcc/c-family/ * c-common.c (try_to_locate_new_include_inertion_point): Use linemap_included_from_linemap. * c-lex.c (fe_file_change): Use linemap_included_from. * c-ppoutput.c (pp_file_change): Likewise. gcc/fortran/ * cpp.c (cb_file_change): Use linemap_included_from. gcc/testsuite/ * c-c++-common/inc-from-1a.h, c-c++-common/inc-from-1b.h, c-c++-common/inc-from-1.c: New From-SVN: r263429
2018-08-07[PATCH] Line map table allocationNathan Sidwell2-60/+45
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg00434.html * line-map.c: (linemap_init): Set default allocator here. (new_linemap): Rather than here. Refactor allocation logic. From-SVN: r263366
2018-07-25Regenerate .pot files.Joseph Myers2-26/+30
gcc/po: * gcc.pot: Regenerate. libcpp/po: * cpplib.pot: Regenerate. From-SVN: r262972
2018-07-20libcpp: remove redundant parameter from rich_location::set_rangeDavid Malcolm3-4/+9
gcc/c-family/ChangeLog: * c-common.c (c_cpp_error): Remove redundant "line_table" parameter from call to rich_location::set_range. (maybe_suggest_missing_token_insertion): Likewise. gcc/ChangeLog: * pretty-print.c (text_info::set_location): Remove redundant "line_table" parameter from call to rich_location::set_range. libcpp/ChangeLog: * include/line-map.h (rich_location::set_range): Remove redundant line_maps * parameter. * line-map.c (rich_location::set_range): Likewise. From-SVN: r262913
2018-07-18re PR c/69558 (glib2 warning pragmas stopped working)Bernd Edlinger2-18/+21
libcpp: 2018-07-18 Bernd Edlinger <bernd.edlinger@hotmail.de> PR 69558 * macro.c (enter_macro_context): Change the location info for builtin macros and _Pragma from location of the closing parenthesis to location of the macro expansion point. testsuite: 2018-07-18 Bernd Edlinger <bernd.edlinger@hotmail.de> PR 69558 * c-c++-common/cpp/diagnostic-pragma-2.c: New test. * c-c++-common/pr69558.c: Remove xfail. * gcc.dg/cpp/builtin-macro-1.c: Adjust test expectations. * gcc.dg/pr61817-1.c: Likewise. * gcc.dg/pr61817-2.c: Likewise. * g++.dg/plugin/pragma_plugin.c: Warn at expansion_point_location. From-SVN: r262861
2018-07-17lex.c (_cpp_lex_direct): Use CPP_DL_NOTE instead of CPP_DL_PEDWARN...Jakub Jelinek2-13/+22
* lex.c (_cpp_lex_direct): Use CPP_DL_NOTE instead of CPP_DL_PEDWARN, CPP_DL_WARNING or CPP_DL_ERROR for note that diagnostics for C++ style comments is reported only once per file and guard those calls on the preceding cpp_error returning true. * gcc.dg/cpp/pr61854-c90.c (foo): Expect a note, rather than error. * gcc.dg/cpp/pr61854-c94.c (foo): Likewise. * gcc.dg/cpp/pr61854-4.c (foo): Likewise. * gcc.dg/cpp/pr61854-8.c: New test. From-SVN: r262832
2018-07-03Reorg line_map data structures for better packing.Nathan Sidwell3-84/+123
* include/line-map.h (enum lc_reason): Add LC_HWM. (LINE_MAP_MAX_LOCATION): Define here. (struct line_map): Move reason field to line_map_ordinary. Adjust GTY tagging. (struct line_map_ordinary): Reorder fields for less padding. (struct line_map_macro): Likewise. (MAP_ORDINARY_P): New. (linemap_check_ordinary, linemap_check_macro): Adjust. * line-map.c (LINE_MAP_MAX_SOURCE_LOCATION): Delete. (new_linemap): Take start_location, not reason. Adjust. (linemap_add, linemap_enter_macro): Adjust. (linemap_line_start): Likewise. (linemap_macro_expansion_map_p): Use MAP_ORDINARY_P. (linemap_macro_loc_to_spelling_point): Likewise. (linemap_macro_loc_to_def_point): Likewise. (linemap_dump): Likewise. From-SVN: r262348
2018-06-11* fr.po: Update.Joseph Myers2-135/+121
From-SVN: r261439
2018-06-07* eo.po: Update.Joseph Myers2-19/+17
From-SVN: r261280
2018-05-23* system.h: #include <new> earlier.Jason Merrill2-4/+8
From-SVN: r260620
2018-05-17line-map.c (linemap_init): Use placement new.Jason Merrill3-1/+10
* line-map.c (linemap_init): Use placement new. * system.h: #include <new>. From-SVN: r260343
2018-04-23Regenerate .pot files.Joseph Myers2-61/+65
gcc/po: * gcc.pot: Regenerate. libcpp/po: * cpplib.pot: Regenerate. From-SVN: r259575
2018-03-27* es.po: Update.Joseph Myers2-109/+78
From-SVN: r258906
2018-03-14Fix ICE for missing header fix-it hints with overlarge #line directives (PR ↵David Malcolm2-0/+16
c/84852) PR c/84852 reports an ICE inside diagnostic_show_locus when printing a diagnostic for a source file with a #line >= 2^31: #line 7777777777 int foo (void) { return strlen(""); } where we're attempting to print a fix-it hint at the top of the file and underline the "strlen" (two "line spans"). The #line 7777777777 won't fix within the 32-bit linenum_type, and is truncated from 0x1cf977871 to 0xcf977871 i.e. 3482810481 in decimal. Such a #line is reported by -pedantic and -pedantic-errors, but we shouldn't ICE. The ICE is an assertion failure within layout::calculate_line_spans, where the line spans have not been properly sorted. The layout_ranges are stored as int, rather than linenum_type, giving line -812156815 for the error, and line 1 for the fix-it hint. However, line_span uses linenum_type rather than int. line_span::comparator compares these values as int, and hence decides that (linenum_type)3482810481 aka (int)-812156815 is less than line 1. This leads to this assertion failing in layout::calculate_line_spans: 1105 gcc_assert (next->m_first_line >= current->m_first_line); since it isn't the case that 1 >= 3482810481. The underlying problem is the mix of types for storing line numbers: in parts of libcpp and diagnostic-show-locus.c we use linenum_type; in other places (including libcpp's expanded_location) we use int. I looked at using linenum_type throughout, but doing so turned into a large patch, so this patch fixes the ICE in a less invasive way by merely using linenum_type more consistently just within diagnostic-show-locus.c, and fixing line_span::comparator to properly handle line numbers (and line number differences) >= 2^31, by using a new helper function for linenum_type differences, computing the difference using long long, and using the sign of the difference (as the difference might not fit in the "int" return type imposed by qsort). gcc/ChangeLog: PR c/84852 * diagnostic-show-locus.c (class layout_point): Convert m_line from int to linenum_type. (line_span::comparator): Use linenum "compare" function when comparing line numbers. (test_line_span): New function. (layout_range::contains_point): Convert param "row" from int to linenum_type. (layout_range::intersects_line_p): Likewise. (layout::will_show_line_p): Likewise. (layout::print_source_line): Likewise. (layout::should_print_annotation_line_p): Likewise. (layout::print_annotation_line): Likewise. (layout::print_leading_fixits): Likewise. (layout::annotation_line_showed_range_p): Likewise. (struct line_corrections): Likewise for field m_row. (line_corrections::line_corrections): Likewise for param "row". (layout::print_trailing_fixits): Likewise. (layout::get_state_at_point): Likewise. (layout::get_x_bound_for_row): Likewise. (layout::print_line): Likewise. (diagnostic_show_locus): Likewise for locals "last_line" and "row". (selftest::diagnostic_show_locus_c_tests): Call test_line_span. * input.c (selftest::test_linenum_comparisons): New function. (selftest::input_c_tests): Call it. * selftest.c (selftest::test_assertions): Test ASSERT_GT, ASSERT_GT_AT, ASSERT_LT, and ASSERT_LT_AT. * selftest.h (ASSERT_GT): New macro. (ASSERT_GT_AT): New macro. (ASSERT_LT): New macro. (ASSERT_LT_AT): New macro. gcc/testsuite/ChangeLog: PR c/84852 * gcc.dg/fixits-pr84852-1.c: New test. * gcc.dg/fixits-pr84852-2.c: New test. libcpp/ChangeLog: * include/line-map.h (compare): New function on linenum_type. From-SVN: r258526
2018-03-03* da.po: Update.Joseph Myers2-14/+12
From-SVN: r258221
2018-02-28PR preprocessor/84517 allow double-underscore macros after string literalsJonathan Wakely2-8/+26
gcc/testsuite: PR preprocessor/84517 * g++.dg/cpp0x/udlit-macros.C: Expect a warning for ""__FILE__. libcpp: PR preprocessor/84517 * lex.c (is_macro_not_literal_suffix): New function. (lex_raw_string, lex_string): Use is_macro_not_literal_suffix to decide when to issue -Wliteral-suffix warnings. From-SVN: r258069
2018-02-16re PR bootstrap/82939 (genmatch fills up terminal with endless printing of ↵Richard Biener2-0/+11
periods) 2018-02-16 Richard Biener <rguenther@suse.de> PR bootstrap/82939 * line-map.c (linemap_init): Avoid broken value-init when compiling with GCC 4.2. From-SVN: r257732
2018-02-15PR preprocessor/83063 - __VA_OPT__ and ##Jason Merrill2-23/+126
PR preprocessor/83708 * macro.c (vaopt_state): Reorder m_last_was_paste before m_state. (vaopt_state::vaopt_state): Adjust. (vaopt_state::update_flags): Add BEGIN and END. (vaopt_state::update): Return them. (copy_paste_flag): Factor out of replace_args. (last_token_is): New. (replace_args): Handle BEGIN and END. Avoid padding there. (tokens_buff_last_token_ptr): Return NULL if no tokens. Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r257696
2018-02-15* libcpp/macro.c: Fix typos.Jason Merrill1-9/+9
From-SVN: r257682