Commit Graph

218722 Commits

Author SHA1 Message Date
Paul-Antoine Arras
99e2906ae2 OpenMP: 'interop' construct - add ME support + target-independent libgomp
This patch partially enables use of the OpenMP interop construct by adding
middle end support, mostly in the omplower pass, and in the target-independent
part of the libgomp runtime. It follows up on previous patches for C, C++ and
Fortran front ends support. The full interop feature requires another patch to
enable foreign runtime support in libgomp plugins.

gcc/ChangeLog:

	* builtin-types.def
	(BT_FN_VOID_INT_INT_PTR_PTR_PTR_INT_PTR_INT_PTR_UINT_PTR): New.
	* gimple-low.cc (lower_stmt): Handle GIMPLE_OMP_INTEROP.
	* gimple-pretty-print.cc (dump_gimple_omp_interop): New function.
	(pp_gimple_stmt_1): Handle GIMPLE_OMP_INTEROP.
	* gimple.cc (gimple_build_omp_interop): New function.
	(gimple_copy): Handle GIMPLE_OMP_INTEROP.
	* gimple.def (GIMPLE_OMP_INTEROP): Define.
	* gimple.h (gimple_build_omp_interop): Declare.
	(gimple_omp_interop_clauses): New function.
	(gimple_omp_interop_clauses_ptr): Likewise.
	(gimple_omp_interop_set_clauses): Likewise.
	(gimple_return_set_retval): Handle GIMPLE_OMP_INTEROP.
	* gimplify.cc (gimplify_scan_omp_clauses): Handle OMP_CLAUSE_INIT,
	OMP_CLAUSE_USE and OMP_CLAUSE_DESTROY.
	(gimplify_omp_interop): New function.
	(gimplify_expr): Replace sorry with call to gimplify_omp_interop.
	* omp-builtins.def (BUILT_IN_GOMP_INTEROP): Define.
	* omp-low.cc (scan_sharing_clauses): Handle OMP_CLAUSE_INIT,
	OMP_CLAUSE_USE and OMP_CLAUSE_DESTROY.
	(scan_omp_1_stmt): Handle GIMPLE_OMP_INTEROP.
	(lower_omp_interop_action_clauses): New function.
	(lower_omp_interop): Likewise.
	(lower_omp_1): Handle GIMPLE_OMP_INTEROP.

gcc/c/ChangeLog:

	* c-parser.cc (c_parser_omp_clause_destroy): Make addressable.
	(c_parser_omp_clause_init): Make addressable.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_omp_clause_init): Make addressable.

gcc/fortran/ChangeLog:

	* trans-openmp.cc (gfc_trans_omp_clauses): Make OMP_CLAUSE_DESTROY and
	OMP_CLAUSE_INIT addressable.
	* types.def (BT_FN_VOID_INT_INT_PTR_PTR_PTR_INT_PTR_INT_PTR_UINT_PTR):
	New.

include/ChangeLog:

	* gomp-constants.h (GOMP_DEVICE_DEFAULT_OMP_61, GOMP_INTEROP_TARGET,
	GOMP_INTEROP_TARGETSYNC, GOMP_INTEROP_FLAG_NOWAIT): Define.

