]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
16 months agoMerge commit 'f7884f7673444b8a2c10ea0981d480f2e82dd16a'; commit 'adb56ef014effb17af27...
Thomas Schwinge [Tue, 19 Mar 2024 15:42:45 +0000 (16:42 +0100)] 
Merge commit 'f7884f7673444b8a2c10ea0981d480f2e82dd16a'; commit 'adb56ef014effb17af27ab7baf0d87bc8bc48a0c' into HEAD [#2916]

Merge "macro: Use MacroInvocation's node_id in ExternalItem constructor", to
avoid bootstrap failure:

    [...]
    In file included from [...]/source-gcc/gcc/rust/ast/rust-expr.h:6,
                     from [...]/source-gcc/gcc/rust/ast/rust-ast-full.h:24,
                     from [...]/source-gcc/gcc/rust/ast/rust-ast.cc:24:
    In copy constructor ‘Rust::AST::MacroInvocation::MacroInvocation(const Rust::AST::MacroInvocation&)’,
        inlined from ‘Rust::AST::MacroInvocation* Rust::AST::MacroInvocation::clone_macro_invocation_impl() const’ at [...]/source-gcc/gcc/rust/ast/rust-\
    macro.h:798:38:
    [...]/source-gcc/gcc/rust/ast/rust-macro.h:734:39: error: ‘*(Rust::AST::MacroInvocation*)<unknown>.Rust::AST::MacroInvocation::Rust::AST::ExprWithout\
    Block.Rust::AST::ExprWithoutBlock::Rust::AST::Expr.Rust::AST::Expr::node_id’ is used uninitialized [-Werror=uninitialized]
      734 |       builtin_kind (other.builtin_kind)
          |                                       ^
    cc1plus: all warnings being treated as errors
    make[3]: *** [[...]/source-gcc/gcc/rust/Make-lang.in:423: rust/rust-ast.o] Error 1
    [...]
    In file included from [...]/source-gcc/gcc/rust/ast/rust-expr.h:6,
                     from [...]/source-gcc/gcc/rust/ast/rust-item.h:27,
                     from [...]/source-gcc/gcc/rust/parse/rust-parse.h:20,
                     from [...]/source-gcc/gcc/rust/expand/rust-macro-expand.h:24,
                     from [...]/source-gcc/gcc/rust/expand/rust-macro-expand.cc:19:
    In copy constructor ‘Rust::AST::MacroInvocation::MacroInvocation(const Rust::AST::MacroInvocation&)’,
        inlined from ‘Rust::AST::MacroInvocation* Rust::AST::MacroInvocation::clone_macro_invocation_impl() const’ at [...]/source-gcc/gcc/rust/ast/rust-\
    macro.h:798:38:
    [...]/source-gcc/gcc/rust/ast/rust-macro.h:734:39: error: ‘*(Rust::AST::MacroInvocation*)<unknown>.Rust::AST::MacroInvocation::Rust::AST::ExprWithout\
    Block.Rust::AST::ExprWithoutBlock::Rust::AST::Expr.Rust::AST::Expr::node_id’ is used uninitialized [-Werror=uninitialized]
      734 |       builtin_kind (other.builtin_kind)
          |                                       ^
    cc1plus: all warnings being treated as errors
    make[3]: *** [[...]/source-gcc/gcc/rust/Make-lang.in:433: rust/rust-macro-expand.o] Error 1
    [...]

16 months agoMerge commit 'f7884f7673444b8a2c10ea0981d480f2e82dd16a^' into HEAD
Thomas Schwinge [Tue, 19 Mar 2024 15:37:35 +0000 (16:37 +0100)] 
Merge commit 'f7884f7673444b8a2c10ea0981d480f2e82dd16a^' into HEAD

16 months agomacro: Use MacroInvocation's node_id in ExternalItem constructor.
Arthur Cohen [Tue, 19 Mar 2024 12:12:20 +0000 (13:12 +0100)] 
macro: Use MacroInvocation's node_id in ExternalItem constructor.

gcc/rust/ChangeLog:

* ast/rust-macro.h: Use proper node id instead of the one in the base
Expr class - which is uninitialized.

16 months agotree-optimization/112653 - PTA and return
Richard Biener [Mon, 27 Nov 2023 09:20:02 +0000 (10:20 +0100)] 
tree-optimization/112653 - PTA and return

The following separates the escape solution for return stmts not
only during points-to solving but also for later querying.  This
requires adjusting the points-to-global tests to include escapes
through returns.  Technically the patch replaces the existing
post-processing which computes the transitive closure of the
returned value solution by a proper artificial variable with
transitive closure constraints.  Instead of adding the solution
to escaped we track it separately.

PR tree-optimization/112653
* gimple-ssa.h (gimple_df): Add escaped_return solution.
* tree-ssa.cc (init_tree_ssa): Reset it.
(delete_tree_ssa): Likewise.
* tree-ssa-structalias.cc (escaped_return_id): New.
(find_func_aliases): Handle non-IPA return stmts by
adding to ESCAPED_RETURN.
(set_uids_in_ptset): Adjust HEAP escaping to also cover
escapes through return.
(init_base_vars): Initialize ESCAPED_RETURN.
(compute_points_to_sets): Replace ESCAPED post-processing
with recording the ESCAPED_RETURN solution.
* tree-ssa-alias.cc (ref_may_alias_global_p_1): Check
the ESCAPED_RETUNR solution.
(dump_alias_info): Dump it.
* cfgexpand.cc (update_alias_info_with_stack_vars): Update it.
* ipa-icf.cc (sem_item_optimizer::fixup_points_to_sets):
Likewise.
* tree-inline.cc (expand_call_inline): Reset it.
* tree-parloops.cc (parallelize_loops): Likewise.
* tree-sra.cc (maybe_add_sra_candidate): Check it.

* gcc.dg/tree-ssa/pta-return-1.c: New testcase.

(cherry picked from commit f7884f7673444b8a2c10ea0981d480f2e82dd16a)

16 months agosra: SRA of non-escaped aggregates passed by reference to calls
Martin Jambor [Fri, 24 Nov 2023 16:32:35 +0000 (17:32 +0100)] 
sra: SRA of non-escaped aggregates passed by reference to calls

PR109849 shows that a loop that heavily pushes and pops from a stack
implemented by a C++ std::vec results in slow code, mainly because the
vector structure is not split by SRA and so we end up in many loads
and stores into it.  This is because it is passed by reference
to (re)allocation methods and so needs to live in memory, even though
it does not escape from them and so we could SRA it if we
re-constructed it before the call and then separated it to distinct
replacements afterwards.

This patch does exactly that, first relaxing the selection of
candidates to also include those which are addressable but do not
escape and then adding code to deal with the calls.  The
micro-benchmark that is also the (scan-dump) testcase in this patch
runs twice as fast with it than with current trunk.  Honza measured
its effect on the libjxl benchmark and it almost closes the
performance gap between Clang and GCC while not requiring excessive
inlining and thus code growth.

The patch disallows creation of replacements for such aggregates which
are also accessed with a precision smaller than their size because I
have observed that this led to excessive zero-extending of data
leading to slow-downs of perlbench (on some CPUs).  Apart from this
case I have not noticed any regressions, at least not so far.

Gimple call argument flags can tell if an argument is unused (and then
we do not need to generate any statements for it) or if it is not
written to and then we do not need to generate statements loading
replacements from the original aggregate after the call statement.
Unfortunately, we cannot symmetrically use flags that an aggregate is
not read because to avoid re-constructing the aggregate before the
call because flags don't tell which what parts of aggregates were not
written to, so we load all replacements, and so all need to have the
correct value before the call.

This version of the patch also takes care to avoid attempts to modify
abnormal edges, something which was missing in the previosu version.

gcc/ChangeLog:

2023-11-23  Martin Jambor  <mjambor@suse.cz>

PR middle-end/109849
* tree-sra.cc (passed_by_ref_in_call): New.
(sra_initialize): Allocate passed_by_ref_in_call.
(sra_deinitialize): Free passed_by_ref_in_call.
(create_access): Add decl pool candidates only if they are not
already candidates.
(build_access_from_expr_1): Bail out on ADDR_EXPRs.
(build_access_from_call_arg): New function.
(asm_visit_addr): Rename to scan_visit_addr, change the
disqualification dump message.
(scan_function): Check taken addresses for all non-call statements,
including phi nodes.  Process all call arguments, including the static
chain, build_access_from_call_arg.
(maybe_add_sra_candidate): Relax need_to_live_in_memory check to allow
non-escaped local variables.
(sort_and_splice_var_accesses): Disallow smaller-than-precision
replacements for aggregates passed by reference to functions.
(sra_modify_expr): Use a separate stmt iterator for adding satements
before the processed statement and after it.
(enum out_edge_check): New type.
(abnormal_edge_after_stmt_p): New function.
(sra_modify_call_arg): New function.
(sra_modify_assign): Adjust calls to sra_modify_expr.
(sra_modify_function_body): Likewise, use sra_modify_call_arg to
process call arguments, including the static chain.

gcc/testsuite/ChangeLog:

2023-11-23  Martin Jambor  <mjambor@suse.cz>

PR middle-end/109849
* g++.dg/tree-ssa/pr109849.C: New test.
* g++.dg/tree-ssa/sra-eh-1.C: Likewise.
* gcc.dg/tree-ssa/pr109849.c: Likewise.
* gcc.dg/tree-ssa/sra-longjmp-1.c: Likewise.
* gfortran.dg/pr43984.f90: Added -fno-tree-sra to dg-options.

(cherry picked from commit aae723d360ca26cd9fd0b039fb0a616bd0eae363)

16 months agoMerge commit '56ca59a03150cf44cea340f58967c990ed6bf43c' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 23:10:10 +0000 (00:10 +0100)] 
Merge commit '56ca59a03150cf44cea340f58967c990ed6bf43c' into HEAD

