Skip to content
Snippets Groups Projects
  1. Jan 17, 2024
    • Jonathan Wakely's avatar
      libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318] · df0a668b
      Jonathan Wakely authored
      
      This is another C++26 change, approved in Varna 2023. We require a new
      static array of data that is extracted from the IANA Character Sets
      database. A new Python script to generate a header from the IANA CSV
      file is added.
      
      The text_encoding class is basically just a pointer to an {ID,name} pair
      in the static array. The aliases view is also just the same pointer (or
      empty), and the view's iterator moves forwards and backwards in the
      array while the array elements have the same ID (or to one element
      further, for a past-the-end iterator).
      
      Because those iterators refer to a global array that never goes out of
      scope, there's no reason they should every produce undefined behaviour
      or indeterminate values.  They should either have well-defined
      behaviour, or abort. The overhead of ensuring those properties is pretty
      low, so seems worth it.
      
      This means that an aliases_view iterator should never be able to access
      out-of-bounds. A non-value-initialized iterator always points to an
      element of the static array even when not dereferenceable (the array has
      unreachable entries at the start and end, which means that even a
      past-the-end iterator for the last encoding in the array still points to
      valid memory).  Dereferencing an iterator can always return a valid
      array element, or "" for a non-dereferenceable iterator (but doing so
      will abort when assertions are enabled).  In the language being proposed
      for C++26, dereferencing an invalid iterator erroneously returns "".
      Attempting to increment/decrement past the last/first element in the
      view is erroneously a no-op, so aborts when assertions are enabled, and
      doesn't change value otherwise.
      
      Similarly, constructing a std::text_encoding with an invalid id (one
      that doesn't have the value of an enumerator) erroneously behaves the
      same as constructing with id::unknown, or aborts with assertions
      enabled.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/113318
      	* acinclude.m4 (GLIBCXX_CONFIGURE): Add c++26 directory.
      	(GLIBCXX_CHECK_TEXT_ENCODING): Define.
      	* config.h.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Use GLIBCXX_CHECK_TEXT_ENCODING.
      	* include/Makefile.am: Add new headers.
      	* include/Makefile.in: Regenerate.
      	* include/bits/locale_classes.h (locale::encoding): Declare new
      	member function.
      	* include/bits/unicode.h (__charset_alias_match): New function.
      	* include/bits/text_encoding-data.h: New file.
      	* include/bits/version.def (text_encoding): Define.
      	* include/bits/version.h: Regenerate.
      	* include/std/text_encoding: New file.
      	* src/Makefile.am: Add new subdirectory.
      	* src/Makefile.in: Regenerate.
      	* src/c++26/Makefile.am: New file.
      	* src/c++26/Makefile.in: New file.
      	* src/c++26/text_encoding.cc: New file.
      	* src/experimental/Makefile.am: Include c++26 convenience
      	library.
      	* src/experimental/Makefile.in: Regenerate.
      	* python/libstdcxx/v6/printers.py (StdTextEncodingPrinter): New
      	printer.
      	* scripts/gen_text_encoding_data.py: New file.
      	* testsuite/22_locale/locale/encoding.cc: New test.
      	* testsuite/ext/unicode/charset_alias_match.cc: New test.
      	* testsuite/std/text_encoding/cons.cc: New test.
      	* testsuite/std/text_encoding/members.cc: New test.
      	* testsuite/std/text_encoding/requirements.cc: New test.
      
      Reviewed-by: default avatarUlrich Drepper <drepper.fsp@gmail.com>
      Reviewed-by: default avatarPatrick Palka <ppalka@redhat.com>
      df0a668b
    • Jonathan Wakely's avatar
      libstdc++: Do not use CTAD for _Utf32_view alias template · 665a3ff1
      Jonathan Wakely authored
      We were relying on P1814R0 (CTAD for alias templates) which isn't
      supported by Clang. We can just not use CTAD and provide an explicit
      template argument list for _Utf32_view.
      
      Ideally we'd define a deduction guide for _Grapheme_cluster_view that
      uses views::all_t to properly convert non-views to views, but all_t is
      defined in <ranges> and we don't want to include all of that in
      <bits/unicode.h>. So just make it require a view for now, which can be
      cheaply copied.
      
      Although it's not needed yet, it would also be more correct to
      specialize enable_borrowed_range for the views in <bits/unicode.h>.
      
      libstdc++-v3/ChangeLog:
      
      	* include/bits/unicode.h (_Grapheme_cluster_view): Require view.
      	Do not use CTAD for _Utf32_view.
      	(__format_width, __truncate): Do not use CTAD.
      	(enable_borrowed_range<_Utf_view<T, R>>): Define specialization.
      	(enable_borrowed_range<_Grapheme_cluster_view<R>>): Likewise.
      665a3ff1
    • Jakub Jelinek's avatar
      testsuite: Add testcase for already fixed PR [PR110251] · 3fd32d3d
      Jakub Jelinek authored
      This testcase started to hang at -O3 with r13-4208 and got fixed
      with r14-2097.
      
      2024-01-17  Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/110251
      	* gcc.c-torture/compile/pr110251.c: New test.
      3fd32d3d
    • Jakub Jelinek's avatar
      Fix comment typos · 97089a54
      Jakub Jelinek authored
      When looking at PR113410, I found a comment typo and just searched for
      the same typo elsewhere and found some typos in the comments which had
      that typo as well.
      
      2024-01-17  Jakub Jelinek  <jakub@redhat.com>
      
      	* tree-into-ssa.cc (pass_build_ssa::gate): Fix comment typo,
      	funcions -> functions, and use were instead of was.
      	* gengtype.cc (dump_typekind): Fix comment typos, funcion -> function
      	and guaranteee -> guarantee.
      	* attribs.h (struct attr_access): Fix comment typo funcion -> function.
      97089a54
    • Jakub Jelinek's avatar
      openmp: Add OpenMP _BitInt support [PR113409] · c8f10456
      Jakub Jelinek authored
      The following patch adds support for _BitInt iterators of OpenMP canonical
      loops (with the preexisting limitation that when not using compile time
      static scheduling the iterators in the library are at most unsigned long long
      or signed long, so one can't in the runtime/dynamic/guided etc. cases iterate
      more than what those types can represent, like is the case of e.g. __int128
      iterators too) and the testcase also covers linear/reduction clauses for them.
      
      2024-01-17  Jakub Jelinek  <jakub@redhat.com>
      
      	PR middle-end/113409
      	* omp-general.cc (omp_adjust_for_condition): Handle BITINT_TYPE like
      	INTEGER_TYPE.
      	(omp_extract_for_data): Use build_bitint_type rather than
      	build_nonstandard_integer_type if either iter_type or loop->v type
      	is BITINT_TYPE.
      	* omp-expand.cc (expand_omp_for_generic,
      	expand_omp_taskloop_for_outer, expand_omp_taskloop_for_inner): Handle
      	BITINT_TYPE like INTEGER_TYPE.
      
      	* testsuite/libgomp.c/bitint-1.c: New test.
      c8f10456
    • YunQiang Su's avatar
      Sanitizer/MIPS: Use $t9 for preemptible function call · 557dbbac
      YunQiang Su authored
      Currently, almost all of the shared libraries of MIPS, rely on $t9
      to get the address of current function, instead of PCREL instructions,
      even on MIPSr6. So we have to set $t9 properly.
      
      To get the address of preemptible function, we need the help of GOT.
      MIPS/O32 has .cpload, which can help to generate 3 instructions to get GOT.
      For __mips64, we can get GOT by:
      
      lui $t8, %hi(%neg(%gp_rel(SANITIZER_STRINGIFY(TRAMPOLINE(func)))))
      daddu $t8, $t8, $t9
      daddiu $t8, $t8, %hi(%neg(%gp_rel(SANITIZER_STRINGIFY(TRAMPOLINE(func)))))
      
      And then get the address of __interceptor_func, and jump to it
      
      ld $t9, %got_disp(_interceptor" SANITIZER_STRINGIFY(func) ")($t8)
      jr $t9
      
      Upstream-Commit: 0a64367a72f1634321f5051221f05f2f364bd882
      
      libsanitizer
      
      	* interception/interception.h (substitution_##func_name):
      	Use macro C_ASM_TAIL_CALL.
      	* sanitizer_common/sanitizer_asm.h: Define C_ASM_TAIL_CALL
      	for MIPS with help of t9.
      557dbbac
    • Pan Li's avatar
      RISC-V: Fix asm checks regression due to recent middle-end change · de4c9a27
      Pan Li authored
      
      The recent middle-end change result in some asm check failures.
      This patch would like to fix the asm check by adjust the times.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/vls/shift-1.c: Fix asm check
      	count.
      	* gcc.target/riscv/rvv/autovec/vls/shift-2.c: Ditto.
      	* gcc.target/riscv/rvv/autovec/vls/shift-3.c: Ditto.
      
      Signed-off-by: default avatarPan Li <pan2.li@intel.com>
      de4c9a27
    • Richard Biener's avatar
      tree-optimization/113371 - avoid prologue peeling for peeled early exits · 33599424
      Richard Biener authored
      The following avoids prologue peeling when doing early exit
      vectorization with the IV exit before the early exit.  That's because
      we it invalidates the invariant that the effective latch of the loop
      is empty causing wrong continuation to the main loop.  In particular
      this is prone to break virtual SSA form.
      
      	PR tree-optimization/113371
      	* tree-vect-data-refs.cc (vect_enhance_data_refs_alignment):
      	Do not peel when LOOP_VINFO_EARLY_BREAKS_VECT_PEELED.
      	* tree-vect-loop-manip.cc (vect_do_peeling): Assert we do
      	not perform prologue peeling when LOOP_VINFO_EARLY_BREAKS_VECT_PEELED.
      
      	* gcc.dg/vect/pr113371.c: New testcase.
      33599424
    • Maxim Kuvyrkov's avatar
      sched-deps.cc (find_modifiable_mems): Avoid exponential behavior [PR96388] · 0c42d178
      Maxim Kuvyrkov authored
      This patch avoids sched-deps.cc:find_inc() creating exponential number
      of dependencies, which become memory and compilation time hogs.
      Consider example (simplified from PR96388) ...
      ===
      sp=sp-4 // sp_insnA
      mem_insnA1[sp+A1]
      ...
      mem_insnAN[sp+AN]
      sp=sp-4 // sp_insnB
      mem_insnB1[sp+B1]
      ...
      mem_insnBM[sp+BM]
      ===
      
      [For simplicity, let's assume find_inc(backwards==true)].
      In this example find_modifiable_mems() will arrange for mem_insnA*
      to be able to pass sp_insnA, and, while doing this, will create
      dependencies between all mem_insnA*s and sp_insnB -- because sp_insnB
      is a consumer of sp_insnA.  After this sp_insnB will have N new
      backward dependencies.
      Then find_modifiable_mems() gets to mem_insnB*s and starts to create
      N new dependencies for _every_ mem_insnB*.  This gets us N*M new
      dependencies.
      
      In PR96833's testcase N and M are 10k-15k, which causes RAM usage of
      30GB and compilation time of 30 minutes, with sched2 accounting for
      95% of both metrics.  After this patch the RAM usage is down to 1GB
      and compilation time is down to 3-4 minutes, with sched2 no longer
      standing out on -ftime-report or memory usage.
      
      gcc/ChangeLog:
      
      	PR rtl-optimization/96388
      	PR rtl-optimization/111554
      	* sched-deps.cc (find_inc): Avoid exponential behavior.
      0c42d178
    • Sandra Loosemore's avatar
      Move docs for -Wuse-after-free and -Wuseless-cast [PR111693] · 25bb8a40
      Sandra Loosemore authored
      These options were categorized as C++ options, but they apply to all
      C-family languages.
      
      gcc/ChangeLog
      	PR c/111693
      	* doc/invoke.texi (Option Summary): Move -Wuseless-cast
      	from C++ Language Options to Warning Options.  Add entry for
      	-Wuse-after-free.
      	(C++ Dialect Options): Move -Wuse-after-free and -Wuseless-cast
      	from here....
      	(Warning Options): ...to here.  Minor copy-editing to fix typo
      	and grammar.
      25bb8a40
    • YunQiang Su's avatar
      MIPS: avoid $gp store if global_pointer is not $gp · b503c878
      YunQiang Su authored
      $GP is used for expanding GOT load, but in the afterward passes,
      a temporary register is tried to replace $gp.
      
      If sucess, we have no need to store and reload $gp. The example
      of failure is that the function calls a preemtive function.
      
      We shouldn't use $GP for any other purpose in the code we generate.
      If a user's inline asm code clobbers $GP, it's their duty to save
      and restore $GP.
      
      gcc
      	* config/mips/mips.cc (mips_compute_frame_info): If another
      	register is used as global_pointer, mark $GP live false.
      
      gcc/testsuite
      	* gcc.target/mips/mips.exp (mips_option_groups):
      	Add -mxgot/-mno-xgot options.
      	* gcc.target/mips/xgot-n32-avoid-gp.c: New test.
      	* gcc.target/mips/xgot-n32-need-gp.c: New test.
      b503c878
    • Sandra Loosemore's avatar
      Tidy documentation for BPF builtins [PR112973] · fce3f51f
      Sandra Loosemore authored
      gcc/Changelog
      	PR target/112973
      	* doc/extend.texi (BPF Built-in Functions): Wrap long lines and
      	give the section a light copy-editing pass.
      fce3f51f
    • Patrick Palka's avatar
      libstdc++: Implement P2540R1 change to views::cartesian_product() · 98966f32
      Patrick Palka authored
      
      This paper changes the identity element of views::cartesian_product to a
      singleton range instead of an empty range.  It was approved alongside
      the main cartesian_product paper P2374R4, but unfortunately was overlooked
      when implementing the main paper.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/ranges (views::_CartesianProduct::operator()):
      	Adjust identity case as per P2540R1.
      	* testsuite/std/ranges/cartesian_product/1.cc (test01):
      	Adjust expected result of the identity case.
      
      Reviewed-by: default avatarJonathan Wakely <jwakely@redhat.com>
      98966f32
    • GCC Administrator's avatar
      Daily bump. · 1a177974
      GCC Administrator authored
      1a177974
  2. Jan 16, 2024
    • Nathaniel Shead's avatar
      c++: Support thread_local statics in header modules [PR113292] · 14338386
      Nathaniel Shead authored
      
      Currently, thread_locals in header modules cause ICEs. This patch makes
      the required changes for them to work successfully.
      
      This requires additionally writing the DECL_TLS_MODEL for thread-local
      variables to the module interface, and the TLS wrapper function needs to
      have its DECL_BEFRIENDING_CLASSES written too as this is used to
      retrieve what VAR_DECL it's a wrapper for when emitting a definition at
      end of TU processing.
      
      	PR c++/113292
      
      gcc/cp/ChangeLog:
      	* decl2.cc (get_tls_wrapper_fn): Set DECL_CONTEXT.
      	(c_parse_final_cleanups): Suppress warning for no definition of
      	TLS wrapper functions in header modules.
      	* module.cc (trees_out::lang_decl_vals): Write wrapped variable
      	for TLS wrapper functions.
      	(trees_in::lang_decl_vals): Read it.
      	(trees_out::decl_value): Write TLS model for thread-local vars.
      	(trees_in::decl_value): Read it for new decls. Remember to emit
      	definitions of TLS wrapper functions later.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/modules/pr113292_a.H: New test.
      	* g++.dg/modules/pr113292_b.C: New test.
      	* g++.dg/modules/pr113292_c.C: New test.
      
      Signed-off-by: default avatarNathaniel Shead <nathanieloshead@gmail.com>
      14338386
    • Nathaniel Shead's avatar
      c++: Fix ENABLE_SCOPE_CHECKING printing · fe1649ee
      Nathaniel Shead authored
      
      The lists of scope kinds used by ENABLE_SCOPE_CHECKING don't seem to
      have been updated in a long while, causing ICEs and confusing output.
      This patch brings the list into line.
      
      Additionally, the comment on 'explicit_spec_p' says that the flag is
      only valid if kind is 'sk_template_parms', so we rewrite the condition
      to be more obviously correct here.
      
      gcc/cp/ChangeLog:
      
      	* name-lookup.h (enum scope_kind): Add 'sk_count'.
      	* name-lookup.cc (cp_binding_level_descriptor): Add missing
      	scope kinds. Add assertion that the list is up to date. Fix
      	handling of explicit_spec_p.
      
      Signed-off-by: default avatarNathaniel Shead <nathanieloshead@gmail.com>
      fe1649ee
    • Marek Polacek's avatar
      c++: fix xobj diagnostic messages · 7d397269
      Marek Polacek authored
      Diagnostics should start with a lower-case letter.
      
      gcc/cp/ChangeLog:
      
      	* decl.cc (grokdeclarator) <case cdk_function>: Tweak diagnostic
      	messages.
      7d397269
    • Marek Polacek's avatar
      c++: fix ICE with xobj in destructor [PR113340] · ac219d52
      Marek Polacek authored
      Here we crash in maybe_retrofit_in_chrg on an invalid dtor
      with explicit this.  Such member functions do not get converted
      to METHOD_TYPE.  If a dtor gets parameters, we reset arg_types
      to void_list_node in grokdeclarator.  This results in m_r_in_c
      receiving:
        void <T8d> (void)
      and crashing on
        parms = DECL_CHAIN (DECL_ARGUMENTS (fn));
      
      This patch avoids the ICE by resetting is_xobj_member_function after
      emitting the error.  Then m_r_in_c gets
        void S::<T40b> (struct S *)
      which does not cause a crash.
      
      	PR c++/113340
      
      gcc/cp/ChangeLog:
      
      	* decl.cc (grokdeclarator) <case cdk_function>: Clear
      	is_xobj_member_function in case of an error.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp23/explicit-obj-diagnostics9.C: New test.
      ac219d52
    • John David Anglin's avatar
      Add hppa*-*-hpux* to targets which do not support split DWARF · 6a6f338c
      John David Anglin authored
      2024-01-16  John David Anglin  <danglin@gcc.gnu.org>
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/pr111409.c: Add hppa*-*-hpux* to targets which do
      	not support split DWARF.
      6a6f338c
    • waffl3x's avatar
      c++: reject packs on xobj params [PR113307] · 6aae831a
      waffl3x authored
      
      Reject and diagnose xobj parameters declared as parameter packs.
      
      	PR c++/113307
      
      gcc/cp/ChangeLog:
      
      	* parser.cc (cp_parser_parameter_declaration): Reject packs
      	on xobj params.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp23/explicit-obj-diagnostics3.C: Add test for
      	rejection of packs.
      
      Signed-off-by: default avatarWaffl3x <waffl3x@protonmail.com>
      6aae831a
    • John David Anglin's avatar
      Add .data.rel.ro.local to read only sections in gcc.dg/array-quals-1.c · 075f2cc2
      John David Anglin authored
      2024-01-16  John David Anglin  <danglin@gcc.gnu.org>
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/array-quals-1.c: Add .data.rel.ro.local to read only
      	sections.
      075f2cc2
    • John David Anglin's avatar
      Remove xfail for hppa*-*-hpux* from stdatomic-flag.c and stdatomic-flag-2.c · 21836718
      John David Anglin authored
      Tests now pass on hppa64-hp-hpux11.11.
      
      2024-01-16  John David Anglin  <danglin@gcc.gnu.org>
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/atomic/stdatomic-flag.c: Remove xfail.
      	* gcc.dg/atomic/stdatomic-flag-2.c: Likewise.
      21836718
    • John David Anglin's avatar
      xfail scan-tree-dump-not throw in g++.dg/pr99966.C on hppa*64*-*-* · dc5fc15d
      John David Anglin authored
      2024-01-16  John David Anglin  <danglin@gcc.gnu.org>
      
      gcc/testsuite/ChangeLog:
      
      	PR tree-optimization/110794
      	* g++.dg/pr99966.C: xfail scan-tree-dump-not throw on hppa*64*-*-*.
      dc5fc15d
    • John David Anglin's avatar
      Require target lto in several tests · 2194fc8f
      John David Anglin authored
      2024-01-16  John David Anglin  <danglin@gcc.gnu.org>
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/c23-tag-alias-2.c: Require target lto.
      	* gcc.dg/c23-tag-alias-3.c: Likewise.
      	* gcc.dg/gnu23-tag-alias-3.c: Likewise.
      	* gcc.dg/scantest-lto.c: Likewise.
      2194fc8f
    • John David Anglin's avatar
      Skip various cmp-mem-const tests on lp64 hppa*-*-* · b31a35b8
      John David Anglin authored
      Prior optimization already reduced the constant.
      
      2024-01-16  John David Anglin  <danglin@gcc.gnu.org>
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/cmp-mem-const-3.c: Skip on lp64 hppa*-*-*.
      	* gcc.dg/cmp-mem-const-4.c: Likewise.
      	* gcc.dg/cmp-mem-const-5.c: Likewise.
      	* gcc.dg/cmp-mem-const-6.c: Likewise.
      b31a35b8
    • John David Anglin's avatar
      xfail all scan-tree-dump-times checks on hppa*64*-*-* in sra-17.c and sra-18.c · 3867dfc3
      John David Anglin authored
      2024-01-64  John David Anglin  <danglin@gcc.gnu.org>
      
      gcc/testsuite/ChangeLog:
      
      	PR tree-optimization/91624
      	* gcc.dg/tree-ssa/sra-17.c: xfail all scan-tree-dump-times
      	checks on hppa*64*-*-*.
      	* gcc.dg/tree-ssa/sra-18.c: Likewise.
      3867dfc3
    • Wilco Dijkstra's avatar
      AArch64: Add -mcpu=cobalt-100 · a0d16e1c
      Wilco Dijkstra authored
      Add support for -mcpu=cobalt-100 (Neoverse N2 with a different implementer ID).
      
      gcc/ChangeLog:
      	* config/aarch64/aarch64-cores.def (AARCH64_CORE): Add 'cobalt-100' CPU.
      	* config/aarch64/aarch64-tune.md: Regenerated.
      	* doc/invoke.texi (-mcpu): Add cobalt-100 core.
      a0d16e1c
    • Owen Avery's avatar
      gccrs: Adjust item kind enums for TupleStructItems and TuplePatternItems · e621b174
      Owen Avery authored
      
      gcc/rust/ChangeLog:
      
      	* hir/tree/rust-hir-pattern.h
      	(TupleStructItems::ItemType::RANGE): Rename to...
      	(TupleStructItems::ItemType::RANGED): ...here.
      	(TupleStructItems::ItemType::NO_RANGE): Rename to...
      	(TupleStructItems::ItemType::MULTIPLE): ...here.
      
      	(TuplePatternItems::TuplePatternItemType): Rename to...
      	(TuplePatternItems::ItemType): ...here.
      
      	: Handle renames.
      
      	* backend/rust-compile-pattern.cc: Likewise.
      	* typecheck/rust-hir-type-check-pattern.cc: Likewise.
      	* checks/errors/borrowck/rust-bir-builder-pattern.h: Likewise.
      
      Signed-off-by: default avatarOwen Avery <powerboat9.gamer@gmail.com>
      e621b174
    • Pierre-Emmanuel Patry's avatar
      gccrs: Add a new test for float disambiguation · 4e554b0d
      Pierre-Emmanuel Patry authored
      
      This new regression test highlight the behavior fixed for float
      disambiguation with empty floating point.
      
      gcc/testsuite/ChangeLog:
      
      	* rust/compile/tuple_float_index.rs: New test.
      
      Signed-off-by: default avatarPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
      4e554b0d
    • Pierre-Emmanuel Patry's avatar
      gccrs: Fix float lexing and tuple index disambiguation · 348f028f
      Pierre-Emmanuel Patry authored
      
      When a float has a floating point but no value after it, a zero was added
      this lead to errors when trying to disambiguate a float into a tuple
      index.
      
      gcc/rust/ChangeLog:
      
      	* lex/rust-lex.cc (Lexer::parse_decimal_int_or_float): Remove
      	additional zero after empty floating point.
      	* parse/rust-parse-impl.h (Parser::left_denotation): Handle float with
      	empty floating point.
      
      Signed-off-by: default avatarPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
      348f028f
    • Raiki Tamura's avatar
      gccrs: v0-mangle closures · 4bd9f115
      Raiki Tamura authored
      
      gcc/rust/ChangeLog:
      
      	* backend/rust-compile-expr.cc (CompileExpr::generate_closure_function):
      	Fix reference to node.
      	* backend/rust-mangle.cc (struct V0Path): Modified to accept closures.
      	(v0_crate_path): Modified to accept closures.
      	(v0_closure): New function to mangle closures.
      	(v0_path): Modified to accept closures
      	* util/rust-mapping-common.h (UNKNOWN_NODEID): Change to UINT32_MAX.
      	(UNKNOWN_HIRID): Change to UINT32_MAX.
      
      gcc/testsuite/ChangeLog:
      
      	* rust/compile/v0-mangle2.rs: New test.
      
      Signed-off-by: default avatarRaiki Tamura <tamaron1203@gmail.com>
      4bd9f115
    • Pierre-Emmanuel Patry's avatar
      gccrs: Move default visitor templates to header · 4011a8b5
      Pierre-Emmanuel Patry authored
      
      Move default ast visitor template implementation to headers in order to
      match the codebase and avoid link errors.
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Move from here...
      	* ast/rust-ast-visitor.h: ... to here.
      
      Signed-off-by: default avatarPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
      4011a8b5
    • Pierre-Emmanuel Patry's avatar
      gccrs: Move templated functions to header file · 32f16cac
      Pierre-Emmanuel Patry authored
      
      Templated functions shall remain in header files to stay in line with the
      rest of the codebase.
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-collector.cc (TokenCollector::visit): Move to header
      	file.
      	(TokenCollector::visit_items_joined_by_separator): Likewise.
      	(TokenCollector::visit_as_line): Likewise.
      	(TokenCollector::visit_items_as_lines): Likewise.
      	(TokenCollector::visit_items_as_block): Likewise.
      	* ast/rust-ast-collector.h: Add implementation.
      
      Signed-off-by: default avatarPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
      32f16cac
    • Pierre-Emmanuel Patry's avatar
      gccrs: Rework function special parameters · 513b0154
      Pierre-Emmanuel Patry authored
      
      Make self param and variadic param Param, introduce Param class and make
      function parameters param too.
      Self can now be represented as a standard parameter and is thus no longer
      required as a separate function attribute.
      Prevent self pointers and allow self in standard functions during parsing
      so they could be rejected at a later stage.
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-collector.cc (TokenCollector::visit): Add visitor for
      	VariadicParam and remove Self parameter visitor from Function visit.
      	* expand/rust-cfg-strip.cc (CfgStrip::maybe_strip_self_param): Remove
      	function.
      	(CfgStrip::maybe_strip_trait_method_decl): Remove self parameter visit.
      	(CfgStrip::maybe_strip_function_params): Handle new function
      	parameters.
      	(CfgStrip::visit): Handle VariadicParam, SelfParam and FunctionParam.
      	* expand/rust-expand-visitor.cc (ExpandVisitor::expand_self_param):
      	Remove function.
      	(ExpandVisitor::expand_trait_method_decl): Do not visit self parameter.
      	(ExpandVisitor::visit): Add visit for VariadicParam, FunctionParam and
      	SelfParam.
      	(ExpandVisitor::expand_function_params): Visit parameters instead.
      	* expand/rust-expand-visitor.h: Update function prototypes.
      	* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Update visit
      	with new parameters.
      	(ResolveTraitItems::visit): Likewise.
      	* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
      	Update visit functions with the new visitor functions for VariadicParam
      	SelfParam and FunctionParam.
      	* resolve/rust-early-name-resolver.h: Update function prototypes.
      	* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Update visitor
      	according to the new function parameter structures.
      	* ast/rust-ast-visitor.h: Update prototypes and add visitor virtual
      	functions for SelfParam, FunctionParam and VariadicParam.
      	* ast/rust-ast.cc (Function::Function): Move constructor in
      	implementation instead of header.
      	(Function::operator=): Likewise.
      	(Function::as_string): Update function with pointer dereference.
      	(VariadicParam::as_string): Likewise.
      	(TraitFunctionDecl::as_string): Likewise.
      	(TraitMethodDecl::as_string): Likewise.
      	(FunctionParam::accept_vis): Add function for visitor.
      	(SelfParam::accept_vis): Likewise.
      	(VariadicParam::accept_vis): Likewise.
      	(TraitItemFunc::TraitItemFunc): Move constructor to implementation
      	file.
      	(TraitItemFunc::operator=): Likewise.
      	(TraitItemMethod::TraitItemMethod): Likewise.
      	(TraitItemMethod::operator=): Likewise.
      	* ast/rust-item.h (class Function): Remove self optional member.
      	(class TraitMethodDecl): Likewise.
      	(class TraitFunctionDecl): Likewise.
      	(class Param): Add abstract parameter class.
      	(class SelfParam): Inherit from Param and remove parameter common
      	members.
      	(class FunctionParam): Likewise.
      	(class VariadicParam): Likewise.
      	(struct Visibility): Move structure declaration.
      	(class VisItem):  Likewise.
      	* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add
      	a self parameter check during AST validation.
      	* checks/errors/rust-ast-validation.h: Add function prototype.
      	* expand/rust-derive-clone.cc (DeriveClone::clone_fn): Update function
      	constructor.
      	* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_self): Rework
      	function for the new parameters.
      	(ASTLoweringBase::visit): Add visit functions for VariadicParam,
      	FunctionParam and SelfParam.
      	* hir/rust-ast-lower-base.h: Update function prototypes.
      	* parse/rust-parse-impl.h (Parser::parse_function): Update function
      	according to new function representation.
      	(Parser::parse_function_param): Return vector of abstract param instead
      	of FunctionParam.
      	(Parser::parse_method): Update according to new representation.
      	(Parser::parse_trait_item): Likewise.
      	(Parser::parse_self_param): Error out with
      	self pointers and prevent the lexer from eating regular function
      	parameters. Update return type.
      	* parse/rust-parse.h: Update function return types.
      	* ast/rust-ast-collector.h: Add VariadicParam visit prototype.
      	* ast/rust-ast.h (struct Visibility): Move struct declaration.
      	(class VisItem): Likewise.
      	* ast/rust-expr.h: Update included files.
      	* checks/errors/rust-feature-gate.h: Add visitor functions for
      	SelfParam, FunctionParam and VariadicParam.
      	* expand/rust-cfg-strip.h: Update function prototypes.
      	* expand/rust-derive.h: Likewise.
      	* hir/rust-ast-lower-implitem.h: Handle special arguments.
      	* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Likewise.
      	* metadata/rust-export-metadata.cc (ExportContext::emit_function):
      	Likewise.
      	* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add visitor
      	functions.
      	* resolve/rust-ast-resolve-base.h: Update prototypes.
      	* resolve/rust-ast-resolve-stmt.h: Handle new parameter kind.
      	* resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise.
      	* resolve/rust-default-resolver.h: Update prototype.
      	* util/rust-attributes.cc (AttributeChecker::visit): Add visitor
      	functions for SelfParam and VariadicParam.
      	* util/rust-attributes.h: Add visit prototypes.
      
      Signed-off-by: default avatarPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
      513b0154
    • Pierre-Emmanuel Patry's avatar
      gccrs: Add new test for invalid variadics · bbb24725
      Pierre-Emmanuel Patry authored
      
      Highlight invalid variadic filtering through the ast validation checker.
      
      gcc/testsuite/ChangeLog:
      
      	* rust/compile/invalid_variadics.rs: New test.
      
      Signed-off-by: default avatarPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
      bbb24725
    • Pierre-Emmanuel Patry's avatar
      gccrs: Add multiple check on variadics position · e92ae55f
      Pierre-Emmanuel Patry authored
      
      Variadics are forbidden alone as well as non final position, this should
      be checked during ast validation.
      
      gcc/rust/ChangeLog:
      
      	* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add
      	check for additional named argument as well as variadic argument's
      	position.
      	* checks/errors/rust-ast-validation.h: Add visit function prototype for
      	external functions.
      
      Signed-off-by: default avatarPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
      e92ae55f
    • Pierre-Emmanuel Patry's avatar
      gccrs: Add trait context to ContextualASTVisitor · c1d722aa
      Pierre-Emmanuel Patry authored
      
      Some construct are forbidden in trait context (eg. pub, async...) and
      we'll need to reject those. To do so we need to identify a trait context.
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-visitor.cc (ContextualASTVisitor::visit): Push the new
      	trait context when visiting a trait.
      	* ast/rust-ast-visitor.h: Add visit function prototype and TRAIT
      	context.
      
      Signed-off-by: default avatarPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
      c1d722aa
    • Pierre-Emmanuel Patry's avatar
      gccrs: Add regression test for invalid label name · 119e0be8
      Pierre-Emmanuel Patry authored
      
      An error message should be emitted when the rust code contains invalid
      label name. Add a new test for this behavior.
      
      gcc/testsuite/ChangeLog:
      
      	* rust/compile/invalid_label_name.rs: New test.
      
      Signed-off-by: default avatarPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
      119e0be8
    • Pierre-Emmanuel Patry's avatar
      gccrs: Change error location for LoopLabel · 66fc33f6
      Pierre-Emmanuel Patry authored
      
      Loop label error reporting during ast validation was done at loop label
      level. It lead to some innacurate error reporting in break loop labels
      due to the way the label is built.
      
      gcc/rust/ChangeLog:
      
      	* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Change
      	reported error location to the lifetime location.
      
      Signed-off-by: default avatarPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
      66fc33f6
    • Pierre-Emmanuel Patry's avatar
      gccrs: Add validation pass for label name · 93ca83c5
      Pierre-Emmanuel Patry authored
      
      Prevent from using reserved keyword in label name.
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Check if there is
      	a label before visit.
      	* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Emit an
      	error when a label has a forbidden name.
      	* checks/errors/rust-ast-validation.h: Add function prototype.
      
      Signed-off-by: default avatarPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
      93ca83c5
Loading