libgomp/ChangeLog:

	* icv-device.c (omp_set_default_device): Check
	GOMP_DEVICE_DEFAULT_OMP_61.
	* libgomp-plugin.h (struct interop_obj_t): New.
	(enum gomp_interop_flag): New.
	(GOMP_OFFLOAD_interop): Declare.
	(GOMP_OFFLOAD_get_interop_int): Declare.
	(GOMP_OFFLOAD_get_interop_ptr): Declare.
	(GOMP_OFFLOAD_get_interop_str): Declare.
	(GOMP_OFFLOAD_get_interop_type_desc): Declare.
	* libgomp.h (_LIBGOMP_OMP_LOCK_DEFINED): Define.
	(struct gomp_device_descr): Add interop_func, get_interop_int_func,
	get_interop_ptr_func, get_interop_str_func, get_interop_type_desc_func.
	* libgomp.map: Add GOMP_interop.
	* libgomp_g.h (GOMP_interop): Declare.
	* target.c (resolve_device): Handle GOMP_DEVICE_DEFAULT_OMP_61.
	(omp_get_interop_int): Replace stub with actual implementation.
	(omp_get_interop_ptr): Likewise.
	(omp_get_interop_str): Likewise.
	(omp_get_interop_type_desc): Likewise.
	(struct interop_data_t): Define.
	(gomp_interop_internal): New function.
	(GOMP_interop): Likewise.
	(gomp_load_plugin_for_device): Load symbols for get_interop_int,
	get_interop_ptr, get_interop_str and get_interop_type_desc.
	* testsuite/libgomp.c-c++-common/interop-1.c: New test.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/interop-1.c: Remove dg-prune-output "sorry".
	* c-c++-common/gomp/interop-2.c: Likewise.
	* c-c++-common/gomp/interop-3.c: Likewise.
	* c-c++-common/gomp/interop-4.c: Remove dg-message "not supported".
	* g++.dg/gomp/interop-5.C: Likewise.
	* gfortran.dg/gomp/interop-4.f90: Likewise.
	* c-c++-common/gomp/interop-5.c: New test.
	* gfortran.dg/gomp/interop-5.f90: New test.

Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
2025-03-21 19:24:16 +01:00
Jerry DeLisle
f45d14b495 Fortran: Fix typo in error message.
PR fortran/119406

gcc/fortran/ChangeLog:

	* resolve.cc (resolve_locality_spec): Add space in error
	message.
2025-03-21 10:34:08 -07:00
Jerry DeLisle
00cbf03029 Fortran: Fix typo in error message.
PR fortran/119403

gcc/fortran/ChangeLog:

	* interface.cc (compare_parameter): Fix typo.
2025-03-21 10:13:37 -07:00
Jason Merrill
ab716829da ipa: target clone and mangling alias [PR114992]
Since the mangling of the second lambda changed (previously we counted all
lambdas, now we only count lambdas with the same signature), we
generate_mangling_alias for handler<lambda2> for backward compatibility.
Since handler is COMDAT, resolve_alias puts the alias in the same comdat
group as handler itself.  Then create_dispatcher_calls tries to add the
alias to the same comdat group as the dispatcher, but it's already in a
same_comdat_group, so we ICE.

It seems like we're just missing a remove_from_same_comdat_group before
add_to_same_comdat_group.

	PR c++/114992

gcc/ChangeLog:

	* multiple_target.cc (create_dispatcher_calls):
	remove_from_same_comdat_group before add_to_same_comdat_group.

gcc/testsuite/ChangeLog:

	* g++.target/i386/mangling-alias1.C: New test.
2025-03-21 12:45:00 -04:00
Paul Thomas
94fa9f4d27 Fortran: Implement the F2018 reduce intrinsic [PR85836]
2025-03-21  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/85836
	* check.cc (get_ul_from_cst_cl): New function used in
	check_operation.
	(check_operation): New function used in check_reduce and
	check_co_reduce.
	(gfc_check_co_reduce): Use it.
	(gfc_check_reduce): New function.
	(gfc_check_rename): Add prototype for intrinsic with 6 arguments.
	* gfortran.h : Add isym id for reduce and prototype for f6.
	* intrinsic.cc (do_check): Add another argument expression and use
	it in the call to the six argument specific check.
	(add_sym_6): New function.
	(add_functions): Add the discription of the reduce intrinsic and
	add it to the intrinsic list.
	* intrinsic.h : Add prototypes for gfc_check_reduce and
	gfc_resolve_reduce.
	* iresolve.cc (generate_reduce_op_wrapper): Generate a wrapper
	subroutine for the 'operation' function to enable the library
	implementation to be type agnostic and use pointer arithmetic
	throughout.
	(gfc_resolve_reduce): New function.
	* trans-expr.cc (gfc_conv_procedure_call): Add flag for scalar
	reduce. Generate a return variable 'sr' for scalar reduce, pass its
	address to the library function and return it as the scalar result.
	* trans-intrinsic.cc (gfc_conv_intrinsic_function): Array valued
	reduce is called in same way as reshape. Fall through for call to
	the scalar version.