16 months agoMerge commit '56ca59a03150cf44cea340f58967c990ed6bf43c^' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 23:10:04 +0000 (00:10 +0100)] 
Merge commit '56ca59a03150cf44cea340f58967c990ed6bf43c^' into HEAD

16 months agoMerge commit 'db50aea62595452db12565186cb520728540d987' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 23:06:54 +0000 (00:06 +0100)] 
Merge commit 'db50aea62595452db12565186cb520728540d987' into HEAD

16 months agoMerge commit 'db50aea62595452db12565186cb520728540d987^' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 22:57:22 +0000 (23:57 +0100)] 
Merge commit 'db50aea62595452db12565186cb520728540d987^' into HEAD

16 months agoMerge commit '4968e4844a3ce30143ae2e267895c418f5c636a1' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 22:55:02 +0000 (23:55 +0100)] 
Merge commit '4968e4844a3ce30143ae2e267895c418f5c636a1' into HEAD

16 months agoMerge commit '28064d6430f3fa71e79d11ac9d4bf3e6adf52145' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 22:54:33 +0000 (23:54 +0100)] 
Merge commit '28064d6430f3fa71e79d11ac9d4bf3e6adf52145' into HEAD

16 months agoRevert "Add files to discourage submissions of PRs to the GitHub mirror."
Thomas Schwinge [Sat, 16 Mar 2024 22:32:57 +0000 (23:32 +0100)] 
Revert "Add files to discourage submissions of PRs to the GitHub mirror."

This is not applicable for GCC/Rust, which does use GitHub.

This reverts commit 2b9778c8d9d33174de63716b74b2f114d700e104.

16 months agoMerge commit '2b9778c8d9d33174de63716b74b2f114d700e104^' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 22:32:07 +0000 (23:32 +0100)] 
Merge commit '2b9778c8d9d33174de63716b74b2f114d700e104^' into HEAD

