Skip to content
Snippets Groups Projects
  1. Feb 19, 2024
    • Joseph Myers's avatar
      Update cpplib es.po · 238f93ae
      Joseph Myers authored
      	* es.po: Update.
      238f93ae
    • Joseph Myers's avatar
      Update .po files · 558f392c
      Joseph Myers authored
      gcc/po/
      	* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
      	ja.po, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po,
      	zh_TW.po: Update.
      
      libcpp/po/
      	* be.po, ca.po, da.po, de.po, el.po, eo.po, es.po, fi.po, fr.po,
      	id.po, ja.po, ka.po, nl.po, pt_BR.po, ro.po, ru.po, sr.po, sv.po,
      	tr.po, uk.po, vi.po, zh_CN.po, zh_TW.po: Update.
      558f392c
  2. Feb 17, 2024
  3. Feb 16, 2024
  4. Feb 02, 2024
  5. Feb 01, 2024
    • Lewis Hyatt's avatar
      libcpp: Stabilize the location for macros restored after PCH load [PR105608] · 019dc638
      Lewis Hyatt authored
      libcpp currently lacks the infrastructure to assign correct locations to
      macros that were defined prior to loading a PCH and then restored
      afterwards. While I plan to address that fully for GCC 15, this patch
      improves things by using at least a valid location, even if it's not the
      best one. Without this change, libcpp uses pfile->directive_line as the
      location for the restored macros, but this location_t applies to the old
      line map, not the one that was just restored from the PCH, so the resulting
      location is unpredictable and depends on what was stored in the line maps
      before. With this change, all restored macros get assigned locations at the
      line of the #include that triggered the PCH restore. A future patch will
      store the actual file name and line number of each definition and then
      synthesize locations in the new line map pointing to the right place.
      
      gcc/c-family/ChangeLog:
      
      	PR preprocessor/105608
      	* c-pch.cc (c_common_read_pch): Adjust line map so that libcpp
      	assigns a location to restored macros which is the same location
      	that triggered the PCH include.
      
      libcpp/ChangeLog:
      
      	PR preprocessor/105608
      	* pch.cc (cpp_read_state): Set a valid location for restored
      	macros.
      019dc638
  6. Jan 05, 2024
  7. Jan 04, 2024
    • Raiki Tamura's avatar
      libcpp: add function to check XID properties · 00dea7e8
      Raiki Tamura authored
      
      This commit adds a new function intended for checking the XID properties
      of a possibly unicode character, as well as the accompanying enum
      describing the possible properties.
      
      libcpp/ChangeLog:
      
      	* charset.cc (cpp_check_xid_property): New.
      	* include/cpplib.h
      	(cpp_check_xid_property): New.
      	(enum cpp_xid_property): New.
      
      Signed-off-by: default avatarRaiki Tamura <tamaron1203@gmail.com>
      00dea7e8
  8. Jan 03, 2024
  9. Dec 14, 2023
  10. Dec 13, 2023
    • Jakub Jelinek's avatar
      libcpp: Fix valgrind errors on pr88974.c [PR112956] · 819bc4f6
      Jakub Jelinek authored
      On the c-c++-common/cpp/pr88974.c testcase I'm seeing
      ==600549== Conditional jump or move depends on uninitialised value(s)
      ==600549==    at 0x1DD3A05: cpp_get_token_1(cpp_reader*, unsigned int*) (macro.cc:3050)
      ==600549==    by 0x1DBFC7F: _cpp_parse_expr (expr.cc:1392)
      ==600549==    by 0x1DB9471: do_if(cpp_reader*) (directives.cc:2087)
      ==600549==    by 0x1DBB4D8: _cpp_handle_directive (directives.cc:572)
      ==600549==    by 0x1DCD488: _cpp_lex_token (lex.cc:3682)
      ==600549==    by 0x1DD3A97: cpp_get_token_1(cpp_reader*, unsigned int*) (macro.cc:2936)
      ==600549==    by 0x7F7EE4: scan_translation_unit (c-ppoutput.cc:350)
      ==600549==    by 0x7F7EE4: preprocess_file(cpp_reader*) (c-ppoutput.cc:106)
      ==600549==    by 0x7F6235: c_common_init() (c-opts.cc:1280)
      ==600549==    by 0x704C8B: lang_dependent_init (toplev.cc:1837)
      ==600549==    by 0x704C8B: do_compile (toplev.cc:2135)
      ==600549==    by 0x704C8B: toplev::main(int, char**) (toplev.cc:2306)
      ==600549==    by 0x7064BA: main (main.cc:39)
      error.  The problem is that _cpp_lex_direct can leave result->src_loc
      uninitialized in some cases and later on we use that location_t.
      
      _cpp_lex_direct essentially does:
        cppchar_t c;
      ...
        cpp_token *result = pfile->cur_token++;
      
       fresh_line:
        result->flags = 0;
      ...
        if (buffer->need_line)
          {
            if (pfile->state.in_deferred_pragma)
              {
                result->type = CPP_PRAGMA_EOL;
                ... // keeps result->src_loc uninitialized;
                return result;
              }
            if (!_cpp_get_fresh_line (pfile))
              {
                result->type = CPP_EOF;
                if (!pfile->state.in_directive && !pfile->state.parsing_args)
                  {
                    result->src_loc = pfile->line_table->highest_line;
                    ...
                  }
                ... // otherwise result->src_loc is sometimes uninitialized here
                return result;
              }
            ...
          }
      ...
        result->src_loc = pfile->line_table->highest_line;
      ...
        c = *buffer->cur++;
        switch (c)
          {
      ...
          case '\n':
      ...
            buffer->need_line = true;
            if (pfile->state.in_deferred_pragma)
              {
                result->type = CPP_PRAGMA_EOL;
      ...
                return result;
              }
            goto fresh_line;
      ...
          }
      ...
      So, if _cpp_lex_direct is called without buffer->need_line initially set,
      result->src_loc is always initialized (and actually hundreds of tests rely
      on that exact value it has), even when c == '\n' and we set that flag later
      on and goto fresh_line.  For CPP_PRAGMA_EOL case we have in that case
      separate handling and don't goto.
      But if _cpp_lex_direct is called with buffer->need_line initially set and
      either decide to return a CPP_PRAGMA_EOL token or if getting a new line fails
      for some reason and we return an CPP_ERROR token and we are in directive
      or parsing args state, it is kept uninitialized and can be whatever the
      allocation left it there as.
      
      The following patch attempts to keep the status quo, use value that was
      returned previously if it was initialized (i.e. we went through the
      goto fresh_line; statement in c == '\n' handling) and only initialize
      result->src_loc if it was uninitialized before.
      
      2023-12-13  Jakub Jelinek  <jakub@redhat.com>
      
      	PR preprocessor/112956
      	* lex.cc (_cpp_lex_direct): Initialize c to 0.
      	For CPP_PRAGMA_EOL tokens and if c == 0 also for CPP_EOF
      	set result->src_loc to highest locus.
      819bc4f6
  11. Nov 29, 2023
  12. Nov 28, 2023
    • Lewis Hyatt's avatar
      libcpp: Fix unsigned promotion for unevaluated divide by zero [PR112701] · ce52f1f7
      Lewis Hyatt authored
      When libcpp encounters a divide by zero while processing a constant
      expression "x/y", it returns "x" as a fallback. The value of the fallback is
      not normally important, since an error will be generated anyway, but if the
      expression appears in an unevaluated context, such as "0 ? 0/0u : -1", then
      there will be no error, and the fallback value will be meaningful to the
      extent that it may cause promotion from signed to unsigned of an operand
      encountered later. As the PR notes, libcpp does not do the unsigned
      promotion correctly in this case; fix it by making the fallback return value
      unsigned as necessary.
      
      libcpp/ChangeLog:
      
      	PR preprocessor/112701
      	* expr.cc (num_div_op): Set unsignedp appropriately when returning a
      	stub value for divide by 0.
      
      gcc/testsuite/ChangeLog:
      
      	PR preprocessor/112701
      	* gcc.dg/cpp/expr.c: Add additional tests to cover divide by 0 in an
      	unevaluated context, where the unsignedness still matters.
      ce52f1f7
    • GCC Administrator's avatar
      Daily bump. · ad3e759c
      GCC Administrator authored
      ad3e759c
  13. Nov 27, 2023
    • Alex Coplan's avatar
      c-family: Implement __has_feature and __has_extension [PR60512] · 06280a90
      Alex Coplan authored
      This patch implements clang's __has_feature and __has_extension in GCC.
      Currently the patch aims to implement all documented features (and some
      undocumented ones) following the documentation at
      https://clang.llvm.org/docs/LanguageExtensions.html
      
       with the exception
      of the legacy features for C++ type traits.  These are omitted, since as
      the clang documentation notes, __has_builtin is the correct "modern" way
      to query for these (which GCC already implements).
      
      gcc/c-family/ChangeLog:
      
      	PR c++/60512
      	* c-common.cc (struct hf_feature_info): New.
      	(c_common_register_feature): New.
      	(init_has_feature): New.
      	(has_feature_p): New.
      	* c-common.h (c_common_has_feature): New.
      	(c_family_register_lang_features): New.
      	(c_common_register_feature): New.
      	(has_feature_p): New.
      	* c-lex.cc (init_c_lex): Plumb through has_feature callback.
      	(c_common_has_builtin): Generalize and move common part ...
      	(c_common_lex_availability_macro): ... here.
      	(c_common_has_feature): New.
      	* c-ppoutput.cc (init_pp_output): Plumb through has_feature.
      
      gcc/c/ChangeLog:
      
      	PR c++/60512
      	* c-lang.cc (c_family_register_lang_features): New.
      	* c-objc-common.cc (struct c_feature_info): New.
      	(c_register_features): New.
      	* c-objc-common.h (c_register_features): New.
      
      gcc/cp/ChangeLog:
      
      	PR c++/60512
      	* cp-lang.cc (c_family_register_lang_features): New.
      	* cp-objcp-common.cc (struct cp_feature_selector): New.
      	(cp_feature_selector::has_feature): New.
      	(struct cp_feature_info): New.
      	(cp_register_features): New.
      	* cp-objcp-common.h (cp_register_features): New.
      
      gcc/ChangeLog:
      
      	PR c++/60512
      	* doc/cpp.texi: Document __has_{feature,extension}.
      
      gcc/objc/ChangeLog:
      
      	PR c++/60512
      	* objc-act.cc (struct objc_feature_info): New.
      	(objc_nonfragile_abi_p): New.
      	(objc_common_register_features): New.
      	* objc-act.h (objc_common_register_features): New.
      	* objc-lang.cc (c_family_register_lang_features): New.
      
      gcc/objcp/ChangeLog:
      
      	PR c++/60512
      	* objcp-lang.cc (c_family_register_lang_features): New.
      
      libcpp/ChangeLog:
      
      	PR c++/60512
      	* include/cpplib.h (struct cpp_callbacks): Add has_feature.
      	(enum cpp_builtin_type): Add BT_HAS_{FEATURE,EXTENSION}.
      	* init.cc: Add __has_{feature,extension}.
      	* macro.cc (_cpp_builtin_macro_text): Handle
      	BT_HAS_{FEATURE,EXTENSION}.
      
      gcc/testsuite/ChangeLog:
      
      	PR c++/60512
      	* c-c++-common/has-feature-common.c: New test.
      	* c-c++-common/has-feature-pedantic.c: New test.
      	* g++.dg/ext/has-feature.C: New test.
      	* gcc.dg/asan/has-feature-asan.c: New test.
      	* gcc.dg/has-feature.c: New test.
      	* gcc.dg/ubsan/has-feature-ubsan.c: New test.
      	* obj-c++.dg/has-feature.mm: New test.
      	* objc.dg/has-feature.m: New test.
      
      Co-Authored-By: default avatarIain Sandoe <iain@sandoe.co.uk>
      06280a90
  14. Nov 25, 2023
  15. Nov 24, 2023
    • Alexander Monakov's avatar
      libcpp: configure: drop unused Valgrind detection · ab78426a
      Alexander Monakov authored
      When top-level configure has either --enable-checking=valgrind or
      --enable-valgrind-annotations, we want to activate a couple of workarounds
      in libcpp. They do not use anything from the Valgrind API, so just
      delete all detection.
      
      libcpp/ChangeLog:
      
      	* config.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac (ENABLE_VALGRIND_CHECKING): Delete.
      	(ENABLE_VALGRIND_ANNOTATIONS): Rename to
      	ENABLE_VALGRIND_WORKAROUNDS.  Delete Valgrind header checks.
      	* lex.cc (new_buff): Adjust for renaming.
      	(_cpp_free_buff): Ditto.
      ab78426a
  16. Nov 21, 2023
  17. Nov 20, 2023
    • Marc Poulhiès's avatar
      Trivial typo fix in variadic · 721cdcd1
      Marc Poulhiès authored
      
      Fix all occurences of varadic, except for Rust (will be part of another change).
      
      gcc/ChangeLog:
      
      	* config/nvptx/nvptx.h (struct machine_function): Fix typo in variadic.
      	* config/nvptx/nvptx.cc (nvptx_function_arg_advance): Adjust to use fixed name.
      	(nvptx_declare_function_name): Likewise.
      	(nvptx_call_args): Likewise.
      	(nvptx_expand_call): Likewise.
      
      gcc/cp/ChangeLog:
      
      	* lambda.cc (compare_lambda_sig): Fix typo in variadic.
      
      libcpp/ChangeLog:
      
      	* macro.cc (parse_params): Fix typo in variadic.
      	(create_iso_definition): Likewise.
      
      Signed-off-by: default avatarMarc Poulhiès <dkm@kataplop.net>
      721cdcd1
    • GCC Administrator's avatar
      Daily bump. · b54b3800
      GCC Administrator authored
      b54b3800
  18. Nov 19, 2023
    • David Malcolm's avatar
      libcpp: split decls out to rich-location.h · 78d132d7
      David Malcolm authored
      
      The various decls relating to rich_location are in
      libcpp/include/line-map.h, but they don't relate to line maps.
      
      Split them out to their own header: libcpp/include/rich-location.h
      
      No functional change intended.
      
      gcc/ChangeLog:
      	* Makefile.in (CPPLIB_H): Add libcpp/include/rich-location.h.
      	* coretypes.h (class rich_location): New forward decl.
      
      gcc/analyzer/ChangeLog:
      	* analyzer.h: Include "rich-location.h".
      
      gcc/c-family/ChangeLog:
      	* c-lex.cc: Include "rich-location.h".
      
      gcc/cp/ChangeLog:
      	* mapper-client.cc: Include "rich-location.h".
      
      gcc/ChangeLog:
      	* diagnostic.h: Include "rich-location.h".
      	* edit-context.h (class fixit_hint): New forward decl.
      	* gcc-rich-location.h: Include "rich-location.h".
      	* genmatch.cc: Likewise.
      	* pretty-print.h: Likewise.
      
      gcc/rust/ChangeLog:
      	* rust-location.h: Include "rich-location.h".
      
      libcpp/ChangeLog:
      	* Makefile.in (TAGS_SOURCES): Add "include/rich-location.h".
      	* include/cpplib.h (class rich_location): New forward decl.
      	* include/line-map.h (class range_label)
      	(enum range_display_kind, struct location_range)
      	(class semi_embedded_vec, class rich_location, class label_text)
      	(class range_label, class fixit_hint): Move to...
      	* include/rich-location.h: ...this new file.
      	* internal.h: Include "rich-location.h".
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      78d132d7
  19. Nov 15, 2023
  20. Nov 14, 2023
    • Jakub Jelinek's avatar
      libcpp, contrib: Update to Unicode 15.1 · d64b7c82
      Jakub Jelinek authored
      The following patch (in plaintext just a pseudo-patch where I've left out
      the too big parts of either wget downloaded or regenerated files out with
      ..., full patch attached compressed) updates to Unicode 15.1 from 15.0
      we had last year.  Apparently Unicode forgot to add a new range to 4-8 Table
      we are using, but from the other files it is clear what should have been
      added; I've filed a bugreport against Unicode.
      
      2023-11-14  Jakub Jelinek  <jakub@redhat.com>
      
      contrib/
      	* unicode/README: Adjust glibc git commit hash, number of Unicode
      	data files to be updated and latest Unicode version.
      	* unicode/from_glibc/utf8_gen.py: Update from glibc.
      	* unicode/UnicodeData.txt: Update from Unicode 15.1.
      	* unicode/EastAsianWidth.txt: Likewise.
      	* unicode/DerivedNormalizationProps.txt: Likewise.
      	* unicode/NameAliases.txt: Likewise.
      	* unicode/DerivedCoreProperties.txt: Likewise.
      	* unicode/PropList.txt: Likewise.
      libcpp/
      	* makeucnid.cc (write_copyright): Update copyright year.
      	* makeuname2c.cc (write_copyright): Likewise.
      	(struct generated): Update latest Unicode version.
      	(generated_ranges): Add 2ebf0-2ee5d CJK UNIFIED IDEOGRAPH
      	range which was forgotten to be added to 4-8 table, but
      	clearly is expected to be there from the 15.1 additions.
      	* ucnid.h: Regenerated.
      	* uname2c.h: Regenerated.
      	* generated_cpp_wcwidth.h: Regenerated.
      d64b7c82
    • Jakub Jelinek's avatar
      c++: Implement C++26 P1854R4 - Making non-encodable string literals ill-formed [PR110341] · 194825f2
      Jakub Jelinek authored
      This paper voted in as DR makes some multi-character literals ill-formed.
      'abcd' stays valid, but e.g. 'á' is newly invalid in UTF-8 exec charset
      while valid e.g. in ISO-8859-1, because it is a single character which needs
      2 bytes to be encoded.
      
      The following patch does that by checking (only pedantically, especially
      because it is a DR) if we'd emit a -Wmultichar warning because character
      constant has more than one byte in it whether the number of source characters
      is equal to the number of bytes in the multichar string.
      If it is, it is normal multi-character literal constant
      and is diagnosed normally with -Wmultichar, otherwise at least one of the
      c-chars in the sequence was encoded as 2+ bytes.
      
      2023-11-14  Jakub Jelinek  <jakub@redhat.com>
      
      	PR c++/110341
      libcpp/
      	* charset.cc: Implement C++26 P1854R4 - Making non-encodable string
      	literals ill-formed.
      	(one_count_chars, convert_count_chars, count_source_chars): New
      	functions.
      	(narrow_str_to_charconst): Change last arg type from cpp_ttype to
      	const cpp_token *.  For C++ if pedantic and i > 1 in CPP_CHAR
      	interpret token also as CPP_STRING32 and if number of characters
      	in the CPP_STRING32 is larger than number of bytes in CPP_CHAR,
      	pedwarn on it.  Make the diagnostics more detailed.
      	(wide_str_to_charconst): Change last arg type from cpp_ttype to
      	const cpp_token *.  Make the diagnostics more detailed.
      	(cpp_interpret_charconst): Adjust narrow_str_to_charconst and
      	wide_str_to_charconst callers.
      gcc/testsuite/
      	* g++.dg/cpp26/literals1.C: New test.
      	* g++.dg/cpp26/literals2.C: New test.
      	* g++.dg/cpp23/wchar-multi1.C: Adjust expected diagnostic wordings.
      	* g++.dg/cpp23/wchar-multi2.C: Likewise.
      	* gcc.dg/c23-utf8char-3.c: Likewise.
      	* gcc.dg/cpp/charconst-4.c: Likewise.
      	* gcc.dg/cpp/charconst.c: Likewise.
      	* gcc.dg/cpp/if-2.c: Likewise.
      	* gcc.dg/utf16-4.c: Likewise.
      	* gcc.dg/utf32-4.c: Likewise.
      	* g++.dg/cpp1z/utf8-neg.C: Likewise.
      	* g++.dg/cpp2a/ucn2.C: Likewise.
      	* g++.dg/ext/utf16-4.C: Likewise.
      	* g++.dg/ext/utf32-4.C: Likewise.
      194825f2
    • GCC Administrator's avatar
      Daily bump. · b9fd8399
      GCC Administrator authored
      b9fd8399
    • Arsen Arsenović's avatar
      libcpp: Regenerate config.in · 5ee4349f
      Arsen Arsenović authored
      The previous commit did not include regenerating files maintained by
      autoheader.
      
      libcpp/ChangeLog:
      
      	* config.in: Regenerate.
      Unverified
      5ee4349f
  21. Nov 13, 2023
    • Arsen Arsenović's avatar
      *: add modern gettext · db50aea6
      Arsen Arsenović authored
      This patch updates gettext.m4 and related .m4 files and adds
      gettext-runtime as a gmp/mpfr/... style host library, allowing newer
      libintl to be used.
      
      This patch /does not/ add build-time tools required for
      internationalizing (msgfmt et al), instead, it just updates the runtime
      library.  The result should be a distribution that acts exactly the same
      when a copy of gettext is present, and disables internationalization
      otherwise.
      
      There should be no changes in behavior when gettext is included in-tree.
      When gettext is not included in tree, nor available on the system, the
      programs will be built without localization.
      
      ChangeLog:
      
      	PR bootstrap/12596
      	* .gitignore: Add '/gettext*'.
      	* configure.ac (host_libs): Replace intl with gettext.
      	(hbaseargs, bbaseargs, baseargs): Split baseargs into
      	{h,b}baseargs.
      	(skip_barg): New flag.  Skips appending current flag to
      	bbaseargs.
      	<library exemptions>: Exempt --with-libintl-{type,prefix} from
      	target and build machine argument passing.
      	* configure: Regenerate.
      	* Makefile.def (host_modules): Replace intl module with gettext
      	module.
      	(configure-ld): Depend on configure-gettext.
      	* Makefile.in: Regenerate.
      
      config/ChangeLog:
      
      	* intlmacosx.m4: Import from gettext-0.22 (serial 8).
      	* gettext.m4: Sync with gettext-0.22 (serial 77).
      	* gettext-sister.m4 (ZW_GNU_GETTEXT_SISTER_DIR): Load gettext's
      	uninstalled-config.sh, or call AM_GNU_GETTEXT if missing.
      	* iconv.m4: Sync with gettext-0.22 (serial 26).
      
      contrib/ChangeLog:
      
      	* prerequisites.sha512: Add gettext.
      	* prerequisites.md5: Add gettext.
      	* download_prerequisites: Add gettext.
      
      gcc/ChangeLog:
      
      	* configure: Regenerate.
      	* aclocal.m4: Regenerate.
      	* Makefile.in (LIBDEPS): Remove (potential) ./ prefix from
      	LIBINTL_DEP.
      	* doc/install.texi: Document new (notable) flags added by the
      	optional gettext tree and by AM_GNU_GETTEXT.  Document libintl/libc
      	with gettext dependency.
      
      libcpp/ChangeLog:
      
      	* configure: Regenerate.
      	* aclocal.m4: Regenerate.
      
      libstdc++-v3/ChangeLog:
      
      	* configure: Regenerate.
      Unverified
      db50aea6
  22. Nov 09, 2023
    • David Malcolm's avatar
      diagnostics: cleanups to diagnostic-show-locus.cc · 8625aa24
      David Malcolm authored
      
      Reduce implicit usage of line_table global, and move source printing to
      within diagnostic_context.
      
      gcc/ChangeLog:
      	* diagnostic-show-locus.cc (layout::m_line_table): New field.
      	(compatible_locations_p): Convert to...
      	(layout::compatible_locations_p): ...this, replacing uses of
      	line_table global with m_line_table.
      	(layout::layout): Convert "richloc" param from a pointer to a
      	const reference.  Initialize m_line_table member.
      	(layout::maybe_add_location_range):  Replace uses of line_table
      	global with m_line_table.  Pass the latter to
      	linemap_client_expand_location_to_spelling_point.
      	(layout::print_leading_fixits): Pass m_line_table to
      	affects_line_p.
      	(layout::print_trailing_fixits): Likewise.
      	(gcc_rich_location::add_location_if_nearby): Update for change
      	to layout ctor params.
      	(diagnostic_show_locus): Convert to...
      	(diagnostic_context::maybe_show_locus): ...this, converting
      	richloc param from a pointer to a const reference.  Make "loc"
      	const.  Split out printing part of function to...
      	(diagnostic_context::show_locus): ...this.
      	(selftest::test_offset_impl): Update for change to layout ctor
      	params.
      	(selftest::test_layout_x_offset_display_utf8): Likewise.
      	(selftest::test_layout_x_offset_display_tab): Likewise.
      	(selftest::test_tab_expansion): Likewise.
      	* diagnostic.h (diagnostic_context::maybe_show_locus): New decl.
      	(diagnostic_context::show_locus): New decl.
      	(diagnostic_show_locus): Convert from a decl to an inline function.
      	* gdbinit.in (break-on-diagnostic): Update from a breakpoint
      	on diagnostic_show_locus to one on
      	diagnostic_context::maybe_show_locus.
      	* genmatch.cc (linemap_client_expand_location_to_spelling_point):
      	Add "set" param and use it in place of line_table global.
      	* input.cc (expand_location_1): Likewise.
      	(expand_location): Update for new param of expand_location_1.
      	(expand_location_to_spelling_point): Likewise.
      	(linemap_client_expand_location_to_spelling_point): Add "set"
      	param and use it in place of line_table global.
      	* tree-diagnostic-path.cc (event_range::print): Pass line_table
      	for new param of linemap_client_expand_location_to_spelling_point.
      
      libcpp/ChangeLog:
      	* include/line-map.h (rich_location::get_expanded_location): Make
      	const.
      	(rich_location::get_line_table): New accessor.
      	(rich_location::m_line_table): Make the pointer be const.
      	(rich_location::m_have_expanded_location): Make mutable.
      	(rich_location::m_expanded_location): Likewise.
      	(fixit_hint::affects_line_p): Add const line_maps * param.
      	(linemap_client_expand_location_to_spelling_point): Likewise.
      	* line-map.cc (rich_location::get_expanded_location): Make const.
      	Pass m_line_table to
      	linemap_client_expand_location_to_spelling_point.
      	(rich_location::maybe_add_fixit): Likewise.
      	(fixit_hint::affects_line_p): Add set param and pass to
      	linemap_client_expand_location_to_spelling_point.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      8625aa24
  23. Nov 08, 2023
  24. Nov 07, 2023
    • Joseph Myers's avatar
      c: Refer more consistently to C23 not C2X · 094a609c
      Joseph Myers authored
      Continuing the move to refer to C23 in place of C2X throughout the
      source tree, update documentation, diagnostics, comments, variable and
      function names, etc., to use the C23 name.
      
      Testsuite updates are left for a future patch, except for testcases
      that test diagnostics that previously mentioned C2X (but in those
      testcases, sometimes other comments are updated, not just the
      diagnostic expectations).
      
      Bootstrapped with no regressions for x86_64-pc-linux-gnu.
      
      gcc/
      	* builtins.def (DEF_C2X_BUILTIN): Rename to DEF_C23_BUILTIN and
      	use flag_isoc23 and function_c23_misc.
      	* config/rl78/rl78.cc (rl78_option_override): Compare
      	lang_hooks.name with "GNU C23" not "GNU C2X".
      	* coretypes.h (function_c2x_misc): Rename to function_c23_misc.
      	* doc/cpp.texi (@code{__has_attribute}): Refer to C23 instead of
      	C2x.
      	* doc/extend.texi: Likewise.
      	* doc/invoke.texi: Likewise.
      	* dwarf2out.cc (highest_c_language, gen_compile_unit_die): Compare
      	against and return "GNU C23" language string instead of "GNU C2X".
      	* ginclude/float.h: Refer to C23 instead of C2X in comments.
      	* ginclude/stdint-gcc.h: Likewise.
      	* glimits.h: Likewise.
      	* tree.h: Likewise.
      
      gcc/ada/
      	* gcc-interface/utils.cc (flag_isoc2x): Rename to flag_isoc23.
      
      gcc/c-family/
      	* c-common.cc (flag_isoc2x): Rename to flag_isoc23.
      	(c_common_reswords): Use D_C23 instead of D_C2X.
      	* c-common.h: Refer throughout to C23 instead of C2X in comments.
      	(D_C2X): Rename to D_C23.
      	(flag_isoc2x): Rename to flag_isoc23.
      	* c-cppbuiltin.cc (builtin_define_float_constants): Use
      	flag_isoc23 instead of flag_isoc2x.  Refer to C23 instead of C2x
      	in comments.
      	* c-format.cc: Use STD_C23 instead of STD_C2X and flag_isoc23
      	instead of flag_isoc2x.  Refer to C23 instead of C2X in comments.
      	* c-format.h: Use STD_C23 instead of STD_C2X.
      	* c-lex.cc: Use warn_c11_c23_compat instead of warn_c11_c2x_compat
      	and flag_isoc23 instead of flag_isoc2x.  Refer to C23 instead of
      	C2X in diagnostics.
      	* c-opts.cc: Use flag_isoc23 instead of flag_isoc2x.  Refer to C23
      	instead of C2X in comments.
      	(set_std_c2x): Rename to set_std_c23.
      	* c.opt (Wc11-c23-compat): Use CPP(cpp_warn_c11_c23_compat)
      	CppReason(CPP_W_C11_C23_COMPAT) Var(warn_c11_c23_compat) instead
      	of CPP(cpp_warn_c11_c2x_compat) CppReason(CPP_W_C11_C2X_COMPAT)
      	Var(warn_c11_c2x_compat).
      
      gcc/c/
      	* c-decl.cc: Use flag_isoc23 instead of flag_isoc2x and c23_auto_p
      	instead of c2x_auto_p.  Refer to C23 instead of C2X in diagnostics
      	and comments.
      	* c-errors.cc: Use flag_isoc23 instead of flag_isoc2x and
      	warn_c11_c23_compat instead of warn_c11_c2x_compat.  Refer to C23
      	instead of C2X in comments.
      	* c-parser.cc: Use flag_isoc23 instead of flag_isoc2x,
      	warn_c11_c23_compat instead of warn_c11_c2x_compat, c23_auto_p
      	instead of c2x_auto_p and D_C23 instead of D_C2X.  Refer to C23
      	instead of C2X in diagnostics and comments.
      	* c-tree.h: Refer to C23 instead of C2X in comments.
      	(struct c_declspecs): Rename c2x_auto_p to c23_auto_p.
      	* c-typeck.cc: Use flag_isoc23 instead of flag_isoc2x and
      	warn_c11_c23_compat instead of warn_c11_c2x_compat.  Refer to C23
      	instead of C2X in diagnostics and comments.
      
      gcc/fortran/
      	* gfortran.h (gfc_real_info): Refer to C23 instead of C2X in
      	comment.
      
      gcc/lto/
      	* lto-lang.cc (flag_isoc2x): Rename to flag_isoc23.
      
      gcc/testsuite/
      	* gcc.dg/binary-constants-2.c: Refer to C23 instead of C2X.
      	* gcc.dg/binary-constants-3.c: Likewise.
      	* gcc.dg/bitint-23.c: Likewise.
      	* gcc.dg/bitint-26.c: Likewise.
      	* gcc.dg/bitint-27.c: Likewise.
      	* gcc.dg/c11-attr-syntax-1.c: Likewise.
      	* gcc.dg/c11-attr-syntax-2.c: Likewise.
      	* gcc.dg/c11-floatn-1.c: Likewise.
      	* gcc.dg/c11-floatn-2.c: Likewise.
      	* gcc.dg/c11-floatn-3.c: Likewise.
      	* gcc.dg/c11-floatn-4.c: Likewise.
      	* gcc.dg/c11-floatn-5.c: Likewise.
      	* gcc.dg/c11-floatn-6.c: Likewise.
      	* gcc.dg/c11-floatn-7.c: Likewise.
      	* gcc.dg/c11-floatn-8.c: Likewise.
      	* gcc.dg/c2x-attr-syntax-4.c: Likewise.
      	* gcc.dg/c2x-attr-syntax-6.c: Likewise.
      	* gcc.dg/c2x-attr-syntax-7.c: Likewise.
      	* gcc.dg/c2x-binary-constants-2.c: Likewise.
      	* gcc.dg/c2x-floatn-5.c: Likewise.
      	* gcc.dg/c2x-floatn-6.c: Likewise.
      	* gcc.dg/c2x-floatn-7.c: Likewise.
      	* gcc.dg/c2x-floatn-8.c: Likewise.
      	* gcc.dg/c2x-nullptr-4.c: Likewise.
      	* gcc.dg/c2x-qual-2.c: Likewise.
      	* gcc.dg/c2x-qual-3.c: Likewise.
      	* gcc.dg/c2x-qual-6.c: Likewise.
      	* gcc.dg/cpp/c11-warning-1.c: Likewise.
      	* gcc.dg/cpp/c11-warning-2.c: Likewise.
      	* gcc.dg/cpp/c11-warning-3.c: Likewise.
      	* gcc.dg/cpp/c2x-warning-2.c: Likewise.
      	* gcc.dg/cpp/gnu11-elifdef-3.c: Likewise.
      	* gcc.dg/cpp/gnu11-elifdef-4.c: Likewise.
      	* gcc.dg/cpp/gnu11-warning-1.c: Likewise.
      	* gcc.dg/cpp/gnu11-warning-2.c: Likewise.
      	* gcc.dg/cpp/gnu11-warning-3.c: Likewise.
      	* gcc.dg/cpp/gnu2x-warning-2.c: Likewise.
      	* gcc.dg/dfp/c11-constants-1.c: Likewise.
      	* gcc.dg/dfp/c11-constants-2.c: Likewise.
      	* gcc.dg/dfp/c2x-constants-2.c: Likewise.
      	* gcc.dg/dfp/constants-pedantic.c: Likewise.
      	* gcc.dg/pr30260.c: Likewise.
      	* gcc.dg/system-binary-constants-1.c: Likewise.
      
      libcpp/
      	* directives.cc: Refer to C23 instead of C2X in diagnostics and
      	comments.
      	(STDC2X): Rename to STDC23.
      	* expr.cc: Use cpp_warn_c11_c23_compat instead of
      	cpp_warn_c11_c2x_compat and CPP_W_C11_C23_COMPAT instead of
      	CPP_W_C11_C2X_COMPAT.  Refer to C23 instead of C2X in diagnostics
      	and comments.
      	* include/cpplib.h: Refer to C23 instead of C2X in diagnostics and
      	comments.
      	(CLK_GNUC2X): Rename to CLK_GNUC23.
      	(CLK_STDC2X): Rename to CLK_STDC23.
      	(CPP_W_C11_C2X_COMPAT): Rename to CPP_W_C11_C23_COMPAT.
      	* init.cc: Use GNUC23 instead of GNUC2X, STDC23 instead of STDC2X
      	and cpp_warn_c11_c23_compat instead of cpp_warn_c11_c2x_compat.
      	* lex.cc (maybe_va_opt_error): Refer to C23 instead of C2X in
      	diagnostic.
      	* macro.cc (_cpp_arguments_ok): Refer to C23 instead of C2X in
      	comment.
      094a609c
  25. Nov 03, 2023
  26. Nov 02, 2023
    • Jakub Jelinek's avatar
      c++: Implement C++26 P2361R6 - Unevaluated strings [PR110342] · 1c585664
      Jakub Jelinek authored
      The following patch implements C++26 unevaluated-string.
      As it seems to me just extra pedanticity, it is implemented only for
      -std=c++26 or -std=gnu++26 and later and only if -pedantic/-pedantic-errors.
      Nothing is done for inline asm, while the spec changes those, it changes it
      to a balanced token sequence with implementation defined rules on what is
      and isn't allowed (so pedantically accepting asm ("" : "+m" (x));
      was accepts-invalid before C++26, but we didn't diagnose anything).
      For the other spots mentioned in the paper, static_assert message,
      linkage specification, deprecated/nodiscard attributes it enforces the
      requirements (no prefixes, udlit suffixes, no octal/hexadecimal escapes
      (conditional escape sequences were rejected with pedantic already before).
      For the deprecated operator "" identifier case I've kept things as is,
      because everything seems to have been diagnosed already (a lot being implied
      from the string having to be empty).
      
      2023-11-02  Jakub Jelinek  <jakub@redhat.com>
      
      	PR c++/110342
      gcc/cp/
      	* parser.cc: Implement C++26 P2361R6 - Unevaluated strings.
      	(uneval_string_attr): New enumerator.
      	(cp_parser_string_literal_common): Add UNEVAL argument.  If true,
      	pass CPP_UNEVAL_STRING rather than CPP_STRING to
      	cpp_interpret_string_notranslate.
      	(cp_parser_string_literal, cp_parser_userdef_string_literal): Adjust
      	callers of cp_parser_string_literal_common.
      	(cp_parser_unevaluated_string_literal): New function.
      	(cp_parser_parenthesized_expression_list): Handle uneval_string_attr.
      	(cp_parser_linkage_specification): Use
      	cp_parser_unevaluated_string_literal for C++26.
      	(cp_parser_static_assert): Likewise.
      	(cp_parser_std_attribute): Use uneval_string_attr for standard
      	deprecated and nodiscard attributes.
      gcc/testsuite/
      	* g++.dg/cpp26/unevalstr1.C: New test.
      	* g++.dg/cpp26/unevalstr2.C: New test.
      	* g++.dg/cpp0x/udlit-error1.C (lol): Expect an error for C++26
      	about user-defined literal in deprecated attribute.
      libcpp/
      	* include/cpplib.h (TTYPE_TABLE): Add CPP_UNEVAL_STRING literal
      	entry.  Use C++11 instead of C++-0x in comments.
      	* charset.cc (convert_escape): Add UNEVAL argument, if true,
      	pedantically diagnose numeric escape sequences.
      	(cpp_interpret_string_1): Formatting fix.  Adjust convert_escape
      	caller.
      	(cpp_interpret_string): Formatting string.
      	(cpp_interpret_string_notranslate): Pass type through to
      	cpp_interpret_string if it is CPP_UNEVAL_STRING.
      1c585664
  27. Nov 01, 2023
  28. Oct 31, 2023
    • David Malcolm's avatar
      libcpp: eliminate MACRO_MAP_EXPANSION_POINT_LOCATION · b0f19336
      David Malcolm authored
      
      This patch eliminates the function "MACRO_MAP_EXPANSION_POINT_LOCATION"
      (which hasn't been a macro since r6-739-g0501dbd932a7e9) in favor of
      a new line_map_macro::get_expansion_point_location accessor.
      
      No functional change intended.
      
      gcc/c-family/ChangeLog:
      	* c-warn.cc (warn_for_multistatement_macros): Update for removal
      	of MACRO_MAP_EXPANSION_POINT_LOCATION.
      
      gcc/cp/ChangeLog:
      	* module.cc (ordinary_loc_of): Update for removal of
      	MACRO_MAP_EXPANSION_POINT_LOCATION.
      	(module_state::note_location): Update for renaming of field.
      	(module_state::write_macro_maps): Likewise.
      
      gcc/ChangeLog:
      	* input.cc (dump_location_info): Update for removal of
      	MACRO_MAP_EXPANSION_POINT_LOCATION.
      	* tree-diagnostic.cc (maybe_unwind_expanded_macro_loc):
      	Likewise.
      
      libcpp/ChangeLog:
      	* include/line-map.h
      	(line_map_macro::get_expansion_point_location): New accessor.
      	(line_map_macro::expansion): Rename field to...
      	(line_map_macro::mexpansion): Rename field to...
      	(MACRO_MAP_EXPANSION_POINT_LOCATION): Delete this function.
      	* line-map.cc (linemap_enter_macro): Update for renaming of field.
      	(linemap_macro_map_loc_to_exp_point): Update for removal of
      	MACRO_MAP_EXPANSION_POINT_LOCATION.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      b0f19336
  29. Oct 24, 2023
  30. Oct 23, 2023
    • Lewis Hyatt's avatar
      libcpp: Improve the diagnostic for poisoned identifiers [PR36887] · cb05acdc
      Lewis Hyatt authored
      The PR requests an enhancement to the diagnostic issued for the use of a
      poisoned identifier. Currently, we show the location of the usage, but not
      the location which requested the poisoning, which would be helpful for the
      user if the decision to poison an identifier was made externally, such as
      in a library header.
      
      In order to output this information, we need to remember a location_t for
      each identifier that has been poisoned, and that data needs to be preserved
      as well in a PCH. One option would be to add a field to struct cpp_hashnode,
      but there is no convenient place to add it without increasing the size of
      the struct for all identifiers. Given this facility will be needed rarely,
      it seemed better to add a second hash map, which is handled PCH-wise the
      same as the current one in gcc/stringpool.cc. This hash map associates a new
      struct cpp_hashnode_extra with each identifier that needs one. Currently
      that struct only contains the new location_t, but it could be extended in
      the future if there is other ancillary data that may be convenient to put
      there for other purposes.
      
      libcpp/ChangeLog:
      
      	PR preprocessor/36887
      	* directives.cc (do_pragma_poison): Store in the extra hash map the
      	location from which an identifier has been poisoned.
      	* lex.cc (identifier_diagnostics_on_lex): When issuing a diagnostic
      	for the use of a poisoned identifier, also add a note indicating the
      	location from which it was poisoned.
      	* identifiers.cc (alloc_node): Convert to template function.
      	(_cpp_init_hashtable): Handle the new extra hash map.
      	(_cpp_destroy_hashtable): Likewise.
      	* include/cpplib.h (struct cpp_hashnode_extra): New struct.
      	(cpp_create_reader): Update prototype to...
      	* init.cc (cpp_create_reader): ...accept an argument for the extra
      	hash table and pass it to _cpp_init_hashtable.
      	* include/symtab.h (ht_lookup): New overload for convenience.
      	* internal.h (struct cpp_reader): Add EXTRA_HASH_TABLE member.
      	(_cpp_init_hashtable): Adjust prototype.
      
      gcc/c-family/ChangeLog:
      
      	PR preprocessor/36887
      	* c-opts.cc (c_common_init_options): Pass new extra hash map
      	argument to cpp_create_reader().
      
      gcc/ChangeLog:
      
      	PR preprocessor/36887
      	* toplev.h (ident_hash_extra): Declare...
      	* stringpool.cc (ident_hash_extra): ...this new global variable.
      	(init_stringpool): Handle ident_hash_extra as well as ident_hash.
      	(ggc_mark_stringpool): Likewise.
      	(ggc_purge_stringpool): Likewise.
      	(struct string_pool_data_extra): New struct.
      	(spd2): New GC root variable.
      	(gt_pch_save_stringpool): Use spd2 to handle ident_hash_extra,
      	analogous to how spd is used to handle ident_hash.
      	(gt_pch_restore_stringpool): Likewise.
      
      gcc/testsuite/ChangeLog:
      
      	PR preprocessor/36887
      	* c-c++-common/cpp/diagnostic-poison.c: New test.
      	* g++.dg/pch/pr36887.C: New test.
      	* g++.dg/pch/pr36887.Hs: New test.
      cb05acdc
  31. Oct 09, 2023
  32. Oct 08, 2023
    • David Malcolm's avatar
      libcpp: eliminate LINEMAPS_{ORDINARY,MACRO}_MAPS · 0a0ceb7a
      David Malcolm authored
      
      libcpp/ChangeLog:
      	* include/line-map.h (LINEMAPS_ORDINARY_MAPS): Delete.
      	(LINEMAPS_MACRO_MAPS): Delete.
      	* line-map.cc (linemap_tracks_macro_expansion_locs_p): Update for
      	deletion of LINEMAPS_MACRO_MAPS.
      	(linemap_get_statistics): Likewise.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      0a0ceb7a
    • David Malcolm's avatar
      libcpp: eliminate LINEMAPS_{,ORDINARY_,MACRO_}CACHE · 45bae180
      David Malcolm authored
      
      It's simpler to use field access than to go through these inline
      functions that look as if they are macros.
      
      No functional change intended.
      
      libcpp/ChangeLog:
      	* include/line-map.h (maps_info_ordinary::cache): Rename to...
      	(maps_info_ordinary::m_cache): ...this.
      	(maps_info_macro::cache): Rename to...
      	(maps_info_macro::m_cache): ...this.
      	(LINEMAPS_CACHE): Delete.
      	(LINEMAPS_ORDINARY_CACHE): Delete.
      	(LINEMAPS_MACRO_CACHE): Delete.
      	* init.cc (read_original_filename): Update for adding "m_" prefix.
      	* line-map.cc (linemap_add): Eliminate LINEMAPS_ORDINARY_CACHE in
      	favor of a simple field access.
      	(linemap_enter_macro): Likewise for LINEMAPS_MACRO_CACHE.
      	(linemap_ordinary_map_lookup): Likewise for
      	LINEMAPS_ORDINARY_CACHE, twice.
      	(linemap_lookup_macro_index): Likewise for LINEMAPS_MACRO_CACHE.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      45bae180
Loading