gcc/testsuite/
	PR fortran/85836
	* gfortran.dg/reduce_1.f90: New test
	* gfortran.dg/reduce_2.f90: New test

libgfortran/
	PR libfortran/85836
	* Makefile.am : Add reduce.c
	* Makefile.in : Regenerated
	* gfortran.map : Add _gfortran_reduce, _gfortran_reduce_scalar,
	_gfortran_reduce_c and _gfortran_reduce_scalar_c to the list.
	* intrinsics/reduce.c (reduce, reduce_scalar, reduce_c,
	reduce_scalar_c): New functions and prototypes
2025-03-21 16:20:21 +00:00
Richard Earnshaw
1d2257dc85 arm: testsuite: make unaligned-memcpy-*.c executable tests [PR91614]
These tests have been looking for a very specific instruction sequence
which has the tendency to be fairly unstable as a result.  But what is
more interesting is that the the tests must not contain instructions
that can't be used for unaligned data, and whether or not the copy is
executed correctly.

So make these tests executable and scan the assembler only to confirm
the absence of instructions that must not be used when the data is not
aligned.

These tests also used to be restricted to targets that support
unaligned accesses (because you get very different code otherwise).
But now we've made the tests executable and to check for the absence
of problem instructions, just falling back to memcpy *is* an
acceptable implementation.  So remove the requirement for unaligned
accesses.

gcc/testsuite:
	PR target/91614
	* gcc.target/arm/unaligned-memcpy-1.c: Make the test executable.
	Only scan for the absence of instructions that cannot access
	misaligned data.  Remove constraint of having unaligned accesses.
	* gcc.target/arm/unaligned-memcpy-2.c: Likewise.
	* gcc.target/arm/unaligned-memcpy-3.c: Likewise.
	* gcc.target/arm/unaligned-memcpy-4.c: Likewise.