16 months agoMerge commit '6a6d3817afa02bbcd2388c8e005da6faf88932f1' into HEAD [#2714]
Thomas Schwinge [Sat, 16 Mar 2024 22:06:45 +0000 (23:06 +0100)] 
Merge commit '6a6d3817afa02bbcd2388c8e005da6faf88932f1' into HEAD [#2714]

16 months agoMerge commit '6a6d3817afa02bbcd2388c8e005da6faf88932f1^' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 22:03:21 +0000 (23:03 +0100)] 
Merge commit '6a6d3817afa02bbcd2388c8e005da6faf88932f1^' into HEAD

16 months agoReplace unique_ptr references with references
Pierre-Emmanuel Patry [Thu, 22 Feb 2024 17:55:53 +0000 (18:55 +0100)] 
Replace unique_ptr references with references

This kind of double indirection is pointless and prone to error. This
commit change the api of all getters from the AST to use references
directly instead of references to unique pointers.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Remove reference
to unique pointer and replace it with a direct reference to the wrapped
data.
* ast/rust-ast.cc (VariadicParam::as_string): Likewise.
(BlockExpr::normalize_tail_expr): Likewise.
* ast/rust-expr.h: Likewise and add pointer getter in order to allow
pointer reseat.
* ast/rust-item.h: Likewise and add pointer getter for reseat.
* ast/rust-path.h: Likewise.
* ast/rust-pattern.h: Likewise.
* ast/rust-stmt.h: Likewise.
* ast/rust-type.h: Likewise.
* expand/rust-cfg-strip.cc (CfgStrip::maybe_strip_struct_fields):
Remove references to unique pointers and replace it with direct
references to the wrapped object.
(CfgStrip::maybe_strip_tuple_fields): Likewise.
(CfgStrip::maybe_strip_generic_args): Likewise.
(CfgStrip::maybe_strip_qualified_path_type): Likewise.
(CfgStrip::visit): Likewise.
* expand/rust-expand-visitor.cc (ExpandVisitor::maybe_expand_expr):
Likewise.
(ExpandVisitor::maybe_expand_type): Likewise.
(ExpandVisitor::visit): Likewise.
* expand/rust-expand-visitor.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_binding):
Likewise.
(ASTLoweringBase::lower_generic_args): Likewise.
(ASTLoweringBase::lower_self): Likewise.
(ASTLoweringBase::lower_type_no_bounds): Likewise.
(ASTLoweringBase::lower_bound): Likewise.
(ASTLoweringBase::lower_range_pattern_bound): Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-block.h: Likewise.
* hir/rust-ast-lower-enumitem.h: Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::translate): Likewise.
(ASTLoweringExpr::visit): Likewise.
* hir/rust-ast-lower-expr.h: Likewise.
* hir/rust-ast-lower-extern.h: Likewise.
* hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::translate):
Likewise.
(ASTLowerImplItem::visit): Likewise.
(ASTLowerTraitItem::translate): Likewise.
(ASTLowerTraitItem::visit): Likewise.
* hir/rust-ast-lower-implitem.h: Likewise.
* hir/rust-ast-lower-item.cc (ASTLoweringItem::translate): Likewise.
(ASTLoweringItem::visit): Likewise.
* hir/rust-ast-lower-item.h: Likewise.
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate):
Likewise.
(ASTLoweringPattern::visit): Likewise.
* hir/rust-ast-lower-pattern.h: Likewise.
* hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Likewise.
* hir/rust-ast-lower-struct-field-expr.h: Likewise.
* hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Likewise.
(ASTLowerQualifiedPathInType::visit): Likewise.
(ASTLoweringType::translate): Likewise.
(ASTLoweringType::visit): Likewise.
(ASTLowerGenericParam::translate): Likewise.
(ASTLowerGenericParam::visit): Likewise.
(ASTLoweringTypeBounds::translate): Likewise.
(ASTLoweringTypeBounds::visit): Likewise.
(ASTLowerWhereClauseItem::visit): Likewise.
* hir/rust-ast-lower-type.h: Likewise.
* hir/rust-ast-lower.cc (ASTLowering::go): Likewise.
(ASTLoweringBlock::visit): Likewise.
(ASTLoweringIfBlock::visit): Likewise.
(ASTLoweringIfLetBlock::visit): Likewise.
(ASTLowerStructExprField::visit): Likewise.
(ASTLoweringExprWithBlock::visit): Likewise.
(ASTLoweringBase::lower_qual_path_type): Likewise.
(ASTLoweringBase::lower_closure_param): Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::resolve_visibility):
Likewise.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::go): Likewise.
(ResolveExpr::visit): Likewise.
(ResolveExpr::resolve_closure_param): Likewise.
* resolve/rust-ast-resolve-expr.h: Likewise.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit):
Likewise.
(ResolveItem::go): Likewise.
(ResolveItem::visit): Likewise.
(ResolveItem::resolve_impl_item): Likewise.
(ResolveItem::resolve_extern_item): Likewise.
(ResolveImplItems::go): Likewise.
(ResolveExternItem::go): Likewise.
(ResolveExternItem::visit): Likewise.
* resolve/rust-ast-resolve-item.h: Likewise.
* resolve/rust-ast-resolve-path.cc (ResolvePath::go): Likewise.
(ResolvePath::resolve_path): Likewise.
* resolve/rust-ast-resolve-path.h: Likewise.
* resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::go):
Likewise.
(PatternDeclaration::visit): Likewise.
(resolve_range_pattern_bound): Likewise.
* resolve/rust-ast-resolve-pattern.h: Likewise.
* resolve/rust-ast-resolve-stmt.cc (ResolveStmt::visit): Likewise.
* resolve/rust-ast-resolve-stmt.h: Likewise.
* resolve/rust-ast-resolve-struct-expr-field.cc (ResolveStructExprField::go):
Likewise.
(ResolveStructExprField::visit): Likewise.
* resolve/rust-ast-resolve-struct-expr-field.h: Likewise.
* resolve/rust-ast-resolve-toplevel.h: Likewise.
* resolve/rust-ast-resolve-type.cc (ResolveType::visit): Likewise.
(ResolveRelativeTypePath::go): Likewise.
(ResolveRelativeQualTypePath::resolve_qual_seg): Likewise.
(ResolveTypeToCanonicalPath::go): Likewise.
(ResolveTypeToCanonicalPath::visit): Likewise.
(ResolveGenericArgs::resolve_disambiguated_generic): Likewise.
(ResolveGenericArgs::go): Likewise.
* resolve/rust-ast-resolve-type.h: Likewise.
* resolve/rust-ast-resolve.cc (NameResolution::go): Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::resolve_qualified_path_type):
Likewise.
(EarlyNameResolver::visit): Likewise.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Likewise.
* checks/errors/rust-ast-validation.cc: Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoReplace reference to unique pointer with reference
Pierre-Emmanuel Patry [Wed, 21 Feb 2024 15:45:18 +0000 (16:45 +0100)] 
Replace reference to unique pointer with reference

Reference to unique pointers are a known anti pattern, only the element
shall be taken by reference instead of the whole wrapper.

gcc/rust/ChangeLog:

* ast/rust-item.h: Change getter function prototype to return a
reference directly instead of a reference to the wrapper type.
* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Fix
the code to accept references instead.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_self): Change
function implementation to return a reference.
* hir/rust-ast-lower-base.h: Accept a reference instead of a unique
pointer reference.
* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Adapt the code
to a reference instead of a unique pointer.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoMerge commit '1a9974d08bc1478a98f52b2ea95475a583747724' into HEAD [#2912]
Thomas Schwinge [Tue, 12 Mar 2024 08:41:55 +0000 (09:41 +0100)] 
Merge commit '1a9974d08bc1478a98f52b2ea95475a583747724' into HEAD [#2912]

16 months agoPlacate clang-format re 'gcc/rust/backend/rust-tree.cc'
Thomas Schwinge [Tue, 12 Mar 2024 08:36:43 +0000 (09:36 +0100)] 
Placate clang-format re 'gcc/rust/backend/rust-tree.cc'

Reformat the upstream GCC commit f4a2ae2338962208b8039f154f5912402e94c378
"Change MODE_BITSIZE to MODE_PRECISION for MODE_VECTOR_BOOL" change to
'gcc/rust/backend/rust-tree.cc' to clang-format's liking.

gcc/rust/
* backend/rust-tree.cc (c_common_type_for_mode): Placate clang-format.

16 months agoAdjust '.github/bors_log_expected_warnings'
Thomas Schwinge [Mon, 11 Mar 2024 22:44:18 +0000 (23:44 +0100)] 
Adjust '.github/bors_log_expected_warnings'

16 months agocse: Workaround GCC < 5 bug in cse_insn [PR111852]
Jakub Jelinek [Wed, 18 Oct 2023 15:01:26 +0000 (17:01 +0200)] 
cse: Workaround GCC < 5 bug in cse_insn [PR111852]

Before the r5-3834 commit for PR63362, GCC 4.8-4.9 refuses to compile
cse.cc which contains a variable with rtx_def type, because rtx_def
contains a union with poly_uint16 element.  poly_int template has
defaulted default constructor and a variadic template constructor which
could have empty parameter pack. GCC < 5 treated it as non-trivially
constructible class and deleted rtunion and rtx_def default constructors.

For the cse_insn purposes, all we need is a variable with size and alignment
of rtx_def, not necessarily rtx_def itself, which we then memset to 0 and
fill in like rtx is normally allocated from heap, so this patch for
GCC_VERSION < 5000 uses an unsigned char array of the right size/alignment.

2023-10-18  Jakub Jelinek  <jakub@redhat.com>

PR bootstrap/111852
* cse.cc (cse_insn): Add workaround for GCC 4.8-4.9, instead of
using rtx_def type for memory_extend_buf, use unsigned char
arrayy with size of rtx_def and its alignment.

(cherry picked from commit bc4bd69faf986326f6b0fd0400cdd6871577afd1)

16 months agoMerge commit 'af4bb221153359f5948da917d5ef2df738bb1e61' into HEAD
Thomas Schwinge [Mon, 11 Mar 2024 21:51:28 +0000 (22:51 +0100)] 
Merge commit 'af4bb221153359f5948da917d5ef2df738bb1e61' into HEAD

16 months agoMerge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c' into HEAD
Thomas Schwinge [Mon, 11 Mar 2024 21:43:19 +0000 (22:43 +0100)] 
Merge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c' into HEAD

16 months agoMerge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c^' into HEAD
Thomas Schwinge [Mon, 11 Mar 2024 21:38:33 +0000 (22:38 +0100)] 
Merge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c^' into HEAD

16 months agoMerge commit '7439f40dc17f47480620beadf5b2f5784b59aefe' into HEAD [#1543]
Thomas Schwinge [Mon, 11 Mar 2024 00:05:15 +0000 (01:05 +0100)] 
Merge commit '7439f40dc17f47480620beadf5b2f5784b59aefe' into HEAD [#1543]

16 months agoMerge commit 'b1c06fd9723453dd2b2ec306684cb806dc2b4fbb^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:59:26 +0000 (00:59 +0100)] 
Merge commit 'b1c06fd9723453dd2b2ec306684cb806dc2b4fbb^' into HEAD

16 months agoMerge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:58:39 +0000 (00:58 +0100)] 
Merge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc' into HEAD

16 months agoMerge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:57:51 +0000 (00:57 +0100)] 
Merge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc^' into HEAD

16 months agoMerge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:56:06 +0000 (00:56 +0100)] 
Merge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0' into HEAD

16 months agoMerge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:47:49 +0000 (00:47 +0100)] 
Merge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0^' into HEAD

16 months agoMerge commit '1aee5d2ace9ea8f35baf5b18e36caf44fe018ea3' into HEAD [#1408]
Thomas Schwinge [Sun, 10 Mar 2024 23:45:13 +0000 (00:45 +0100)] 
Merge commit '1aee5d2ace9ea8f35baf5b18e36caf44fe018ea3' into HEAD [#1408]

16 months agoMerge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704' into HEAD [#1408]
Thomas Schwinge [Sun, 10 Mar 2024 23:34:47 +0000 (00:34 +0100)] 
Merge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704' into HEAD [#1408]

16 months agoMerge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:34:22 +0000 (00:34 +0100)] 
Merge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704^' into HEAD

16 months agoMerge commit 'f3f6ff7b16861cd0651eccff14689536550762ae' into HEAD [#2414]
Thomas Schwinge [Sun, 10 Mar 2024 23:33:08 +0000 (00:33 +0100)] 
Merge commit 'f3f6ff7b16861cd0651eccff14689536550762ae' into HEAD [#2414]

16 months agoMerge commit 'f3f6ff7b16861cd0651eccff14689536550762ae^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:26:50 +0000 (00:26 +0100)] 
Merge commit 'f3f6ff7b16861cd0651eccff14689536550762ae^' into HEAD

16 months agoMerge commit 'dc17ceb3055f56aa3a59c6ef3ae32043d58502d1' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:25:25 +0000 (00:25 +0100)] 
Merge commit 'dc17ceb3055f56aa3a59c6ef3ae32043d58502d1' into HEAD

16 months agoMerge commit 'dc17ceb3055f56aa3a59c6ef3ae32043d58502d1^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:25:10 +0000 (00:25 +0100)] 
Merge commit 'dc17ceb3055f56aa3a59c6ef3ae32043d58502d1^' into HEAD

16 months agoMerge commit '9fc0ae6033f3e41c9b4605531a6a8543414b0d2d' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:24:32 +0000 (00:24 +0100)] 
Merge commit '9fc0ae6033f3e41c9b4605531a6a8543414b0d2d' into HEAD

16 months agoMerge commit '9fc0ae6033f3e41c9b4605531a6a8543414b0d2d^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:24:01 +0000 (00:24 +0100)] 
Merge commit '9fc0ae6033f3e41c9b4605531a6a8543414b0d2d^' into HEAD

16 months agoMerge commit 'ead5103cc6f526bcc5a30c8c7185e9dd5de73d55' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:21:19 +0000 (00:21 +0100)] 
Merge commit 'ead5103cc6f526bcc5a30c8c7185e9dd5de73d55' into HEAD

16 months agoMerge commit 'f330710912229678b65def1f6f52765baa3d0f7a' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:20:06 +0000 (00:20 +0100)] 
Merge commit 'f330710912229678b65def1f6f52765baa3d0f7a' into HEAD

16 months agoMerge commit 'ab422974567ae73926c2308c3400b5974d6e09f1' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:18:11 +0000 (00:18 +0100)] 
Merge commit 'ab422974567ae73926c2308c3400b5974d6e09f1' into HEAD

16 months agoMerge commit 'ab422974567ae73926c2308c3400b5974d6e09f1^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:17:15 +0000 (00:17 +0100)] 
Merge commit 'ab422974567ae73926c2308c3400b5974d6e09f1^' into HEAD

16 months agoMerge commit '9c7797a8c2d707ba4516d3d96d8dff6201476fb6' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:15:40 +0000 (00:15 +0100)] 
Merge commit '9c7797a8c2d707ba4516d3d96d8dff6201476fb6' into HEAD

16 months agoMerge commit '126f707efbb5184178701cbdc753a10fd831374e' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:58:16 +0000 (23:58 +0100)] 
Merge commit '126f707efbb5184178701cbdc753a10fd831374e' into HEAD

