aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2025-03-25testsuite: aarch64: restore torture options in bf16_dup.cChristophe Lyon1-1/+1
Remove dg-options, so that the test is executed as expected using the options defined by advsimd-intrinsics.exp. (Previously we pretend we do, but in fact all torture options are silently overriden with -O2) We skip it at -O0, because the tested optimizations does not take place at this level. gcc/testsuite/ * gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c: Remove dg-options.
2025-03-25testsuite: aarch64: arm: move saturating_arithmetic_autovect tests to simd/Christophe Lyon5-0/+0
These tests force dg-options because they rely on -ftree-vectorize and do not make use of torture options, so move them to simd/ where they belong. gcc/testsuite/ * gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect.inc: Move to gcc.target/aarch64/simd/. * gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_1.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_2.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_3.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/saturating_arithmetic_autovect_4.c: Likewise.
2025-03-25testsuite: arm: remove duplicate -mcpu=unset in arm_v8_1_lob_okChristophe Lyon1-1/+1
This was probably a typo / oversight. gcc/testsuite/ * lib/target-supports.exp (check_effective_target_arm_v8_1_lob_ok): Remove duplicate -mcpu=unset.
2025-03-25arm: add commutative alternatives to <US>mull pattern.Richard Earnshaw2-5/+6
Prior to Armv6, the SMULL and UMULL instructions, which have the form UMULL Rdlo, Rdhi, Rm, Rs had an operand restriction such that Rdlo, Rdhi and Rm must all be different registers. Rs, however can overlap either of the destination registers. Add some register-tie alternatives to allow the register allocator to find these forms without having to use additional register moves. In addition to this, the test is pretty meaningless on Thumb-1 targets as the S/UMULL instructions do not exist in a 16-bit encoding. So skip the test in this case. gcc/ChangeLog: * config/arm/arm.md (<US>mull): Add alternatives that allow Rs to be tied to either Rdlo or Rdhi. gcc/testsuite/ChangeLog: * gcc.target/arm/pr42575.c: Skip test if thumb1.
2025-03-25opcodes: fix wrong code in expand_binop_directly [PR117811]Richard Earnshaw2-12/+39
If expand_binop_directly fails to add a REG_EQUAL note it tries to unwind and restart. But it can unwind too far if expand_binop changed some of the operands before calling it. We don't need to unwind that far anyway since we should end up taking exactly the same route next time, just without a target rtx. To fix this we remove LAST from the argument list and let the callers (all in expand_binop) do their own unwinding if the call fails. Instead we unwind just as far as the entry to expand_binop_directly and recurse within this function instead of all the way back up. gcc/ChangeLog: PR middle-end/117811 * optabs.cc (expand_binop_directly): Remove LAST as an argument, instead record the last insn on entry. Only delete insns if we need to restart and restart by calling ourself, not expand_binop. (expand_binop): Update callers to expand_binop_directly. If it fails to expand the operation, delete back to LAST. gcc/testsuite: PR middle-end/117811 * gcc.dg/torture/pr117811.c: New test.
2025-03-25tailc: Only diagnose musttail failures during tailc or musttail passes ↵Jakub Jelinek3-39/+87
[PR119376] The following testcases FAIL because musttail failures are diagnosed not just in the tailc or musttail passes, but also during the tailr1 and tailr2. tailr1 pass is before IPA and in the testcases eh cleanup has not cleaned up the IL sufficiently yet to make the musttail calls pass, even tailr2 could be too early. The following patch does that only during the tailc pass, and if that pass is not actually executed, during musttail pass. To do it only in the tailc pass, I chose to pass a new bool flag, because while we have the opt_tailcalls argument, it is actually passed by reference to find_tail_calls and sometimes cleared during that. musttail calls when the new DIAG_MUSTTAIL flag is not set are handled like any other calls, we simply silently punt on those if they can't be turned into tail calls. Furthermore, I had to tweak the musttail pass gate. Previously it was !flag_optimize_sibling_calls && f->has_musttail. The problem is that gate of tailr and tailc passes is flag_optimize_sibling_calls != 0 && dbg_cnt (tail_call) and furthermore, tailc pass is only in the normal optimization queue, so only if not -O0 or -Og. So when one would use tail_call dbg_cnt with some limit, or when e.g. using -foptimize-sibling-calls with -O0 or -Og, nothing would actually diagnose invalid musttail calls or set tail call flags on those if they are ok. I could insert a new PROP_ flag on whether musttail has been handled by tailc pass, but given that we have the cfun->has_musttail flag already and nothing after tailc/musttail passes uses it, I think it is easier to just clear the flag when musttail failures are diagnosed and correct ones have [[tail call]] flag added. Expansion will then only look at the [[tail call]] flag, it could even at the [[must tail call]] flag, but I don't see a point to check cfun->has_musttail. 2025-03-25 Jakub Jelinek <jakub@redhat.com> PR ipa/119376 * tree-tailcall.cc (suitable_for_tail_opt_p): Add DIAG_MUSTTAIL argument, propagate it down to maybe_error_musttail. (suitable_for_tail_call_opt_p): Likewise. (maybe_error_musttail): Add DIAG_MUSTTAIL argument. Don't emit error for gimple_call_must_tail_p calls if it is false. (find_tail_calls): Add DIAG_MUSTTAIL argument, propagate it down to maybe_error_musttail, suitable_for_tail_opt_p, suitable_for_tail_call_opt_p and find_tail_calls calls. (tree_optimize_tail_calls_1): Add DIAG_MUSTTAIL argument, propagate it down to find_tail_calls and if set, clear cfun->has_musttail flag at the end. Rename OPT_MUSTCALL argument to OPT_MUSTTAIL. (execute_tail_calls): Pass true to DIAG_MUSTTAIL tree_optimize_tail_calls_1 argument. (pass_tail_recursion::execute): Pass false to DIAG_MUSTTAIL tree_optimize_tail_calls_1 argument. (pass_musttail::gate): Don't test flag_optimize_sibling_calls. (pass_musttail::execute): Pass true to DIAG_MUSTTAIL tree_optimize_tail_calls_1 argument. * g++.dg/torture/musttail1.C: New test. * g++.dg/opt/musttail2.C: New test.
2025-03-25PR modula2/119449 MAX of SYSTEM.REAL64 cause an ICEGaius Mulley11-89/+168
This bugfix implements MAX(REAL64) and MIN(REAL64) etc for REAL64, REAL96 and REAL128. gcc/m2/ChangeLog: PR modula2/119449 * gm2-compiler/M2GCCDeclare.def (TryDeclareType): Remove tokenno parameter. * gm2-compiler/M2GCCDeclare.mod (TryDeclareType): Ditto. * gm2-compiler/M2GenGCC.mod (FoldTBitsize): Remove op2 and rename op1 as res and op3 as type. (FoldStandardFunction): Call FoldTBitsize omitting op2. * gm2-compiler/M2Quads.mod (GetTypeMin): Rewrite. (GetTypeMinLower): New procedure function. (GetTypeMax): Rewrite. (GetTypeMaxLower): New procedure function. * gm2-compiler/M2Range.mod (CheckCancelled): Comment out. * gm2-compiler/M2System.mod (CreateMinMaxFor): Add realtype parameter. (MapType): Rewrite to use realtype. (CreateType): Ditto. (AttemptToCreateType): Ditto. (MakeFixedSizedTypes): Add realtype boolean. (InitPIMTypes): Ditto. (InitISOTypes): Ditto. (MakeExtraSystemTypes): Ditto. * gm2-gcc/m2pp.cc (m2pp_nop_expr): Remove code. * gm2-gcc/m2type.cc (IsGccRealType): New function. (m2type_GetMinFrom): Rewrite. (m2type_GetMaxFrom): Ditto. (do_min_real): Declare static. (do_max_real): Declare static. gcc/testsuite/ChangeLog: PR modula2/119449 * gm2/pim/pass/minmaxreal.mod: New test. * gm2/pim/pass/minmaxreal2.mod: New test. * gm2/pim/pass/minmaxreal3.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2025-03-25i386: Fix AVX10.2 sat cvt intrinsic.Hu, Lin11-6/+22
The patch aims to modify the missed fixed for vcvttph2iubs's testcase. gcc/testsuite/ChangeLog: * gcc.target/i386/avx10_2-512-vcvttph2iubs-2.c: Modify testcase.
2025-03-25Daily bump.GCC Administrator7-1/+2463
2025-03-24vect: Add assert to expand_vector_conversion [PR118616]Andrew Pinski1-0/+1
In some cases (after inliing due to LTO and -O3), GCC cannot figure out that the length of the converts vect is not empty when supportable_indirect_convert_operation returns true. So we get an extra warning because we loop through all but the last entry and GCC decided that `converts.length () - 1` is -1. This adds an assert to avoid the warning and maybe even produce slightly better code for this function. A gcc_checking_assert would be better here but we don't convert that into an assume attribute or `if(!a) __builtin_unreachable();`, I filed PR 119439 for that. Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/118616 gcc/ChangeLog: * tree-vect-generic.cc (expand_vector_conversion): Add an assert that converts vect is non empty if supportable_indirect_convert_operation returns true. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-03-24Update gcc hr.po, sv.poJoseph Myers2-544/+424
* hr.po, sv.po: Update.
2025-03-24c++: pack indexing and if constevalJason Merrill2-1/+17
The pack index is manifestly constant-evaluated, and the call to maybe_constant_value needs to reflect that or we wrongly complain about non-constant index if the evaluation uses if consteval. gcc/cp/ChangeLog: * semantics.cc (finish_type_pack_element): Pass mce_true to maybe_constant_value. gcc/testsuite/ChangeLog: * g++.dg/cpp26/pack-indexing16.C: New test.
2025-03-24cobol: Move includes before system.hIain Sandoe1-2/+2
This just moves an include ahead of cobol-system.h which in turn includes system.h. gcc/cobol/ChangeLog: * cdf-copy.cc: Move host include before system.h Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-03-24Remove buffer overflow in cobol driverAndreas Schwab1-8/+4
PR cobol/119390 * gcobolspec.cc (lang_specific_driver): Use pointer instead of copying into fixed array.
2025-03-24testsuite: d: Break up Wbuiltin_declaration_mismatch2.d into smaller testsIain Buclaw5-176/+226
gcc/testsuite/ChangeLog: * gdc.dg/Wbuiltin_declaration_mismatch2.d: Split test into ... * gdc.dg/Wbuiltin_declaration_mismatch3.d: New test. * gdc.dg/Wbuiltin_declaration_mismatch4.d: New test. * gdc.dg/Wbuiltin_declaration_mismatch5.d: New test. * gdc.dg/Wbuiltin_declaration_mismatch6.d: New test.
2025-03-24gccrs: support generic super traits recursivelyPhilip Herron10-60/+166
In order to handle generic super traits on any trait bound we need to ensure we track the TypeBoundPredicate as part of the TraitReference instead of just the raw TraitReferences because these will have any applied generics enplace. Then for any TypeBoundPredicate it takes a copy of the super traits because this is the usage of a TraitBound and we can apply generics which then need to be recursively applied up the chain of super predicates. The main tweak is around TypeBoundPredicate::lookup_associated_item because we need to associate the predicate with the item we are looking up so the caller can respect the generics correctly as well. Fixes Rust-GCC#3502 gcc/rust/ChangeLog: * typecheck/rust-hir-path-probe.cc: update call * typecheck/rust-hir-trait-reference.cc (TraitReference::lookup_trait_item): track predicate (TraitReference::is_equal): likewise (TraitReference::is_object_safe): likewise (TraitReference::satisfies_bound): likewise * typecheck/rust-hir-trait-reference.h: likewise * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): likewise * typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::TypeBoundPredicate): track super traits (TypeBoundPredicate::operator=): likewise (TypeBoundPredicate::apply_generic_arguments): ensure we apply to super predicates (TypeBoundPredicateItem::operator=): take copy of parent predicate (TypeBoundPredicateItem::error): pass error instead of nullptr (TypeBoundPredicateItem::is_error): update to no longer check for nullptr (TypeBoundPredicateItem::get_parent): updated (TypeBoundPredicateItem::get_tyty_for_receiver): likewise (TypeBoundPredicate::get_associated_type_items): likewise * typecheck/rust-tyty-bounds.h (class TypeBoundPredicateItem): move * typecheck/rust-tyty-subst.cc: flag to handle placeholder Self on traits * typecheck/rust-tyty-subst.h (class TypeBoundPredicateItem): likewise * typecheck/rust-tyty.h (class TypeBoundPredicateItem): refactored gcc/testsuite/ChangeLog: * rust/execute/torture/issue-3502.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-24gccrs: nr2.0: Fix StructExprFieldIdentifier handlingOwen Avery3-8/+29
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add visitor for StructExprFieldIdentifier. * resolve/rust-late-name-resolver-2.0.h (Late::visit): Likewise. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: nr2.0: Adjust indentifier expression handlingOwen Avery2-12/+17
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Make sure to return early after a resolution error, improve the resolution error message, fix a typo, handle ambiguous resolutions, and remove an old comment. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: Modify multiple definition errorOwen Avery9-45/+43
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Modify error message. * resolve/rust-ast-resolve-implitem.h (ResolveToplevelImplItem::visit): Likewise. (ResolveTopLevelTraitItems::visit): Likewise. (ResolveToplevelExternItem::visit): Likewise. * resolve/rust-ast-resolve-stmt.cc (ResolveStmt::visit): Likewise. * resolve/rust-ast-resolve-stmt.h (ResolveStmt::visit): Likewise. * resolve/rust-ast-resolve-toplevel.h (ResolveTopLevel::visit): Likewise. * resolve/rust-ast-resolve-type.h (ResolveGenericParams::visit): Likewise. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. * rust/compile/redef_error2.rs: Modify expected error. * rust/compile/redef_error5.rs: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: nr2.0: Adjust visitors for struct expressionsOwen Avery3-8/+19
gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Make sure to always visit the struct name. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Avoid visiting the struct name twice. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: Prevent multiple resolution insertionOwen Avery8-81/+302
gcc/rust/ChangeLog: * expand/rust-derive-clone.cc (DeriveClone::clone_impl): Avoid using the same node id multiple times. (DeriveClone::clone_enum_identifier): Likewise. (DeriveClone::clone_enum_tuple): Likewise. * expand/rust-derive-copy.cc (DeriveCopy::copy_impl): Likewise. * resolve/rust-ast-resolve-item.cc (flatten_list): Likewise. * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Prevent reinsertion of resolutions. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::resolve_fn_trait_call): Likewise. * resolve/rust-name-resolver.cc (Resolver::insert_resolved_name): Catch multiple resolution insertions. (Resolver::insert_resolved_type): Likewise. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: nr2.0: Fix test self-path2.rsOwen Avery4-12/+11
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Adjust the error message for a lower self segment in the middle of a path. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove self-path2.rs * rust/compile/self-path2.rs: Adjust expected errors. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: emit an error for type or const parameters on foreign itemsRyutaro Okada2-0/+19
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): emit an error for type or const parameters on foreign items gcc/testsuite/ChangeLog: * rust/compile/extern_generics.rs: New test. Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
2025-03-24gccrs: Fix modules with same name as builtins causing ICE (#3315)Liam Naddell8-25/+127
gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (ForeverStack): Add a dedicated prelude node for the Language prelude * resolve/rust-forever-stack.hxx (ForeverStack): Add support code for the prelude node * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Move language prelude builtins to the prelude context * resolve/rust-name-resolution-context.cc (NameResolutionContext::scoped): Add code for handling the prelude corner case * resolve/rust-rib.h (Rib::Kind): Add a special Prelude rib type gcc/testsuite/ChangeLog: * rust/compile/issue-3315-1.rs: Add test for module with same name as builtin * rust/compile/issue-3315-2.rs: Test with utilization of i32 type * rust/compile/nr2/exclude: issue-3315-2.rs Does not work with NR2.0 Signed-off-by: Liam Naddell <liamnprg@gmail.com>
2025-03-24gccrs: nr2.0: Check compile/torture/*.rs testsOwen Avery2-4/+19
gcc/testsuite/ChangeLog: * rust/compile/nr2/compile.exp: Adjust to cover tests in the torture subdirectory. * rust/compile/nr2/exclude: Add entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: Remove mangling tests from exclusion listPierre-Emmanuel Patry1-2/+0
Those tests are now passing. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove two mangling tests from exclusion file. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: Fix canonical path parent resolutionPierre-Emmanuel Patry1-1/+1
The algorithm was comparing using the wrong id, this lead to some mangling errors as an erroneous parent was selected. gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx: Fix the id comparison. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: Insert crate name in canonical pathPierre-Emmanuel Patry1-1/+6
gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx: Insert a new segment with the crate's name as canonical's path prefix. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: Add a function to get the crate number from node idPierre-Emmanuel Patry2-7/+14
gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::lookup_crate_num): Add function to retrieve crate number from it's node id. (Mappings::node_is_crate): change function with call to lookup_crate_num to avoid looping through all crates. (Mappings::insert_ast_crate): Populate node id to crate number map. * util/rust-hir-map.h: Change function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: Remove finalize import visitorPierre-Emmanuel Patry2-75/+0
This visitor is not used anymore. gcc/rust/ChangeLog: * resolve/rust-finalize-imports-2.0.cc (FinalizeImports::FinalizeImports): Remove constructor. (FinalizeImports::go): Remove function. (FinalizeImports::visit): Likewise. * resolve/rust-finalize-imports-2.0.h (class FinalizeImports): Remove FinalizeImports class. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: Remove tests from exclusion listPierre-Emmanuel Patry1-2/+0
gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove issue-1786 and issue-3033 from exclusion list. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: Move import mapping resolution to in tree visitPierre-Emmanuel Patry5-90/+105
Import mapping was relying on resolve_path which in turn relies on the cursor function. This means the mapping resolver should be called from the correct scope instead of being called from the crate scope. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::Early): Move the top level visitor from the function scope to attributes. (Early::go): Remove top level visitor creation and adapt calling code. Remove call to mapping resolution and import finalization. (Early::finalize_simple_import): Move the finalization from it's visitor. (Early::finalize_glob_import): Likewise. (Early::finalize_rebind_import): Likewise. (Early::visit): Add mapping resolution and finalization in UseDeclaration visitor function. * resolve/rust-finalize-imports-2.0.cc (finalize_simple_import): Move function. (finalize_glob_import): Likewise. (finalize_rebind_import): Likewise. (FinalizeImports::visit): Remove call to finalizers. * resolve/rust-early-name-resolver-2.0.h (class Early): Add top level attribute. * resolve/rust-finalize-imports-2.0.h: Add function prototypes. * resolve/rust-toplevel-name-resolver-2.0.h: Change getter return type to reference. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: check for recursion trait cycle with bounds checksPhilip Herron6-5/+78
We need to be careful when doing bounds check as to not create a recusive trait resolution. This patch checks for that case and fixes a bad type is equal check on ADT Types which was caught with a regression here. Fixes Rust-GCC#3126 gcc/rust/ChangeLog: * typecheck/rust-hir-trait-resolve.cc (TraitResolver::ResolveHirItem): new helper * typecheck/rust-hir-trait-resolve.h: add helper prototype * typecheck/rust-type-util.cc (query_type): add debug * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): check for recursion * typecheck/rust-tyty.cc (VariantDef::is_equal): fix is equal check gcc/testsuite/ChangeLog: * rust/execute/torture/issue-3126.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-24gccrs: track DefId on ADT Types this could be useful informationPhilip Herron3-29/+65
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): track DefId of origin * typecheck/rust-tyty.cc (BaseType::monomorphized_clone): likewise (ADTType::ADTType): likewise (ADTType::get_id): likewise (ADTType::clone): likewise * typecheck/rust-tyty.h: likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-24gccrs: remove visitor which is not needed herePhilip Herron2-46/+20
Just a small refactor to remove a visitor which is not needed. gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc (ResolvePathRef::Compile): remove visitor (ResolvePathRef::ResolvePathRef): likewise (ResolvePathRef::visit): likewise * backend/rust-compile-resolve-path.h (class ResolvePathRef): likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-24gccrs: Fix some small issuesOwen Avery2-2/+2
gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (assume_handler): Fix copy/paste error. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Fix spelling mistake. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: Add a test for enum variant name resolutionPierre-Emmanuel Patry1-0/+12
Highlight the fact that a value inside an enum definition refers to a struct outside of the enum and not to the enum variant's name directly. gcc/testsuite/ChangeLog: * rust/compile/enum_variant_name.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: Remove nr2 exhaustiveness test from exclusion listPierre-Emmanuel Patry1-1/+0
gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: Add enum variant string information to definitionPierre-Emmanuel Patry1-0/+2
New enum variant status now appears in the string representation of the resolver's definition. gcc/rust/ChangeLog: * resolve/rust-rib.cc (Rib::Definition::to_string): Add enum variant status. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: Keep definition provenance to skip enum variantsPierre-Emmanuel Patry8-26/+106
Enum variants shouldn't be accessed directly even from within an enum. This commit keeps the provenance for enum variants definition so we can skip them when resolving a value within an enum definition. gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: Add new function to insert enum variants and add argument to resolver's get function to explicitely skip enum variants. * resolve/rust-forever-stack.hxx: Update function definitions. * resolve/rust-name-resolution-context.cc (NameResolutionContext::insert_variant): Add function to insert enum variants. * resolve/rust-name-resolution-context.h: Add function's prototype. * resolve/rust-rib.cc (Rib::Definition::Definition): Add new boolean to hint at enum variant provenance. (Rib::Definition::is_variant): New getter for variant status. (Rib::Definition::Shadowable): Update constructor to opt out of enum variants. (Rib::Definition::Globbed): Likewise. (Rib::Definition::NonShadowable): Change constructor to forward enum variant provenance status. * resolve/rust-rib.h: Update function prototypes. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::insert_enum_variant_or_error_out): Add function to insert enum variants in the name resolver. (TopLevel::visit): Update several enum variant's visitor function with the new enum variant name resolving code. * resolve/rust-toplevel-name-resolver-2.0.h: Update function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: Add rib kind debug representationPierre-Emmanuel Patry2-3/+36
Rib kind had no string representation, and thus were not used in the debug string representation. gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx: Output rib kind. * resolve/rust-rib.h: Add function to get string representation from a rib kind. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-24gccrs: nr2.0: Set the node id of the root nodeOwen Avery3-10/+6
gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (ForeverStack::ForeverStack): Set the node id of the root node to that of the current crate. * resolve/rust-forever-stack.hxx (ForeverStack::find_starting_point): Use the node id of the root node during resolution of crate segments. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: expansion: Correctly expand $crate metavarArthur Cohen8-17/+115
gcc/rust/ChangeLog: * expand/rust-macro-expand.cc: Use new SubstituteCtx API. * expand/rust-macro-expand.h: Likewise. * expand/rust-macro-substitute-ctx.cc: Implement proper expansion of $crate. * expand/rust-macro-substitute-ctx.h: Adapt APIs to take macro definition when substituting. * util/rust-hir-map.cc (Mappings::insert_macro_def): Store crate information when inserting macro definition in mappings. (Mappings::lookup_macro_def_crate): New. * util/rust-hir-map.h: Adapt mappings to store crate in which macros were defined. gcc/testsuite/ChangeLog: * rust/execute/crate-metavar1.rs: New test. * rust/compile/crate-metavar1.rs: New test.
2025-03-24gccrs: nr2.0: Make sure PathInExpression is default resolvedOwen Avery2-7/+2
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Call DefaultResolver::visit earlier, in order to ensure it is called even if Late::visit returns early. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: Reduce usage of rust-session-manager.hOwen Avery11-13/+91
gcc/rust/ChangeLog: * util/rust-edition.cc: New file. * util/rust-edition.h: New file. * Make-lang.in: Add rust-edition.o to the object list. * ast/rust-pattern.cc: Remove inclusion of rust-session-manager.h. * expand/rust-macro-expand.cc: Likewise. * expand/rust-macro-builtins-helpers.h: Likewise. * expand/rust-macro-builtins-include.cc: Include rust-session-manager.h. * expand/rust-macro-builtins-utility.cc: Likewise. * lex/rust-lex.cc: Include rust-edition.h instead of rust-session-manager.h. (Lexer::classify_keyword): Use get_rust_edition instead of Session and CompileOptions. * parse/rust-parse-impl.h: Include rust-edition.h instead of rust-session-manager.h. (Parser::parse_async_item): Use get_rust_edition instead of Session and CompileOptions. * checks/errors/rust-feature.h: Include rust-edition.h instead of rust-session-manager.h. (class Feature): Use Rust::Edition instead of Rust::CompileOptions::Edition. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: session-manager: Call into DesugarQuestionMarkArthur Cohen1-0/+2
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Call DesugarQuestionMark::go().
2025-03-24gccrs: lower: Error out when lowering ErrorPropagationExprArthur Cohen4-197/+188
Adapt functions for lowering nodes that should never reach the lowering phase to cause an unreachable, and mark them as final so as it not possible to override them in other visitors. gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc: Adapt functions for ErrorPropagationExpr and MacroInvocation. * hir/rust-ast-lower-base.h: Mark them as final. * hir/rust-ast-lower-expr.cc: Remove previous definition for those overrides. * hir/rust-ast-lower-expr.h: Likewise.
2025-03-24gccrs: ast: Add base for desugaring try expressionsArthur Cohen4-0/+331
gcc/rust/ChangeLog: * Make-lang.in: Compile it. * ast/rust-desugar-question-mark.cc: New file. * ast/rust-desugar-question-mark.h: New file. gcc/testsuite/ChangeLog: * rust/compile/try-expr1.rs: New test.
2025-03-24gccrs: Adjust unknown macro error messageOwen Avery6-7/+7
gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Adjust error produced when macro resolution fails. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/macro43.rs: Adjust expected errors. * rust/compile/macros/mbe/macro44.rs: Likewise. * rust/compile/nested_macro_use2.rs: Likewise. * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-24gccrs: nr2.0: Handle lang item type path segmentsOwen Avery4-5/+66
gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx (ForeverStack::find_starting_point): Stop when hitting a lang item segment. (ForeverStack::resolve_segments): Resolve lang item segments. (ForeverStacl::resolve_path): Handle single segment lang item paths and add comment. * util/rust-unwrap-segment.cc (unwrap_segment_get_lang_item): Add. * util/rust-unwrap-segment.h (unwrap_segment_get_lang_item): Add. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>