2025-03-21 15:32:59 +00:00
Richard Earnshaw
b1ac0c5f19 arm: testsuite: memcpy-aligned requires unaligned accesses
This test is designed to check that if one of the operands is
aligned (but the other isn't) we expand to a sensible sequence and
bypass most of the overhead of doing a memcpy.  But on targets without
unaligned accessess, we still end up calling memcpy.  It's then a
lottery as to whether the prologue and epilogue code, plus the
set-up for the memcpy itself, generate instructions that match the
scan patterns.

Since in those cases we're not actually testing what the test is looking
for anyway, just skip the test on strict-alignment targets.

gcc/testsuite:
	* gcc.target/arm/memcpy-aligned-1.c: Require unaligned accesses.
2025-03-21 15:32:59 +00:00
Jason Merrill
cb537f0d83 c++: fix return type of __cxa_bad_array_new_length
We were lying about the return type, but that's not necessary; we already
need to handle a COND_EXPR where one side is void for THROW_EXPR.

This fixes an execution failure on nvptx:
error: Prototype doesn't match for '__cxa_throw_bad_array_new_length'

gcc/cp/ChangeLog:

	* init.cc (throw_bad_array_new_length): Returns void.
2025-03-21 11:04:56 -04:00
Thomas Schwinge
618c42d237 C++: Adjust implicit '__cxa_bad_cast' prototype to reality
In 2001 Subversion r40924 (Git commit 52a11cbfcf)
"IA-64 ABI Exception Handling", '__cxa_bad_cast' changed from 'void *' to
'void' return type:

    --- libstdc++-v3/libsupc++/exception_support.cc
    +++ /dev/null
    @@ -1,388 +0,0 @@
    -[...]
    -// Helpers for rtti. Although these don't return, we give them return types so
    -// that the type system is not broken.
    -extern "C" void *
    -__cxa_bad_cast ()
    -{
    -  [...]
    -}
    -[...]

    --- /dev/null
    +++ libstdc++-v3/libsupc++/unwind-cxx.h
    @@ -0,0 +1,163 @@
    +[...]
    +extern "C" void __cxa_bad_cast ();
    +[...]

    --- /dev/null
    +++ libstdc++-v3/libsupc++/eh_aux_runtime.cc
    @@ -0,0 +1,56 @@
    +[...]
    +extern "C" void
    +__cxa_bad_cast ()
    +{
    +  [...]
    +}
    +[...]

The implicit prototype in the C++ front end however wasn't likewise adjusted,
and so for nvptx we generate code for 'void *' return type:

    // BEGIN GLOBAL FUNCTION DECL: __cxa_bad_cast
    .extern .func (.param .u64 %value_out) __cxa_bad_cast;

    {
    .param .u64 %value_in;
    call (%value_in),__cxa_bad_cast;
    trap;
    // (noreturn)
    exit;
    // (noreturn)
    ld.param.u64 %r30,[%value_in];
    }

..., which is in conflict with the library code with 'void' return type:

    // BEGIN GLOBAL FUNCTION DECL: __cxa_bad_cast
    .visible .func __cxa_bad_cast;

    // BEGIN GLOBAL FUNCTION DEF: __cxa_bad_cast
    .visible .func __cxa_bad_cast
    {
    [...]
    }

..., and we thus get execution test FAIL for 'g++.dg/rtti/dyncast2.C':

    error   : Prototype doesn't match for '__cxa_bad_cast' in 'input file 7 at offset 51437', first defined in 'input file 7 at offset 51437'
    nvptx-run: cuLinkAddData failed: device kernel image is invalid (CUDA_ERROR_INVALID_SOURCE, 300)

With this patched, we get the expected:

     // BEGIN GLOBAL FUNCTION DECL: __cxa_bad_cast
    -.extern .func (.param .u64 %value_out) __cxa_bad_cast;
    +.extern .func __cxa_bad_cast;

     {
    -.param .u64 %value_in;
    -call (%value_in),__cxa_bad_cast;
    +call __cxa_bad_cast;
     trap;
     // (noreturn)
     exit;
     // (noreturn)
    -ld.param.u64 %r30,[%value_in];
     }

..., and execution test PASS.

	gcc/cp/
	* rtti.cc (throw_bad_cast): Adjust implicit '__cxa_bad_cast'
	prototype to reality.
2025-03-21 15:35:18 +01:00
Thomas Schwinge
f7f6a3dd82 Add 'g++.target/nvptx/alias-g++.dg_init_dtor2-2.C'
... next to '-malias' variant: commit a1865fd338
"Add 'g++.target/nvptx/alias-g++.dg_init_dtor2-1.C'", to document what we're
doing to '-mno-alias'.

	gcc/testsuite/
	* g++.target/nvptx/alias-g++.dg_init_dtor2-2.C: New.
2025-03-21 15:34:42 +01:00
Thomas Schwinge
6d3a48baac Add 'gcc.target/nvptx/alias-unsupported-1.c'
... testing for the GCC/nvptx "alias definitions not supported" error
diagnostic.

	gcc/testsuite/
	* gcc.target/nvptx/alias-unsupported-1.c: New.
2025-03-21 15:34:42 +01:00
Tobias Burnus
12db61156f testsuite/lib/libgomp.exp: compile with -fdiagnostics-plain-output
libgomp.exp added -fno-diagnostics-show-caret and -fdiagnostics-color=never
as 'additional_flags' for compilation. However, it turned out that this now
is insufficient as the [...] part of diagnostics have a hyperlink URL.

Solution: Use the -fdiagnostics-plain-output flag instead, added in commit
r11-2701-g129a1319c0ab73. This flag currently implies the following flags:
   -fno-diagnostics-show-caret
   -fno-diagnostics-show-line-numbers
   -fdiagnostics-color=never
   -fdiagnostics-urls=never
   -fdiagnostics-path-format=separate-events
   -fdiagnostics-text-art-charset=none
   -fno-diagnostics-show-event-links

libgomp/ChangeLog:

	* testsuite/lib/libgomp.exp (libgomp_init): Add
	-fdiagnostics-plain-output to additional_flags; remove
	-fno-diagnostics-show-caret and -fdiagnostics-color=never.
2025-03-21 13:54:49 +01:00
Andre Vehreschild
a5c69abf13 Fortran: Fix freeing procedure pointer components [PR119380]
PR fortran/119380

gcc/fortran/ChangeLog:

	* trans-array.cc (structure_alloc_comps): Prevent freeing of
	procedure pointer components.

gcc/testsuite/ChangeLog:

	* gfortran.dg/proc_ptr_comp_54.f90: New test.
2025-03-21 13:31:55 +01:00
Arthur Cohen
adbbf12a8f gccrs: nr2.0: late: Better format PathInExpression resolution
gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Improve formatting.
2025-03-21 12:57:51 +01:00
Arthur Cohen
adba3fff2d gccrs: derive(Clone): Add lang item typepaths failure testcases to nr2 exclude
gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: Add failing lang item typepaths tests.
	* rust/execute/torture/derive_macro4.rs: Mark Clone as lang item.
2025-03-21 12:57:51 +01:00
Arthur Cohen
00c48701f1 gccrs: derive(Clone): Implement derive clone for enum struct variants
gcc/rust/ChangeLog:

	* expand/rust-derive-clone.cc (DeriveClone::clone_enum_struct): New function for deriving
	enum struct variants.
	(DeriveClone::visit_enum): Call into the new function.

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude:
	* rust/compile/derive_clone_enum1.rs: New test.
	* rust/compile/derive_clone_enum2.rs: New test.
	* rust/compile/derive_clone_enum3.rs: New test.
	* rust/execute/torture/derive_clone_enum1.rs: New test.
2025-03-21 12:57:51 +01:00
Arthur Cohen
2c5d4994ed gccrs: derive(Clone): Implement clone for enum tuple variants
gcc/rust/ChangeLog:

	* expand/rust-derive-clone.cc (DeriveClone::variant_match_path): New function.
	(DeriveClone::clone_enum_identifier): Rename.
	(DeriveClone::clone_enum_tuple): New function.
	(DeriveClone::visit_enum): Visit tuple variants properly.
	* expand/rust-derive-clone.h: Declare new functions.
2025-03-21 12:57:51 +01:00
Arthur Cohen
8dedd0d11d gccrs: ast-builder: Add new methods for building structs
gcc/rust/ChangeLog:

	* ast/rust-ast-builder.cc: Add new methods for constructing struct exprs.
	* ast/rust-ast-builder.h: Mention how to build tuple expressions.
2025-03-21 12:57:51 +01:00
Arthur Cohen
4cbbaa71c1 gccrs: derive(Clone): Add deriving of simple enum variants
gcc/rust/ChangeLog:

	* expand/rust-derive-clone.cc: Clone enum identifier variants properly
	* expand/rust-derive-clone.h: Declare new functions used.
2025-03-21 12:57:51 +01:00
Arthur Cohen
5ec40be008 gccrs: derive(Clone): Improve existing testcase
gcc/testsuite/ChangeLog:

	* rust/compile/derive_macro4.rs: Mark Copy and Clone as lang items.
2025-03-21 12:57:51 +01:00
Arthur Cohen
72ad259a22 gccrs: derive(Clone): Add note about Clone::clone()
gcc/rust/ChangeLog:

	* expand/rust-derive-clone.cc (DeriveClone::clone_call): Mention using `clone_fn`
	lang item in the future.
2025-03-21 12:57:51 +01:00
Arthur Cohen
d8c11ccefb gccrs: derive(Clone): Use lang item for PhantomData in Clone
gcc/rust/ChangeLog:

	* expand/rust-derive-clone.cc (DeriveClone::visit_union): Create a lang item path
	instead of a regular path.
2025-03-21 12:57:50 +01:00
Arthur Cohen
f6cdae89d1 gccrs: ast-builder: Add new methods around type paths.
gcc/rust/ChangeLog:

	* ast/rust-ast-builder.cc: New functions.
	* ast/rust-ast-builder.h: Declare them.
2025-03-21 12:57:50 +01:00
Arthur Cohen
a728f5f19a gccrs: derive(Copy): Use copy lang item when deriving Copy.
gcc/rust/ChangeLog:

	* expand/rust-derive-copy.cc: Use lang item path.
2025-03-21 12:57:50 +01:00
Arthur Cohen
9bc5deb919 gccrs: derive(Clone): Mark PhantomData as a lang item
gcc/testsuite/ChangeLog:

	* rust/compile/derive_macro4.rs: Make PhantomData a lang item.
2025-03-21 12:57:50 +01:00
Arthur Cohen
41cd035570 gccrs: derive(Clone): Manually generate AssertParamIsCopy struct for unions
gcc/rust/ChangeLog:

	* expand/rust-derive-clone.cc (DeriveClone::visit_union): Manually generate
	the struct used for asserting a union implements Copy.
2025-03-21 12:57:50 +01:00
Arthur Cohen
58d035551b gccrs: builder: Allow generating struct statements
gcc/rust/ChangeLog:

	* ast/rust-ast-builder.cc (Builder::struct_struct): New function.
	* ast/rust-ast-builder.h (vec): New function.
2025-03-21 12:57:50 +01:00
Arthur Cohen
8f65a00131 gccrs: lang-items: Mark Clone trait as a lang item in testsuite
gcc/testsuite/ChangeLog:

	* rust/compile/derive_macro1.rs: Add #[lang = "clone"] to Clone trait.
	* rust/compile/derive_macro3.rs: Likewise.
	* rust/compile/derive_macro6.rs: Likewise.
	* rust/execute/torture/derive_macro3.rs: Likewise.
2025-03-21 12:57:50 +01:00
Arthur Cohen
5d3afe339b gccrs: ast-collector: Fix tuple struct pattern collection
gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit): Visit tuple pattern items as
	separated by commas.