16 months agoMerge commit '126f707efbb5184178701cbdc753a10fd831374e^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:54:17 +0000 (23:54 +0100)] 
Merge commit '126f707efbb5184178701cbdc753a10fd831374e^' into HEAD

16 months agoMerge commit 'f4a2ae2338962208b8039f154f5912402e94c378' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:42:52 +0000 (23:42 +0100)] 
Merge commit 'f4a2ae2338962208b8039f154f5912402e94c378' into HEAD

16 months agoMerge commit 'f4a2ae2338962208b8039f154f5912402e94c378^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:42:46 +0000 (23:42 +0100)] 
Merge commit 'f4a2ae2338962208b8039f154f5912402e94c378^' into HEAD

16 months agoMerge commit '8a30775b0d3037123ee540f7b65a736ad49e05ce' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:38:46 +0000 (23:38 +0100)] 
Merge commit '8a30775b0d3037123ee540f7b65a736ad49e05ce' into HEAD

16 months agoMerge commit '8a30775b0d3037123ee540f7b65a736ad49e05ce^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:38:38 +0000 (23:38 +0100)] 
Merge commit '8a30775b0d3037123ee540f7b65a736ad49e05ce^' into HEAD

16 months agoMerge commit '33ebb0dff9bb022f1e0709e0e73faabfc3df7931' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:34:31 +0000 (23:34 +0100)] 
Merge commit '33ebb0dff9bb022f1e0709e0e73faabfc3df7931' into HEAD

16 months agoMerge commit '33ebb0dff9bb022f1e0709e0e73faabfc3df7931^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:34:09 +0000 (23:34 +0100)] 
Merge commit '33ebb0dff9bb022f1e0709e0e73faabfc3df7931^' into HEAD

16 months agoMerge commit '4f01ae3761ca1f8dd7a33b833ae30624f047ac9c' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:24:35 +0000 (23:24 +0100)] 
Merge commit '4f01ae3761ca1f8dd7a33b833ae30624f047ac9c' into HEAD

16 months agoMerge commit '4f01ae3761ca1f8dd7a33b833ae30624f047ac9c^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:22:34 +0000 (23:22 +0100)] 
Merge commit '4f01ae3761ca1f8dd7a33b833ae30624f047ac9c^' into HEAD

16 months agoMerge commit 'ea1cd66f2200839d46a8b4dc140d18c00b849c82' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:19:06 +0000 (23:19 +0100)] 
Merge commit 'ea1cd66f2200839d46a8b4dc140d18c00b849c82' into HEAD

16 months agoMerge commit 'ea1cd66f2200839d46a8b4dc140d18c00b849c82^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:18:49 +0000 (23:18 +0100)] 
Merge commit 'ea1cd66f2200839d46a8b4dc140d18c00b849c82^' into HEAD

16 months agoMerge commit 'bc45e18d433f879a02e369d027829f90f9e85724' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:16:21 +0000 (23:16 +0100)] 
Merge commit 'bc45e18d433f879a02e369d027829f90f9e85724' into HEAD

16 months agoMerge commit 'bc45e18d433f879a02e369d027829f90f9e85724^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:15:52 +0000 (23:15 +0100)] 
Merge commit 'bc45e18d433f879a02e369d027829f90f9e85724^' into HEAD

16 months agoMerge commit '0a85544e1aaeca41133ecfc438cda913dbc0f122' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 21:57:58 +0000 (22:57 +0100)] 
Merge commit '0a85544e1aaeca41133ecfc438cda913dbc0f122' into HEAD

16 months agoMerge commit '0a85544e1aaeca41133ecfc438cda913dbc0f122^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 21:56:03 +0000 (22:56 +0100)] 
Merge commit '0a85544e1aaeca41133ecfc438cda913dbc0f122^' into HEAD

17 months agoRemove dead code associated with `AST::ExternalFunctionItem`
0xn4utilus [Wed, 28 Feb 2024 14:05:30 +0000 (19:35 +0530)] 
Remove dead code associated with `AST::ExternalFunctionItem`

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit):
Remove dead code.
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-full-decls.h (class ExternalFunctionItem):
Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit):
Likewise.
* ast/rust-ast-visitor.h: Likewise.
* ast/rust-ast.cc (ExternalFunctionItem::as_string): Likewise.
(ExternalFunctionItem::accept_vis): Likewise.
* checks/errors/rust-ast-validation.cc (ASTValidation::visit):
Likewise.
* checks/errors/rust-ast-validation.h: Likewise.
* checks/errors/rust-feature-gate.h: Likewise.
* expand/rust-cfg-strip.cc (CfgStrip::visit):
Likewise.
* expand/rust-cfg-strip.h: Likewise.
* expand/rust-derive.h: Likewise.
* expand/rust-expand-visitor.cc (ExpandVisitor::visit):
Likewise.
* expand/rust-expand-visitor.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit):
Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* metadata/rust-export-metadata.cc (ExportContext::emit_function):
Likewise.
* parse/rust-parse-impl.h: Likewise.
* parse/rust-parse.h: Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit):
Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Likewise.
* resolve/rust-default-resolver.h: Likewise.
* util/rust-attributes.cc (AttributeChecker::visit): Likewise.
* util/rust-attributes.h: Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/extern_func_with_body.rs: New test.

Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
17 months agoUpdate resolver to use `AST::Function` instead of `AST::ExternalFunctionItem`
0xn4utilus [Sun, 25 Feb 2024 23:09:43 +0000 (04:39 +0530)] 
Update resolver to use `AST::Function` instead of `AST::ExternalFunctionItem`

gcc/rust/ChangeLog:

* checks/errors/rust-feature-gate.cc (FeatureGate::visit):
Check if function is_external or not.
* hir/rust-ast-lower-extern.h: Use AST::Function
instead of AST::ExternalFunctionItem.
* parse/rust-parse-impl.h (Parser::parse_external_item):
Likewise.
(Parser::parse_pattern): Fix clang format.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveExternItem::visit):
Likewise.
* resolve/rust-ast-resolve-item.h: Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Check if param has_pattern before using get_pattern.

Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
17 months agoUnify ASTValidation::visit for ExternalFunctionItem and Function
0xn4utilus [Sun, 25 Feb 2024 13:33:55 +0000 (19:03 +0530)] 
Unify ASTValidation::visit for ExternalFunctionItem and Function

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (ASTValidation::visit):
Add external function validation support. Add ErrorCode::E0130.
* parse/rust-parse-impl.h (Parser::parse_function): Parse
external functions from `parse_function`.
(Parser::parse_external_item): Clang format.
(Parser::parse_pattern): Clang format.
* parse/rust-parse.h: Add default parameter
`is_external` in `parse_function`.

Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
17 months agoAdd get_pattern_kind to Pattern
0xn4utilus [Sun, 25 Feb 2024 00:50:51 +0000 (06:20 +0530)] 
Add get_pattern_kind to Pattern