2025-03-21 12:57:50 +01:00
Arthur Cohen
1c9cd6a601 gccrs: ast-collector: Adapt to lang item type path segments
gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit): Fix collector to better
	handle lang item type path segments.
2025-03-21 12:57:50 +01:00
Arthur Cohen
4d0cfd5b6f gccrs: mappings: Add get_lang_item_node
This method errors out if the lang item has not been declared yet.

gcc/rust/ChangeLog:

	* util/rust-hir-map.cc (Mappings::get_lang_item_node): New.
	* util/rust-hir-map.h: New function.
2025-03-21 12:57:49 +01:00
Arthur Cohen
5702b0a24e gccrs: lang-item: Add LangItem::PrettyString
Which formats a lang item as it appears in source code.

gcc/rust/ChangeLog:

	* util/rust-lang-item.cc (LangItem::PrettyString): New.
	* util/rust-lang-item.h: New.
2025-03-21 12:57:49 +01:00
Arthur Cohen
88aeeccaca gccrs: lang-items: Collect struct lang items.
gcc/rust/ChangeLog:

	* ast/rust-collect-lang-items.cc (CollectLangItems::visit): New.
	* ast/rust-collect-lang-items.h: New.
2025-03-21 12:57:49 +01:00
Arthur Cohen
01504790ad gccrs: lower: Properly lower non-generic lang item type path segments.
gcc/rust/ChangeLog:

	* hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Adapt code to lang item
	type path segments.