gcc/rust/ChangeLog:

* ast/rust-ast.h: Add Kind Enum to
Pattern.
* ast/rust-macro.h: Add get_pattern_kind().
* ast/rust-path.h: Likewise.
* ast/rust-pattern.h: Likewise.

Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
17 months agoAdd support for external functions
0xn4utilus [Sun, 25 Feb 2024 00:02:26 +0000 (05:32 +0530)] 
Add support for external functions

gcc/rust/ChangeLog:

* ast/rust-ast.cc (Function::Function): Add `is_external_function` field.
(Function::operator=): Likewise.
* ast/rust-ast.h: New constructor for ExternalItem.
* ast/rust-item.h (class Function): Add `is_external_function`
field. Update `get_node_id`.
* ast/rust-macro.h: Update copy constructor.

Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
17 months agoClean BiMap to use tl::optional for lookups
Sourabh Jaiswal [Fri, 1 Mar 2024 11:46:23 +0000 (19:46 +0800)] 
Clean BiMap to use tl::optional for lookups

gcc/rust/Changelog:

* expand/rust-expand-visitor.cc
(ExpandVisitor::expand_inner_items): Adjust to use has_value ()
(ExpandVisitor::expand_inner_stmts): Likewise
* expand/rust-macro-builtins.cc (builtin_macro_from_string): Likewise
(make_macro_path_str): Likewise
* util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise
* util/rust-lang-item.cc (LangItem::Parse): Adjust to return tl::optional
(LangItem::toString) Likewise
* util/rust-token-converter.cc (handle_suffix): Adjust to use value.or ()
(from_literal) Likewise
* util/bi-map.h (BiMap::lookup): Adjust to use tl::optional for
lookups

Signed-off-by: Sourabh Jaiswal <sourabhrj31@gmail.com>
17 months agoEnsure TupleStructPattern and TuplePattern have items
Owen Avery [Tue, 27 Feb 2024 21:34:23 +0000 (16:34 -0500)] 
Ensure TupleStructPattern and TuplePattern have items

Note that instances of both classes which have been
moved from will have (items == nullptr).

gcc/rust/ChangeLog:

* ast/rust-pattern.h
(class TupleStructPattern): Assert that items != nullptr.
(class TuplePattern): Likewise.
(TupleStructPattern::has_items): Remove.
(TuplePattern::has_tuple_pattern_items): Likewise.
* parse/rust-parse-impl.h
(Parser::parse_ident_leading_pattern):
Prevent construction of TupleStructPattern with
(items == nullptr).
(Parser::parse_pattern_no_alt): Likewise.
* ast/rust-ast-collector.cc
(TokenCollector::visit): Remove usage of
TupleStructPattern::has_items.
* ast/rust-ast-visitor.cc
(DefaultASTVisitor::visit): Likewise.
* resolve/rust-early-name-resolver.cc
(EarlyNameResolver::visit): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/pattern-struct.rs: Fix test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
17 months agoAdd curly brackets, formatted clang
jjasmine [Fri, 1 Mar 2024 21:40:17 +0000 (16:40 -0500)] 
Add curly brackets, formatted clang

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add error emitting

17 months agoAdd error emitting when we can't resolve id expr
jjasmine [Fri, 1 Mar 2024 10:31:15 +0000 (05:31 -0500)] 
Add error emitting when we can't resolve id expr

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add error emitting

17 months agoformat-args: Add documentation for future expansion of function
Arthur Cohen [Fri, 1 Mar 2024 14:37:45 +0000 (15:37 +0100)] 
format-args: Add documentation for future expansion of function

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Add
documentation regarding future tasks.

17 months agolower: Add base for lowering FormatArgs nodes
Arthur Cohen [Thu, 22 Feb 2024 13:59:17 +0000 (14:59 +0100)] 
lower: Add base for lowering FormatArgs nodes

gcc/rust/ChangeLog:

* Make-lang.in: Compile the new source file.
* ast/rust-ast-collector.cc (TokenCollector::visit): Error out when
visiting FormatArgs nodes.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
* ast/rust-ast.cc (FormatArgs::get_locus): New.
* ast/rust-builtin-ast-nodes.h: Improve FormatArgs API.
* ast/rust-fmt.cc (Pieces::~Pieces): Cleanup.
(Pieces::Pieces): Likewise.
* ast/rust-fmt.h (struct Pieces): Add pieces_vector member.
* hir/rust-ast-lower-format-args.cc: New file.
* hir/rust-ast-lower-format-args.h: New file.

17 months agoformat-args: Fix Rust interface and add input parsing.
Arthur Cohen [Fri, 16 Feb 2024 17:27:22 +0000 (18:27 +0100)] 
format-args: Fix Rust interface and add input parsing.

gcc/rust/ChangeLog:

* Make-lang.in: Do not build Rust library in release mode.
* ast/rust-ast.cc: Make FormatArgs inherit from AST::Expr
* ast/rust-builtin-ast-nodes.h: Improve FormatArg* nodes and helpers.
* ast/rust-fmt.cc (Pieces::collect): Fix interface to match FFI function.
* ast/rust-fmt.h (collect_pieces): Likewise.
(struct Pieces): Add append_newline parameter.
* expand/rust-macro-builtins.cc: Add proper parsing of format_args
input.
* hir/rust-ast-lower-base.cc: Include diagnostics header.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Switch interface to use more parser
parameters.
* libformat_parser/src/bin.rs: Use new interface.

17 months agoparser: Add peek(n) method to parser
Arthur Cohen [Mon, 19 Feb 2024 19:41:50 +0000 (20:41 +0100)] 
parser: Add peek(n) method to parser

gcc/rust/ChangeLog:

* parse/rust-parse.h: New method.

17 months agomacro-builtins: Add newline generic format_args!() handler
Arthur Cohen [Fri, 16 Feb 2024 15:19:27 +0000 (16:19 +0100)] 
macro-builtins: Add newline generic format_args!() handler

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (format_args_maker): New function.
(try_expand_many_expr): Add comment about reworking function.
(MacroBuiltin::format_args_handler): Add newline parameter.
* expand/rust-macro-builtins.h: Likewise.

17 months agoast: Add base nodes for FormatArgs
Arthur Cohen [Thu, 15 Feb 2024 19:58:48 +0000 (20:58 +0100)] 
ast: Add base nodes for FormatArgs

This commit adds a base for creating AST FormatArgs nodes after expanding
invocations of `format_args!()`. These nodes will then be expanded to
the proper runtime function calls (to core::fmt::rt) during the AST
lowering.

gcc/rust/ChangeLog:

* ast/rust-builtin-ast-nodes.h: New file.
* ast/rust-ast-full-decls.h (class FormatArgs): Declare new class.
* ast/rust-ast-collector.cc: Handle FormatArgs nodes properly.
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-full.h: Likewise.
* ast/rust-ast-visitor.cc: Likewise.
* ast/rust-ast-visitor.h: Likewise.
* ast/rust-ast.cc: Likewise.
* ast/rust-ast.h: Likewise.
* expand/rust-derive.h: Likewise.
* hir/rust-ast-lower-base.cc: Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-expr.cc: Likewise.
* hir/rust-ast-lower-expr.h: Likewise.
* resolve/rust-ast-resolve-base.cc: Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.

17 months agoMake DefaultResolver visit more of the AST
Owen Avery [Wed, 28 Feb 2024 22:42:49 +0000 (17:42 -0500)] 
Make DefaultResolver visit more of the AST

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc
(DefaultResolver::visit): Visit inner AST nodes of ClosureExprInner,
ClosureExprInnerTyped, IfExpr, IfExprConseqElse, MatchExpr,
PathInExpression, EnumItemTuple, EnumItemStruct, and
EnumItemDiscriminant.
* ast/rust-item.h
(EnumItemDiscriminant::has_expr): New function.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
17 months agoextern-types: Lower to HIR::ExternalTypeItem properly
Arthur Cohen [Tue, 20 Feb 2024 15:22:20 +0000 (16:22 +0100)] 
extern-types: Lower to HIR::ExternalTypeItem properly

gcc/rust/ChangeLog:

* hir/rust-ast-lower-extern.h: Lower to HIR::ExternalTypeItem nodes.
* hir/tree/rust-hir-item.h (class ExternalTypeItem): Create private
visibility by default as extern types have no visibility - add a comment
about the correctness of this.

17 months agohir: Add ExternalTypeItem node
Arthur Cohen [Tue, 20 Feb 2024 14:45:35 +0000 (15:45 +0100)] 
hir: Add ExternalTypeItem node

gcc/rust/ChangeLog:

* hir/tree/rust-hir-item.h (class ExternalTypeItem): New class.
* hir/tree/rust-hir.cc (ExternalTypeItem::as_string): Likewise.
* backend/rust-compile-extern.h: Add base for handling HIR::ExternalTypeItem
node.
* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
* checks/errors/borrowck/rust-function-collector.h: Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
* checks/errors/rust-const-checker.h: Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
* checks/errors/rust-unsafe-checker.h: Likewise.
* hir/rust-ast-lower-extern.h: Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/rust-hir-dump.h: Likewise.
* hir/tree/rust-hir-full-decls.h (class ExternalTypeItem): Likewise.
* hir/tree/rust-hir-visitor.h: Likewise.
(ExternalTypeItem::accept_vis): Likewise.
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise.
* typecheck/rust-hir-type-check-implitem.h: Likewise.

17 months agoextern-types: Declare external types in name resolver.
Arthur Cohen [Tue, 20 Feb 2024 13:53:32 +0000 (14:53 +0100)] 
extern-types: Declare external types in name resolver.

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-implitem.h: Declare external types as new
types.

17 months agolang-items: Make lang items enum stronger, rename class, cleanup ns.
Arthur Cohen [Tue, 27 Feb 2024 13:39:22 +0000 (14:39 +0100)] 
lang-items: Make lang items enum stronger, rename class, cleanup ns.

gcc/rust/ChangeLog:

* util/rust-lang-item.h (class RustLangItem): Renamed to...
(class LangItem): ...this. Rename ItemType enum to Kind
* util/rust-lang-item.cc: Rename methods to use new class name.
* backend/rust-compile-expr.cc (CompileExpr::visit): Use new lang-item API.
(CompileExpr::resolve_operator_overload): Likewise.
* backend/rust-compile-expr.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Likewise.
* typecheck/rust-autoderef.cc (Adjuster::try_deref_type): Likewise.
(AutoderefCycle::cycle): Likewise.
* typecheck/rust-autoderef.h: Likewise.
* typecheck/rust-hir-type-bounds.h: Likewise.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::get_marker_predicate): Likewise.
* typecheck/rust-hir-type-check-base.h: Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.
* typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise.
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_sized_builtin): Likewise.
(TypeBoundsProbe::assemble_builtin_candidate): Likewise.
(TypeCheckBase::get_predicate_from_bound): Likewise.
* typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise.
* util/rust-hir-map.cc (Mappings::get_lang_item): Likewise.
(Mappings::lookup_trait_item_lang_item): Likewise.
* util/rust-hir-map.h: Likewise.

17 months agolang-items: Cleanup parsing and lookups of lang items.
Arthur Cohen [Tue, 27 Feb 2024 12:35:50 +0000 (13:35 +0100)] 
lang-items: Cleanup parsing and lookups of lang items.

gcc/rust/ChangeLog:

* Make-lang.in: Compile new rust-lang-item.o.
* util/rust-lang-item.h: Split into header and source.
* util/rust-lang-item.cc: Cleanup parsing of lang items by using a hashmap
and returning optional values, cleanup handling of exhaustive lang item
lookups.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Use
new optional API.