2025-03-21 12:57:49 +01:00
Arthur Cohen
8e7d9ae2ff gccrs: tychk: resolve lang item type paths properly
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Adapt
	code to handle lang item type paths.
2025-03-21 12:56:57 +01:00
Arthur Cohen
63023c0328 gccrs: ast: Refactor how lang item paths are handled.
Lang item typepaths were not handled properly, and required a complete overhaul.
All old classes that concerned lang item paths are now modified to use a simpler
version of `AST::LangItemPath`, which has been removed. TypePath segments can now
be lang items, as this is requied for having generic lang item paths such as
PhantomData<T>.

gcc/rust/ChangeLog:

	* ast/rust-path.h: Rework how lang item paths are represented.
	* ast/rust-path.cc: Likewise.
	* ast/rust-item.h: Likewise.
	* ast/rust-ast.cc: Likewise.
	* ast/rust-ast-collector.cc: Adapt to new lang item path system.
	* ast/rust-ast-collector.h: Likewise.
	* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
	* ast/rust-ast-visitor.h: Likewise.
	* expand/rust-derive-copy.cc: Likewise.
	* expand/rust-derive.h: Likewise.
	* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
	* hir/rust-ast-lower-base.h: Likewise.
	* hir/rust-ast-lower-type.cc (ASTLowerTypePath::translate): Likewise.
	(ASTLowerTypePath::visit): Likewise.
	* hir/rust-ast-lower-type.h: Likewise.
	* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise.
	* resolve/rust-ast-resolve-base.h: Likewise.
	* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Likewise.
	* resolve/rust-ast-resolve-type.h: Likewise.
	* resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise.
	* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise.
	* resolve/rust-late-name-resolver-2.0.h: Likewise.
	* hir/tree/rust-hir-path.cc (TypePathSegment::TypePathSegment): Likewise.
	(TypePathSegmentGeneric::TypePathSegmentGeneric): Likewise.
	* hir/tree/rust-hir-path.h: Likewise.
	* typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Likewise.
	* ast/rust-ast-builder.cc: Likewise.
	* ast/rust-ast-builder.h: Likewise.
2025-03-21 12:56:57 +01:00
Arthur Cohen
20d4c59e24 gccrs: collect-lang-items: Display attribute upon error finding it
gcc/rust/ChangeLog:

	* ast/rust-collect-lang-items.cc (get_lang_item_attr): Show unknown attribute upon error.
2025-03-21 12:56:57 +01:00
Arthur Cohen
1d0be88926 gccrs: attributes: Add #[derive] as a built-in attribute
gcc/rust/ChangeLog:

	* util/rust-attribute-values.h: Declare new attribute value.
	* util/rust-attributes.cc: Use it.
2025-03-21 12:56:57 +01:00
Arthur Cohen
5925402663 gccrs: ast: Fix warning about copy elision for moved expr
gcc/rust/ChangeLog:

	* ast/rust-ast.cc (BlockExpr::normalize_tail_expr): Remove overzealous
	std::move
2025-03-21 12:56:57 +01:00
Owen Avery
3a82942eaa gccrs: Remove dead code related to external functions
gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc
	(TokenCollector::visit): Remove visitor for NamedFunctionParam.
	* ast/rust-ast-collector.h
	(TokenCollector::visit): Likewise.
	* ast/rust-ast-full-decls.h
	(class NamedFunctionParam): Remove forward declaration.
	* ast/rust-ast-visitor.cc
	(DefaultASTVisitor::visit): Remove visitor for
	NamedFunctionParam.
	* ast/rust-ast-visitor.h
	(DefaultASTVisitor::visit): Likewise.
	* ast/rust-ast.cc
	(NamedFunctionParam::as_string): Remove.
	* ast/rust-item.h
	(class NamedFunctionParam): Remove.
	(class ExternalFunctionItem): Remove.
	* parse/rust-parse-impl.h
	(Parser::parse_named_function_param): Remove.
	(Parser::parse_named_function_params): Remove.
	* parse/rust-parse.h
	(Parser::parse_named_function_param): Remove.
	(Parser::parse_named_function_params): Remove.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-21 12:56:57 +01:00
Owen Avery
c9f85323b5 gccrs: nr2.0: Early resolve pending eager macro invocations
gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc
	(Early::visit): Resolve the pending eager invocations inside
	builtin macro invocations.

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-21 12:56:57 +01:00
Philip Herron
c0681b527a gccrs: Add missing name resolution to static items in blocks
We need to add name resolution and hir lowering for items as part of blocks
in order to typecheck and compile them correctly.