17 months agoMerge commit '705de6d54ca95b8277a15fe9a2255af6168ae086' into HEAD [#2123]
Thomas Schwinge [Thu, 29 Feb 2024 13:04:29 +0000 (14:04 +0100)] 
Merge commit '705de6d54ca95b8277a15fe9a2255af6168ae086' into HEAD [#2123]

17 months agoFix small FixMe task in rust macro builtins
jjasmine [Fri, 23 Feb 2024 21:06:14 +0000 (13:06 -0800)] 
Fix small FixMe task in rust macro builtins

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc: Change BuiltinMacro in
builtin_macro_from_string to tl::optional<>
* expand/rust-macro-builtins.h (enum class): Change BuiltinMacro
in builtin_macro_from_string to tl::optional<>
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
Resolved wrong type dependency of builtin_macro_from_string

Signed-off-by: jjasmine <tanghocle456@gmail.com>
17 months agoAdjust error checks to match name resolution 2.0
Owen Avery [Fri, 23 Feb 2024 15:20:55 +0000 (10:20 -0500)] 
Adjust error checks to match name resolution 2.0

gcc/testsuite/ChangeLog:

* rust/compile/bad_stmt_enums.rs: Adjust redefinition error.
* rust/compile/bad_toplevel_enums.rs: Likewise.
* rust/compile/redef_error1.rs: Likewise.
* rust/compile/redef_error3.rs: Likewise.
* rust/compile/redef_error4.rs: Likewise.
* rust/compile/redef_error6.rs: Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
17 months agoci: Install cargo on ubuntu 18.04 container.
Arthur Cohen [Mon, 26 Feb 2024 10:57:54 +0000 (11:57 +0100)] 
ci: Install cargo on ubuntu 18.04 container.

ChangeLog:

* .github/workflows/ccpp.yml: Install cargo for GCC 4.8 job.

17 months agoformat-parser: Add `is_some_and` method for Option<T>
Arthur Cohen [Mon, 26 Feb 2024 10:55:47 +0000 (11:55 +0100)] 
format-parser: Add `is_some_and` method for Option<T>

Workaround for Ubuntu 18.04, since we still use it for the GCC 4.8 CI.
The default Rust package is 1.65 (and unlikely to change I assume?),
but the generic format parser library uses `is_some_and` which was
introduced in 1.70. So this is a simple reimplementation, directly taken
from the standard library sources.

libgrust/ChangeLog:

* libformat_parser/generic_format_parser/src/lib.rs: Add IsSomeAnd<T>
trait, impl it for Option<T>.

17 months agolibformat_parser: Fix Rust warnings.
Arthur Cohen [Thu, 15 Feb 2024 12:11:26 +0000 (13:11 +0100)] 
libformat_parser: Fix Rust warnings.

libgrust/ChangeLog:

* libformat_parser/generic_format_parser/src/lib.rs: Remove
unused deprecated attribute and unused import.
* libformat_parser/src/lib.rs: Remove unused import.

17 months agorust-fmt: Store parsed string in Pieces struct
Arthur Cohen [Tue, 13 Feb 2024 15:31:25 +0000 (16:31 +0100)] 
rust-fmt: Store parsed string in Pieces struct

gcc/rust/ChangeLog:

* ast/rust-fmt.cc (Pieces::collect): Fix signature to take ownership
of the given string.
* ast/rust-fmt.h (struct Pieces): Store parsed string in the struct.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Add debug prompt.

17 months agoformat_args: Parse entire token invocation
Arthur Cohen [Wed, 7 Feb 2024 11:46:16 +0000 (12:46 +0100)] 
format_args: Parse entire token invocation

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Transform entire invocation token stream into string for the parser.

17 months agoformat_args: Parse format string properly
Arthur Cohen [Tue, 30 Jan 2024 15:16:36 +0000 (16:16 +0100)] 
format_args: Parse format string properly

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Construct string to parser properly.

17 months agolibformat_parser: Send boxed values across FFI properly
Arthur Cohen [Tue, 30 Jan 2024 00:48:13 +0000 (01:48 +0100)] 
libformat_parser: Send boxed values across FFI properly

gcc/rust/ChangeLog:

* ast/rust-fmt.cc (Pieces::~Pieces): Call libformat_parser's release
function in destructor.
* ast/rust-fmt.h (struct PieceSlice): Add capacity.
(destroy_pieces): New.
(struct Pieces): Add destructor.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Leak Boxes properly for C++ to
see them, add memory release function.

17 months agolibformat_parser: Update header and remove old interface
Arthur Cohen [Mon, 29 Jan 2024 21:06:39 +0000 (22:06 +0100)] 
libformat_parser: Update header and remove old interface

gcc/rust/ChangeLog:

* ast/rust-fmt.cc (Pieces::collect): Use new Pieces API.
* ast/rust-fmt.h: Update interface with new FFI bindings.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Add IntoFFI trait.
* libformat_parser/libformat-parser.h: Removed.

17 months agogit: Ignore libgrust build folders
Arthur Cohen [Mon, 29 Jan 2024 15:17:00 +0000 (16:17 +0100)] 
git: Ignore libgrust build folders

ChangeLog:

* .gitignore: Add libgrust target folders to the ignore list.

17 months agolibformat_parser: Start experimenting with cbindgen
Arthur Cohen [Mon, 29 Jan 2024 15:14:13 +0000 (16:14 +0100)] 
libformat_parser: Start experimenting with cbindgen

libgrust/ChangeLog:

* libformat_parser/cbindgen.toml: New file.
* libformat_parser/libformat-parser.h: New file.

gcc/rust/ChangeLog:

* ast/rust-fmt.h: Add remaining FFI types.

17 months agolibformat_parser: Add FFI safe interface
Arthur Cohen [Mon, 29 Jan 2024 15:13:24 +0000 (16:13 +0100)] 
libformat_parser: Add FFI safe interface

libgrust/ChangeLog:

* libformat_parser/generic_format_parser/src/lib.rs: Add generic
library.
* libformat_parser/src/lib.rs: Add base for FFI interface.

17 months agolibgrust: Add format_parser library
Arthur Cohen [Thu, 30 Nov 2023 13:11:41 +0000 (14:11 +0100)] 
libgrust: Add format_parser library

Compile libformat_parser and link to it.

gcc/rust/ChangeLog:

* Make-lang.in: Compile libformat_parser.
* ast/rust-fmt.cc: New FFI definitions.
* ast/rust-fmt.h: Likewise.
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Call
into libformat_parser.
* expand/rust-macro-builtins.h: Define format_args!() handler proper.

libgrust/ChangeLog:

* libformat_parser/Cargo.lock: New file.
* libformat_parser/Cargo.toml: New file.
* libformat_parser/generic_format_parser/Cargo.toml: New file.
* libformat_parser/generic_format_parser/src/lib.rs: New file.
* libformat_parser/src/bin.rs: New file.
* libformat_parser/src/lib.rs: New file.

17 months agofmt: Start working on format_args!() parser
Arthur Cohen [Thu, 9 Nov 2023 17:32:52 +0000 (18:32 +0100)] 
fmt: Start working on format_args!() parser

This commit adds a base class for parsing the various constructs of a
Rust format string, according to the grammar in the reference:

https://doc.rust-lang.org/std/fmt/index.html#syntax

gcc/rust/ChangeLog:

* Make-lang.in: Compile rust-fmt object
* ast/rust-fmt.cc: New file.
* ast/rust-fmt.h: New file.

17 months agogccrs: minor cleanup in langhook.type_for_mode
Marc Poulhiès [Mon, 19 Feb 2024 21:52:29 +0000 (22:52 +0100)] 
gccrs: minor cleanup in langhook.type_for_mode

gcc/rust/ChangeLog:

* rust-lang.cc (grs_langhook_type_for_mode): simplify code for
xImode. Add missing long_double_type_node.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
17 months agoFix false positive for top-level AltPattern
Owen Avery [Sun, 18 Feb 2024 05:19:25 +0000 (00:19 -0500)] 
Fix false positive for top-level AltPattern

gcc/rust/ChangeLog:

* hir/rust-ast-lower-pattern.cc
(ASTLoweringPattern::visit):
Reset is_let_top_level while visiting GroupedPattern.

gcc/testsuite/ChangeLog:

* rust/compile/let_alt.rs: Check for false positive.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
17 months agogccrs: fix powif64 intrinsic
Marc Poulhiès [Mon, 19 Feb 2024 21:36:39 +0000 (22:36 +0100)] 
gccrs: fix powif64 intrinsic

The signature was incorrectly using an i64 for the integer power,
instead of an i32.

gcc/testsuite/ChangeLog:

* rust/compile/torture/intrinsics-math.rs: Adjust powif64
intrinsic signature.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>