Fixes Rust-GCC#3350

gcc/rust/ChangeLog:

	* hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): hir lowering
	* hir/rust-ast-lower-stmt.h: likewise
	* resolve/rust-ast-resolve-stmt.cc (ResolveStmt::visit): name resolution
	* resolve/rust-ast-resolve-stmt.h: likewise

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3350.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-21 12:56:57 +01:00
CohenArthur
29367fe699 gccrs: Revert "gcc/rust/ChangeLog:"
This reverts commit 600fd806b8.
2025-03-21 12:56:57 +01:00
Arthur Cohen
36ac388bf9 gccrs: Fix scan-gimple testcases on LE platforms.
gcc/testsuite/ChangeLog:

	* rust/compile/macros/builtin/eager1.rs: Switch to scan-assembler directive as the
	GIMPLE dump does not contain strings on LE.
	* rust/compile/macros/builtin/recurse2.rs: Likewise.
2025-03-21 12:56:57 +01:00
Arthur Cohen
ffecc9a972 gccrs: testsuite: Fix missing handling of little endian.
Some failures occur in the testsuite because we
did not account for the little-endian case.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-1446.rs: Add swap_bytes function.
	* rust/compile/iterators1.rs: Remove unused {to, from}_le functions.
2025-03-21 12:56:56 +01:00
Owen Avery
469d668f6f gccrs: Add ForeverStackStore
ForeverStackStore is meant to partially unify the internal states of
per-namespace ForeverStack instances. This commit does not contain
modifications to ForeverStack which would allow it to rely on a
ForeverStackStore to store nodes, but a future commit should address
this.

gcc/rust/ChangeLog:

	* Make-lang.in: Handle rust-forever-stack.cc.
	* resolve/rust-forever-stack.h
	(class ForeverStackStore): Add.
	* resolve/rust-forever-stack.cc: New file, based on
	rust-forever-stack.hxx.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-21 12:56:56 +01:00
Om Swaroop Nayak
7fd3007310 gccrs: gcc/rust/ChangeLog:
* ast/rust-collect-lang-items.cc (get_lang_item_attr): "removed checker fn"
	* util/rust-attributes.cc (Attributes::is_lang_item): "added fn"
	* util/rust-attributes.h: "added fn"

Signed-off-by: Om Swaroop Nayak <96killerat96@gmail.com>
2025-03-21 12:56:56 +01:00
Philip Herron
770ca551cf gccrs: improve mutability checks
This ensures that we handle var decls readonly checks much better

Addresses: Rust-GCC#807 Rust-GCC#3287

gcc/rust/ChangeLog:

	* checks/errors/rust-readonly-check.cc (check_decl): improve mut check
	(emit_error): helper
	(check_modify_expr): likewise
	(readonly_walk_fn): reuse helper
	(ReadonlyCheck::Lint): cleanup context each run

gcc/testsuite/ChangeLog:

	* rust/execute/torture/builtin_macro_include_bytes.rs: needs mut
	* rust/compile/mutability_checks1.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-21 12:56:56 +01:00
Owen Avery
76565cabf2 gccrs: Visit the trait paths of trait implementations
gcc/rust/ChangeLog:

	* ast/rust-ast-visitor.cc
	(DefaultASTVisitor::visit): When visiting a TraitImpl, visit its
	trait path.

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-21 12:56:56 +01:00
liushuyu
5b7583c68a gccrs: add two more tests to test try-catch (unwind) code generation
gcc/testsuite/ChangeLog:
	* rust/compile/try-catch-unwind-old.rs: add a test to test the older
	try intrinsics from plain old Rust to v1.78.0
	* rust/compile/try-catch-unwind-new.rs: add a test to test the newer
	catch_unwind instrinsics since Rust v1.78.0
2025-03-21 12:56:56 +01:00