GCC Administrator [Tue, 11 Apr 2023 00:16:33 +0000 (00:16 +0000)]
Daily bump.
Michael Meissner [Mon, 10 Apr 2023 03:32:27 +0000 (23:32 -0400)]
Do not generate vmaddfp and vnmsubfp
This is version 3 of the patch. This is essentially version 1 with the removal
of changes to altivec.md, and cleanup of the comments.
Version 2 generated the vmaddfp and vnmsubfp instructions if -Ofast was used,
and those changes are deleted in this patch.
The Altivec instructions vmaddfp and vnmsubfp have different rounding behaviors
than the VSX xvmaddsp and xvnmsubsp instructions due to VSCR[NJ] and other
corner cases. In particular, generating these instructions seems to break
Eigen on big endian systems.
2023-04-09 Michael Meissner <meissner@linux.ibm.com>
gcc/
PR target/70243
* config/rs6000/vsx.md (vsx_fmav4sf4): Do not generate vmaddfp.
(vsx_nfmsv4sf4): Do not generate vnmsubfp.
gcc/testsuite/
PR target/70243
* gcc.target/powerpc/pr70243.c: New test.
Haochen Jiang [Fri, 31 Mar 2023 02:49:14 +0000 (10:49 +0800)]
i386: Add AMX-COMPLEX to Granite Rapids
gcc/Changelog:
* config/i386/i386.h (PTA_GRANITERAPIDS): Add PTA_AMX_COMPLEX.
Haochen Jiang [Wed, 31 May 2023 02:45:00 +0000 (10:45 +0800)]
Support Intel AMX-COMPLEX
gcc/ChangeLog:
* common/config/i386/cpuinfo.h (get_available_features):
Detect AMX-COMPLEX.
* common/config/i386/i386-common.cc
(OPTION_MASK_ISA2_AMX_COMPLEX_SET,
OPTION_MASK_ISA2_AMX_COMPLEX_UNSET): New.
(ix86_handle_option): Handle -mamx-complex.
* common/config/i386/i386-cpuinfo.h (enum processor_features):
Add FEATURE_AMX_COMPLEX.
* common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for
amx-complex.
* config.gcc: Add amxcomplexintrin.h.
* config/i386/cpuid.h (bit_AMX_COMPLEX): New.
* config/i386/i386-c.cc (ix86_target_macros_internal): Define
__AMX_COMPLEX__.
* config/i386/i386-isa.def (AMX_COMPLEX): Add DEF_PTA(AMX_COMPLEX).
* config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p):
Handle amx-complex.
* config/i386/i386.opt: Add option -mamx-complex.
* config/i386/immintrin.h: Include amxcomplexintrin.h.
* doc/extend.texi: Document amx-complex.
* doc/invoke.texi: Document -mamx-complex.
* doc/sourcebuild.texi: Document target amx-complex.
* config/i386/amxcomplexintrin.h: New file.
gcc/testsuite/ChangeLog:
* g++.dg/other/i386-2.C: Add -mamx-complex.
* g++.dg/other/i386-3.C: Ditto.
* gcc.target/i386/amx-check.h: Add cpu check for AMX-COMPLEX.
* gcc.target/i386/amx-helper.h: Add amx-complex support.
* gcc.target/i386/funcspec-56.inc: Add new target attribute.
* gcc.target/i386/sse-12.c: Add -mamx-complex.
* gcc.target/i386/sse-13.c: Ditto.
* gcc.target/i386/sse-14.c: Ditto.
* gcc.target/i386/sse-22.c: Add amx-complex.
* gcc.target/i386/sse-23.c: Ditto.
* lib/target-supports.exp (check_effective_target_amx_complex): New.
* gcc.target/i386/amxcomplex-asmatt-1.c: New test.
* gcc.target/i386/amxcomplex-asmintel-1.c: Ditto.
* gcc.target/i386/amxcomplex-cmmimfp16ps-2.c: Ditto.
* gcc.target/i386/amxcomplex-cmmrlfp16ps-2.c: Ditto.
GCC Administrator [Mon, 10 Apr 2023 00:16:39 +0000 (00:16 +0000)]
Daily bump.
Iain Sandoe [Sat, 1 Apr 2023 16:23:51 +0000 (21:53 +0530)]
c++, coroutines: Fix block nests when the function has no top-level bind.
When the function contains no local vars and also no nested scopes, there
is no top-level bind expression. Because the rewritten coroutine body will
require both local vars and contain nested scopes, we add a bind expression
to such functions. When this was done the necessary scope blocks were
omitted which leads to disconnected function content.
Fixed by adding a new block to the added bind expression.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/cp/ChangeLog:
* coroutines.cc (coro_rewrite_function_body): Ensure that added
bind expressions have scope blocks.
GCC Administrator [Sun, 9 Apr 2023 00:16:37 +0000 (00:16 +0000)]
Daily bump.
Jakub Jelinek [Sat, 8 Apr 2023 18:21:42 +0000 (12:21 -0600)]
PR tree-optimization/109392
If we have an object with SSA_NAME_OCCURS_IN_ABNORMAL_PHI, then
maybe_push_res_to_seq may fail. Directly build the extraction
for that case.
PR tree-optimization/109392
gcc/
* tree-vect-generic.cc (tree_vec_extract): Handle failure
of maybe_push_res_to_seq better.
gcc/testsuite/
* gcc.dg/pr109392.c: New test.
John David Anglin [Sat, 8 Apr 2023 17:25:25 +0000 (17:25 +0000)]
xfail gcc.dg/long_branch.c on hppa.
2023-04-08 John David Anglin <danglin@gcc.gnu.org>
gcc/testsuite/ChangeLog:
* gcc.dg/pr84877.c: xfail on hppa*-*-*.
John David Anglin [Sat, 8 Apr 2023 16:01:26 +0000 (16:01 +0000)]
Fix gcc.dg/long_branch.c on hppa.
2023-04-08 John David Anglin <danglin@gcc.gnu.org>
gcc/testsuite/ChangeLog:
* gcc.dg/long_branch.c: Use timeout factor 2.0 on hppa*-*-*.
Tetsuma Hoshino [Sat, 8 Apr 2023 14:19:53 +0000 (08:19 -0600)]
PR target/109402: v850 (not v850e) variant of __muldi3() moves sp in reversed direction [PR109402]
muldi3 will deallocate stack space after the call to __save_r26_r31,
then re-allocate the space a short while later. If an interrupt
occurs in that window, it can clobber items on the stack.
PR target/109402
libgcc/
* config/v850/lib1funcs.S (___muldi3): Remove unnecessary
stack manipulations.
Jakub Jelinek [Sat, 8 Apr 2023 10:05:04 +0000 (12:05 +0200)]
riscv: Fix genrvv-type-indexer dependencies
I've noticed
make: Circular build/genrvv-type-indexer.o <- gtype-desc.h dependency dropped.
The following patch fixes that. The RTL_BASE_H variable includes a lot of
headers which the generator doesn't include, including gtype-desc.h.
I've preprocessed it and checked all gcc/libiberty headers against what is
included in the other dependency variables and here is what I found:
1) coretypes.h includes align.h, poly-int.h and poly-int-types.h which
weren't listed (most of dependencies are thankfully done automatically,
so it isn't that big deal except for these generators and the like)
2) system.h includes filenames.h (already listed) but filenames.h includes
hashtab.h; instead of adding FILENAMES_H I've just added the dependency
to SYSTEM_H
3) $(RTL_BASE_H) wasn't really needed at all and insn-modes.h is already
included in $(CORETYPES_H)
2023-04-08 Jakub Jelinek <jakub@redhat.com>
* Makefile.in (CORETYPES_H): Depend on align.h, poly-int.h and
poly-int-types.h.
(SYSTEM_H): Depend on $(HASHTAB_H).
* config/riscv/t-riscv (build/genrvv-type-indexer.o): Remove unused
dependency on $(RTL_BASE_H), remove redundant dependency on
insn-modes.h.
Paul Thomas [Sat, 8 Apr 2023 08:04:13 +0000 (09:04 +0100)]
Fortran: Fix some of the bugs in associate [PR87477]
2023-04-08 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/87477
* iresolve.cc (gfc_resolve_adjustl, gfc_resolve_adjustr): if
string length is deferred use the string typespec for result.
* resolve.cc (resolve_assoc_var): Handle parentheses around the
target expression.
(resolve_block_construct): Remove unnecessary static decls.
* trans-array.cc (gfc_conv_expr_descriptor): Guard string len
expression in condition. Improve handling of string length and
span, especially for substrings of the descriptor.
(duplicate_allocatable): Make element type more explicit with
'eltype'.
* trans-decl.cc (gfc_get_symbol_decl): Emit a fatal error with
appropriate message instead of ICE if symbol type is unknown.
(gfc_generate_function_code): Set current locus to proc_sym
declared_at.
* trans-expr.cc (gfc_get_expr_charlen): Retain last charlen in
'previous' and use if end expression in substring reference is
null.
(gfc_conv_string_length): Use gfc_conv_expr_descriptor if
'expr_flat' is an array. Add post block to catch deallocation
of temporaries.
(gfc_conv_procedure_call): Assign the parmse string length to
the expression string length, if it is deferred.
(gfc_trans_alloc_subarray_assign): If this is a deferred string
length component, store the string length in the hidden comp.
Update the typespec length accordingly. Generate a new type
spec for the call to gfc_duplicate-allocatable in this case.
* trans-io.cc (gfc_trans_transfer): Scalarize transfer of
deferred character array components.
gcc/testsuite/
PR fortran/87477
* gfortran.dg/associate_47.f90 : Enable substring test.
* gfortran.dg/associate_51.f90 : Update an error message.
* gfortran.dg/goacc/array-with-dt-2.f90 : Add span to
uninitialzed dg-warnings.
PR fortran/85686
PR fortran/88247
PR fortran/91941
PR fortran/92779
PR fortran/93339
PR fortran/93813
PR fortran/100948
PR fortran/102106
* gfortran.dg/associate_60.f90 : New test
PR fortran/98408
* gfortran.dg/pr98408.f90 : New test
PR fortran/105205
* gfortran.dg/pr105205.f90 : New test
PR fortran/106918
* gfortran.dg/pr106918.f90 : New test
Paul Thomas [Sat, 8 Apr 2023 06:49:13 +0000 (07:49 +0100)]
Fortran: Fix dg directives and remove trailing whitespaces in testsuite
2023-04-08 Paul Thomas <pault@gcc.gnu.org>
* gfortran.dg/c-interop/allocatable-optional-pointer.f90 : Fix
dg directive and remove trailing whitespace.
* gfortran.dg/c-interop/c407a-1.f90 : ditto
* gfortran.dg/c-interop/c407b-1.f90 : ditto
* gfortran.dg/c-interop/c407b-2.f90 : ditto
* gfortran.dg/c-interop/c407c-1.f90 : ditto
* gfortran.dg/c-interop/c535a-1.f90 : ditto
* gfortran.dg/c-interop/c535a-2.f90 : ditto
* gfortran.dg/c-interop/c535b-1.f90 : ditto
* gfortran.dg/c-interop/c535b-2.f90 : ditto
* gfortran.dg/c-interop/c535b-3.f90 : ditto
* gfortran.dg/c-interop/c535c-1.f90 : ditto
* gfortran.dg/c-interop/c535c-2.f90 : ditto
* gfortran.dg/c-interop/deferred-character-1.f90 : ditto
* gfortran.dg/c-interop/removed-restrictions-1.f90 : ditto
* gfortran.dg/c-interop/removed-restrictions-2.f90 : ditto
* gfortran.dg/c-interop/removed-restrictions-4.f90 : ditto
* gfortran.dg/c-interop/tkr.f90 : ditto
* gfortran.dg/class_result_10.f90 : ditto
* gfortran.dg/dtio_35.f90 : ditto
* gfortran.dg/gomp/affinity-clause-1.f90 : ditto
* gfortran.dg/pr103258.f90 : ditto
* gfortran.dg/pr59107.f90 : ditto
* gfortran.dg/pr93835.f08 : ditto
GCC Administrator [Sat, 8 Apr 2023 00:16:33 +0000 (00:16 +0000)]
Daily bump.
Ian Lance Taylor [Fri, 7 Apr 2023 20:27:04 +0000 (13:27 -0700)]
mime: remove test ordering dependency
Backport CL 421442 from upstream.
Original description:
Arrange for tests that call setMimeInit to fully restore the old values,
by clearing the sync.Once that controls initialization.
Once we've done that, call initMime in initMimeUnixTest because
otherwise the test types loaded there will be cleared by the call to
initMime that previously was not being done.
For golang/go#51648
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/483117
Alexandre Oliva [Fri, 7 Apr 2023 04:04:32 +0000 (01:04 -0300)]
[testsuite] [ppc] skip ppc-fortran if fortran is disabled
Skip ppc-fortran.exp if a trivial fortran program cannot be compiled.
for gcc/testsuite/ChangeLog
* gcc.target/powerpc/ppc-fortran/ppc-fortran.exp: Test for
fortran compiler, skip if missing.
GCC Administrator [Fri, 7 Apr 2023 00:17:36 +0000 (00:17 +0000)]
Daily bump.
Stam Markianos-Wright [Thu, 6 Apr 2023 17:57:08 +0000 (18:57 +0100)]
arm: remove unused variables from test
This is just a minor issue I found with a previous test
of mine that caused it to fail in C++ mode due to these
unused const variables being uninitialised. I forgot to
remove these after removing some test cases that did use
them. I removed the test cases, because I came to the
conclusion that the const-ness of the immediate was
irrelevant to the test itself.
Removing the variables now makes the test PASS for C++.
gcc/testsuite/ChangeLog:
* gcc.target/arm/mve/intrinsics/mve_intrinsic_type_overloads-fp.c: Remove unused variables.
* gcc.target/arm/mve/intrinsics/mve_intrinsic_type_overloads-int.c: Remove unused variables.
Richard Earnshaw [Thu, 6 Apr 2023 13:44:30 +0000 (14:44 +0100)]
arm: mve: fix auto-inc generation [PR107674]
My change r13-416-g485a0ae0982abe caused the compiler to stop
generating auto-inc operations on mve loads and stores. The fix
is to check whether there is a replacement register available
when in strict mode and the register is still a pseudo.
gcc:
PR target/107674
* config/arm/arm.cc (arm_effective_regno): New function.
(mve_vector_mem_operand): Use it.
Andrew MacLeod [Wed, 5 Apr 2023 19:59:38 +0000 (15:59 -0400)]
Check if dependency is valid before using in may_recompute_p.
When the IL is rewritten after a statement has been processed and
dependencies cached, its possible that an ssa-name in the dependency
cache is no longer in the IL. Check this before trying to recompute.
PR tree-optimization/109417
gcc/
* gimple-range-gori.cc (gori_compute::may_recompute_p): Check if
dependency is in SSA_NAME_FREE_LIST.
gcc/testsuite/
* gcc.dg/pr109417.c: New.
Owen Avery [Fri, 27 Jan 2023 03:59:49 +0000 (22:59 -0500)]
gccrs: Fix issue with parsing unsafe block expression statements
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h
(Parser::parse_stmt): Handle unsafe expression statements.
gcc/testsuite/ChangeLog:
* rust/compile/issue-1422.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Fri, 27 Jan 2023 03:48:45 +0000 (22:48 -0500)]
gccrs: Address unsafe with/without block handling ambiguity
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h
(Parser::parse_expr_stmt): Remove hypothetical unsafe + expr_stmt_without_block handling.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
M V V S Manoj Kumar [Fri, 17 Feb 2023 18:09:56 +0000 (23:39 +0530)]
gccrs: Added AST Node AST::InlineAsm
Addresses #1567
Created a AST node InlineAsm similar to the one found in rustc.
As there is no Symbol struct/class in gccrs I have made every instance
of Symbol a string.
gcc/rust/ChangeLog:
* ast/rust-ast-full-decls.h (class InlineAsm):Added class declaration.
* ast/rust-expr.h (class InlineAsm):Added class definition.
Signed-off-by: M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
Arthur Cohen [Wed, 15 Feb 2023 15:56:07 +0000 (16:56 +0100)]
gccrs: diagnostic: Refactor Error class
The class now allows for more variants including a `Hint` one which
then gets emitted by calling `rust_inform`. This allows us to display
hints/tips/notes in backtracking contexts such as the parser.
gcc/rust/ChangeLog:
* rust-diagnostics.h (struct Error): Add new Kind enum and various new
static constructors to allow for hints as well.
* rust-diagnostics.cc (Error::Error): Use new `kind` field properly.
* checks/errors/privacy/rust-visibility-resolver.cc
(VisibilityResolver::resolve_module_path): Use new Error API.
* expand/rust-macro-builtins.cc (MacroBuiltin::include_handler): Likewise.
* expand/rust-macro-expand.cc (parse_many): Likewise.
(transcribe_type): Likewise.
* parse/rust-parse-impl.h (Parser::parse_crate): Likewise.
* rust-session-manager.cc (Session::handle_crate_name): Likewise.
* ast/rust-ast.cc (Module::load_items): Likewise.
Arthur Cohen [Wed, 15 Feb 2023 16:10:54 +0000 (17:10 +0100)]
gccrs: ast: Refactor TraitItem to keep Location info
gcc/rust/ChangeLog:
* ast/rust-ast.h: Keep location in TraitItem base class
* ast/rust-item.h (class TraitItemFunc): Use base class location instead.
(class TraitItemMethod): Likewise.
(class TraitItemConst): Likewise.
(class TraitItemType): Likewise.
* ast/rust-macro.h: Likewise.
Philip Herron [Thu, 16 Feb 2023 16:14:23 +0000 (16:14 +0000)]
gccrs: add test case to show our query-type system is working
Fixes #1361
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/testsuite/ChangeLog:
* rust/compile/issue-1361.rs: New test.
SainiAditya1 [Mon, 30 Jan 2023 17:07:08 +0000 (22:37 +0530)]
gccrs: rename rust-hir-full-tests.cc
gcc/rust/Changelog:
* hir/tree/rust-hir-full-test.cc: Moved to...
* hir/tree/rust-hir.cc: ...here.
* Make-lang.in: Rename rust-hir-full-test.
Signed-off-by: SainiAditya1 <Adityasaini10012001@outlook.com>
Thomas Schwinge [Tue, 14 Feb 2023 23:28:35 +0000 (00:28 +0100)]
gccrs: Fix up DejaGnu directives in 'rust/compile/issue-1830_{bytes,str}.rs' test cases [#1838]
'dg-excess-errors' "indicates that the test is expected to fail due to compiler
messages that are not handled by 'dg-error', [etc.]". It's argument doesn't
specify the message to match but just just a comment. Here, however, we'd like
to match specific compiler messages, so we should use 'dg-error', etc. Use the
magic line number zero as the compiler error diagnostic doesn't tell which line
the error occurred on (separate issue to resolve). This gives us:
-XFAIL: rust/compile/issue-1830_str.rs (test for excess errors)
+PASS: rust/compile/issue-1830_bytes.rs at line 8 (test for errors, line )
+PASS: rust/compile/issue-1830_bytes.rs (test for excess errors)
-XFAIL: rust/compile/issue-1830_bytes.rs (test for excess errors)
+PASS: rust/compile/issue-1830_str.rs at line 8 (test for errors, line )
+PASS: rust/compile/issue-1830_str.rs (test for excess errors)
Fix-up for recent GCC/Rust master branch #1838
commit
cf9ed4001eec6a22686d19a13f7de8ac94f9cb2a
"testsuite: Add empty string macro test".
gcc/testsuite/
* rust/compile/issue-1830_bytes.rs: Fix up DejaGnu directives.
* rust/compile/issue-1830_str.rs: Likewise.
Owen Avery [Tue, 14 Feb 2023 22:28:35 +0000 (17:28 -0500)]
gccrs: Add AST::AltPattern class
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc
(Dump::visit): Add AltPattern visitor.
* ast/rust-ast-dump.h:
(Dump::visit): Add AltPattern visitor.
* ast/rust-ast-full-decls.h
(class AltPattern): Add declaration.
* ast/rust-ast-visitor.h:
(ASTVisitor::visit): Add AltPattern visitor.
* ast/rust-ast.cc
(AltPattern::as_string): Add definition.
(AltPattern::accept_vis): Add definition.
* ast/rust-pattern.h
(class AltPattern): Add declaration.
* checks/errors/rust-feature-gate.h:
(FeatureGate::visit) Add AltPattern visitor
* expand/rust-attribute-visitor.cc
(AttrVisitor::visit): Add AltPattern visitor.
* expand/rust-attribute-visitor.h:
(AttrVisitor::visit): Add AltPattern visitor.
* hir/rust-ast-lower-base.cc
(ASTLoweringBase::visit): Add AltPattern visitor.
* hir/rust-ast-lower-base.h:
(ASTLoweringBase::visit): Add AltPattern visitor.
* resolve/rust-ast-resolve-base.cc
(ResolverBase::visit): Add AltPattern visitor.
* resolve/rust-ast-resolve-base.h:
(ResolverBase::visit): Add AltPattern visitor.
* resolve/rust-early-name-resolver.cc
(EarlyNameResolver::visit): Add AltPattern visitor.
* resolve/rust-early-name-resolver.h:
(EarlyNameResolver::visit): Add AltPattern visitor.
* util/rust-attributes.cc
(AttributeChecker::visit): Add AltPattern visitor.
* util/rust-attributes.h:
(AttributeChecker::visit): Add AltPattern visitor.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Wed, 15 Feb 2023 15:04:32 +0000 (10:04 -0500)]
gccrs: Fix formatting
gcc/rust/ChangeLog:
* ast/rust-pattern.h: Fix formatting.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Arthur Cohen [Wed, 15 Feb 2023 09:52:28 +0000 (10:52 +0100)]
gccrs: builtins: Return empty list of tokens instead of nullptr
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::include_handler): Do not
return nullptr token in expansion of `include!()`
gcc/testsuite/ChangeLog:
* rust/compile/empty.in: New test.
* rust/compile/include_empty.rs: New test.
Owen Avery [Tue, 14 Feb 2023 23:47:53 +0000 (18:47 -0500)]
gccrs: Add trailing newline
gcc/rust/ChangeLog:
* checks/errors/rust-feature-gate.h: Add trailing newline before EOF.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Philip Herron [Mon, 13 Feb 2023 22:22:06 +0000 (22:22 +0000)]
gccrs: Fix regression in testcase
Fixes #776
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/testsuite/ChangeLog:
* rust/compile/torture/traits10.rs: Fix test-case
Philip Herron [Mon, 13 Feb 2023 17:51:19 +0000 (17:51 +0000)]
gccrs: Support for Sized builtin marker trait
When implementing general bounds checking as part of unify calls, we did
not check associated types on bounds which lead to alot of missed error
checking. This now recursively checks the bounds and the associated types
with a decent error message. This also required us to implement the Sized
marker trait to keep existing test-cases happy.
Fixes #1725
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-reference.cc (TraitReference::clear_associated_types): make const
(TraitReference::clear_associated_type_projections): new interface
* typecheck/rust-hir-trait-reference.h:
* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): refactor
(TraitItemReference::associated_type_reset): reset projections
* typecheck/rust-hir-type-bounds.h:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): fix bounds
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::TypeBoundsProbe): refactor into cc file
(TypeBoundsProbe::Probe): refactor
(TypeBoundsProbe::is_bound_satisfied_for_type): likewise
(TypeBoundsProbe::assemble_sized_builtin): add builtin for Sized
(TypeCheckBase::get_predicate_from_bound): refactor
(TypeBoundPredicate::lookup_associated_type): refactor
* typecheck/rust-tyty-subst.cc (SubstitutionRef::lookup_associated_impl)
(SubstitutionRef::prepare_higher_ranked_bounds): new interface to clear hanging bounds
(SubstitutionRef::monomorphize): refactor
* typecheck/rust-tyty-subst.h:
* typecheck/rust-tyty.cc (BaseType::get_locus): helper
(BaseType::satisfies_bound): ensure bounds are satisfied and assoicated types
(ParamType::ParamType): new field in constructor
(ParamType::clone): update clone
(ParamType::set_implicit_self_trait): new interface
(ParamType::is_implicit_self_trait): likewise
* typecheck/rust-tyty.h: cleanup
* util/rust-hir-map.cc (Mappings::Mappings): builtin marker
(Mappings::~Mappings): delete marker
(Mappings::lookup_builtin_marker): lookup
* util/rust-hir-map.h: update header
gcc/testsuite/ChangeLog:
* rust/compile/issue-1725-1.rs: New test.
* rust/compile/issue-1725-2.rs: New test.
Philip Herron [Mon, 6 Feb 2023 17:48:06 +0000 (17:48 +0000)]
gccrs: Add new virtual function HIR::ImplItem::get_impl_item_name
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* hir/tree/rust-hir-item.h: implement virtual function
* hir/tree/rust-hir.h: add virtual function
Philip Herron [Mon, 6 Feb 2023 17:46:07 +0000 (17:46 +0000)]
gccrs: Extract query_type from TypeCheckBase to be a simple extern
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* Make-lang.in: add new dependancy
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::query_type): refactor
* typecheck/rust-hir-type-check-base.h: refactor
* typecheck/rust-hir-type-check.h (RUST_HIR_TYPE_CHECK): refactor
* typecheck/rust-type-util.cc: New file.
* typecheck/rust-type-util.h: New file.
Owen Avery [Sun, 8 Jan 2023 22:19:12 +0000 (17:19 -0500)]
gccrs: Implemented UTF-8 checking for include_str!()
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc
(MacroBuiltin::include_str_handler): Add check for valid UTF-8.
gcc/testsuite/ChangeLog:
* rust/compile/builtin_macro_include_str.rs:
Include test of invalid UTF-8.
* rust/compile/invalid_utf8: File with invalid UTF-8.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Tue, 14 Feb 2023 01:32:51 +0000 (20:32 -0500)]
gccrs: Add support for parsing empty tuple patterns.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h
(Parser::parse_grouped_or_tuple_pattern): Add support for empty tuple patterns.
gcc/testsuite/ChangeLog:
* rust/compile/parse_empty_tuple_pattern.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Pierre-Emmanuel Patry [Thu, 9 Feb 2023 17:24:42 +0000 (18:24 +0100)]
gccrs: testsuite: Add empty string macro test
Add two new tests with empty string for include_str and include_bytes
macros.
gcc/testsuite/ChangeLog:
* rust/compile/issue-1830_bytes.rs: New test.
* rust/compile/issue-1830_str.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Thu, 9 Feb 2023 09:47:15 +0000 (10:47 +0100)]
gccrs: lex: Prevent directories in RAIIFile
RAIIFile constructor was accepting directory filename. This lead to
unattended directory opening in some part of the code (load_file_bytes)
wich resulted in ice. Since RAIIFile are used for the lexer, removing
the ability to open directories with RAIIFile fixes those issues and
prevent future mistakes.
gcc/rust/ChangeLog:
* lex/rust-lex.h: Add file type check.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Owen Avery [Fri, 3 Feb 2023 15:19:32 +0000 (10:19 -0500)]
gccrs: Simplify WildcardPattern let statement handling
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc
(CompilePatternLet::visit): Simplify WildcardPattern compilation for let statements.
* backend/rust-compile-var-decl.h:
(CompileVarDecl::visit): Remove variable declaration for WildcardPattern.
* resolve/rust-ast-resolve-pattern.h:
(PatternDeclaration::visit): Remove name resolution for WildcardPattern.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Mon, 13 Feb 2023 16:29:07 +0000 (11:29 -0500)]
gccrs: Add test
gcc/testsuite/ChangeLog:
* rust/compile/variadic.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Fri, 10 Feb 2023 15:19:24 +0000 (10:19 -0500)]
gccrs: Add variadic argument type checking
gcc/rust/ChangeLog:
* typecheck/rust-tyty-call.cc
(TypeCheckCallExpr::visit): Add variadic argument type checking.
(TypeCheckCallExpr::visit): Fix comment spelling ("varadic").
gcc/testsuite/ChangeLog:
* rust/execute/torture/overflow1.rs: Fix test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
mxlol233 [Sun, 5 Feb 2023 13:17:34 +0000 (21:17 +0800)]
gccrs: Add feature gate for "rust-intrinsic".
This commit implemented a feature gate to check `intrinsics`.
gcc/rust/ChangeLog:
* checks/errors/rust-feature-gate.cc: Add implementation for
`void FeatureGate::visit (AST::ExternBlock &block)`. Add `valid_feature`
construction process in `FeatureGate::check`.
* checks/errors/rust-feature-gate.h: Add declaration for
`void FeatureGate::visit (AST::ExternBlock &block)`. Add private
variable `valid_feature`.
* checks/errors/rust-feature.h: Change `issue` to `m_issue`.
gcc/testsuite/ChangeLog:
* rust/compile/const-issue1440.rs: Add crate feature: `intrinsics`.
* rust/compile/feature_intrinsics.rs: New file.
* rust/compile/issue-1031.rs: Add crate feature: `intrinsics`.
* rust/compile/issue-1130.rs: Add crate feature: `intrinsics`.
* rust/compile/issue-1131.rs: Add crate feature: `intrinsics`.
* rust/compile/issue-1237.rs: Add crate feature: `intrinsics`.
* rust/compile/issue-1289.rs: Add crate feature: `intrinsics`.
* rust/compile/rust-const-blog-issue.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/intrinsics-3.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/intrinsics-4.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/intrinsics-5.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/intrinsics-6.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/intrinsics-7.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/issue-1024.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/issue-1075.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/issue-1432.rs: Add crate feature: `intrinsics`.
* rust/compile/unsafe10.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/atomic_load.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/atomic_store.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/copy_nonoverlapping1.rs: Add crate feature:
`intrinsics`.
* rust/execute/torture/issue-1120.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/issue-1133.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/issue-1232.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/slice-magic.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/slice-magic2.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/str-layout1.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/transmute1.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/wrapping_op1.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/wrapping_op2.rs: Add crate feature: `intrinsics`.
Signed-off-by: Xiao Ma <mxlol233@outlook.com>
Thomas Schwinge [Mon, 27 Feb 2023 12:53:50 +0000 (13:53 +0100)]
gccrs: Update copyright years.
gcc/rust/ChangeLog:
* ast/rust-ast-fragment.cc: Update copyright years.
* ast/rust-ast-fragment.h: Likewise.
* ast/rust-macro.cc: Likewise.
* checks/errors/rust-feature-gate.cc: Likewise.
* checks/errors/rust-feature-gate.h: Likewise.
* checks/errors/rust-feature.cc: Likewise.
* checks/errors/rust-feature.h: Likewise.
* hir/rust-ast-lower-expr.cc: Likewise.
* hir/rust-ast-lower-type.cc: Likewise.
* resolve/rust-early-name-resolver.cc: Likewise.
* resolve/rust-early-name-resolver.h: Likewise.
* rust-gcc.h: Likewise.
* typecheck/rust-hir-path-probe.cc: Likewise.
* typecheck/rust-hir-trait-reference.cc: Likewise.
* typecheck/rust-tyty-bounds.h: Likewise.
* typecheck/rust-tyty-subst.cc: Likewise.
* typecheck/rust-tyty-subst.h: Likewise.
* typecheck/rust-tyty-util.cc: Likewise.
* typecheck/rust-tyty-util.h: Likewise.
* typecheck/rust-unify.cc: Likewise.
* typecheck/rust-unify.h: Likewise.
* util/rust-inline-visitor.h: Likewise.
Pierre-Emmanuel Patry [Thu, 9 Feb 2023 10:32:50 +0000 (11:32 +0100)]
gccrs: cli: Update safety warning message
The compiler's warning message about the safety flag did not match
cargo-gccrs environment variable name anymore.
gcc/rust/ChangeLog:
* rust-session-manager.cc (Session::compile_crate): Update the
environment variable name.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Wed, 8 Feb 2023 15:19:41 +0000 (16:19 +0100)]
gccrs: typecheck: Refactor rust-hir-trait-reference.h
Move function body to their own cc file instead of keeping them in the
header file.
gcc/rust/ChangeLog:
* Make-lang.in: Add `rust-hir-trait-reference.o`.
* typecheck/rust-hir-trait-reference.h: Remove multiple function body.
* typecheck/rust-hir-trait-reference.cc: Add multiple function body.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Arthur Cohen [Wed, 8 Feb 2023 11:23:06 +0000 (12:23 +0100)]
gccrs: expander: Add documentation for `expand_eager_invocations`
gcc/rust/ChangeLog:
* expand/rust-macro-expand.cc (MacroExpander::expand_eager_invocations):
Add documentation explaining the algorithm.
Arthur Cohen [Wed, 18 Jan 2023 11:23:03 +0000 (12:23 +0100)]
gccrs: macros: Perform macro expansion in a fixed-point fashion.
This commit changes our macro expansion system from an eager and recursive
macro expansion to a fixed-point like system. Instead of, when seeing
a macro invocation, expanding it and all of the macros within it, we
now perform multiple passes of expansion on the entire crate.
This, however, leads to a problem. Rust macros are expanded lazily, but
Rust builtin macros should be expanded eagerly. Due to this, we must
work around the lazy expansion in builtin macros and perform eager
expansion for each pass of the fixed-point, before finally expanding
the builtin when there are no longer any inner macro invocations.
To perform proper macro scoping, the ENR now keeps track of the current
scope (`current_scope` member) and resolves macros accordingly.
This is done through the use of the `scoped` method, which creates a new
scope, runs a specified lambda and then exits the scope. This prevents
pushing/popping errors that we've seen happen already in similar
contexts.
We might think about generalizing it to other classes, providing a
`Scoped<EntryFn, ExitFn>` class or similar
gcc/rust/ChangeLog:
* ast/rust-macro.cc: New file.
* Make-lang.in: Add `rust-macro.o` object
* ast/rust-ast-fragment.cc (Fragment::Fragment): Change API around
the construction of AST fragments.
(Fragment::operator=): Correct `Fragment::operator=` to take into
account the fragment tokens.
(Fragment::create_error): Use new constructor.
(Fragment::complete): Remove in favor of new constructor.
(Fragment::unexpanded): Remove as that Fragment type is no longer used
or possible.
(Fragment::get_tokens): Add helper to access a fragment's tokens.
* ast/rust-ast-fragment.h (enum class): Remove `FragmentKind::Unused`
* ast/rust-ast.cc (MacroInvocation::as_string): Display
builtin macro invocations properly.
* ast/rust-ast.h: Fix `DelimTokenTree` class copy constructors and
handling of its token vector.
* ast/rust-macro.h (class MacroMatcher): Format.
(class MetaItemSeq): Likewise.
(builtin_macro_from_string): Get a `BuiltinMacroKind` from a given
string, i.e the name of the macro (`assert!`, `cfg!` and so on).
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Do not expand
macros recursively anymore.
(AttrVisitor::maybe_expand_expr): Likewise.
(AttrVisitor::maybe_expand_type): Likewise.
* expand/rust-attribute-visitor.h: Likewise, and remove
`expand_macro_fragment_recursively` function.
* expand/rust-macro-builtins.cc (make_token): Add shorthand for
returning `std::unique_ptr<AST::Token>`s.
(make_macro_invocation): Add shorthand for returning fragments
containing builtin macro invocations.
(try_expand_macro_expression): Do not expand macros recursively.
(try_expand_single_string_literal): Likewise.
(try_expand_many_expr): Likewise.
(parse_single_string_literal): Error out more appropriately.
(MacroBuiltin::compile_error_handler): Add explanation for eager
invocation
(MacroBuiltin::file_handler): Return the proper tokens associated with
macro invocation, and builtin macros in the case of necessary eager
expansion.
(MacroBuiltin::column_handler): Likewise.
(MacroBuiltin::include_bytes_handler): Likewise.
(MacroBuiltin::include_str_handler): Likewise.
(MacroBuiltin::concat_handler): Likewise.
(MacroBuiltin::env_handler): Likewise.
(MacroBuiltin::cfg_handler): Likewise.
(MacroBuiltin::include_handler): Likewise.
(MacroBuiltin::line_handler): Likewise.
* expand/rust-macro-expand.cc (MacroExpander::expand_eager_invocations):
Add function to expand eager invocations *once* in the fixed point
pipeline.
(MacroExpander::expand_invoc): Call into `expand_eager_invocations` for
builtin macro invocations.
(MacroExpander::expand_crate): Use new `AttrVisitor` API.
(parse_many): Return tokens in `AST::Fragment`.
(transcribe_expression): Likewise.
(transcribe_type): Likewise.
* expand/rust-macro-expand.h (struct MacroExpander): Add `has_changed`
flag for fixed point checking.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::EarlyNameResolver):
Keep track of the current macro scope.
(EarlyNameResolver::go): Use `scoped` API.
(EarlyNameResolver::visit): Likewise.
* resolve/rust-early-name-resolver.h: Add `scoped` API.
* rust-session-manager.cc (Session::expansion): Perform macro expansion
in a fixed-point fashion.
gcc/testsuite/ChangeLog:
* rust/compile/macro17.rs: Fix testsuite for new recursion errors.
* rust/compile/macro44.rs: Fix invalid testcase assertions.
* rust/compile/builtin_macro_recurse.rs: Fix invalid test.
* rust/compile/builtin_macro_recurse2.rs: New test.
* rust/compile/macro46.rs: New test.
Arthur Cohen [Tue, 17 Jan 2023 15:44:23 +0000 (16:44 +0100)]
gccrs: expansion: Add `get_token_slice` to `MacroInvocLexer` class
gcc/rust/ChangeLog:
* expand/rust-macro-invoc-lexer.cc (MacroInvocLexer::get_token_slice):
Add API to retrieve token slices when lexing macro expansions.
* expand/rust-macro-invoc-lexer.h: Declare `get_token_slice`.
Arthur Cohen [Fri, 13 Jan 2023 11:16:49 +0000 (12:16 +0100)]
gccrs: parser: Expose parse_macro_invocation as public API
gcc/rust/ChangeLog:
* parse/rust-parse.h: Move `parse_macro_invocation` to public API.
Arthur Cohen [Tue, 17 Jan 2023 14:53:00 +0000 (15:53 +0100)]
gccrs: rust-item: include rust-expr.h
gcc/rust/ChangeLog:
* ast/rust-item.h (class BlockExpr): Remove forward declaration of
class `BlockExpr`.
Owen Avery [Sat, 4 Feb 2023 05:02:22 +0000 (00:02 -0500)]
gccrs: Add support for TuplePattern in let statements
gcc/rust/ChangeLog:
* hir/tree/rust-hir-pattern.h
(TuplePatternItemsRanged::get_lower_patterns): Add method.
(TuplePatternItemsRanged::get_upper_patterns): Add method.
* backend/rust-compile-pattern.cc
(CompilePatternLet::visit): Implement TuplePattern visitor.
* backend/rust-compile-pattern.h
(CompilePatternLet::visit): Move TuplePattern visitor out of header file.
gcc/testsuite/ChangeLog:
* rust/execute/torture/let-pattern-1.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Philip Herron [Sat, 4 Feb 2023 22:53:48 +0000 (22:53 +0000)]
gccrs: Add general TypeBounds checks
Existing tests are updated to use libcore copy and clone implementation.
Addresses #1725
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-unify.cc (UnifyRules::go): ensure the bounds are checked
gcc/testsuite/ChangeLog:
* rust/compile/torture/intrinsics-4.rs: implement Copy trait
* rust/compile/torture/intrinsics-5.rs: likewise
* rust/execute/torture/atomic_load.rs: likewise
* rust/execute/torture/atomic_store.rs: likewise
* rust/bounds1.rs: New test.
Philip Herron [Sat, 4 Feb 2023 23:02:31 +0000 (23:02 +0000)]
gccrs: Remove bad error message on checking function arguments
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): remove error message
gcc/testsuite/ChangeLog:
* rust/compile/func3.rs: update test case
Philip Herron [Tue, 31 Jan 2023 18:52:33 +0000 (18:52 +0000)]
gccrs: Fix higher ranked trait bounds computation of self
This updates the higher ranked trait bounds computation to handle ambigious
cases. When we have a slice for example:
let slice = &a[1..3];
This works by reusing the Index operator overload from libcore, so when the
index range of 1..3 is computed, the type system needs to compute what the
types of index are; this works by integer inference variables
Range<<integer>> that need to be unified with the impl Index for
Range<Usize> which computes the real type of usize for the index. This is
fine but what happens when we have the Copy and Clone traits bounds which
have implementations for all the primitive types i8, i16, i32, i64...
which is valid for any integer inference variable so the code prior to this
patch would have grabbed the first impl it would have found and used it
which is incorrect. When we have integer or float inference variables we
need to look for their respective defaults or emit an ambigious type bound
error.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-reference.h: add const infterface
* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::get_generic_param): make const
(SubstitutionRef::monomorphize): fix issue
* typecheck/rust-tyty-subst.h: constify interface
Philip Herron [Tue, 31 Jan 2023 14:39:29 +0000 (14:39 +0000)]
gccrs: Add missing Sized, Copy and Clone lang item mappings
We need these lang items to be defined and later down the line the mappings
will be used to implement proper copy and clone logic.
Fixes #1786
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* util/rust-lang-item.h:
gcc/testsuite/ChangeLog:
* rust/compile/issue-1786.rs: New test.
Philip Herron [Tue, 31 Jan 2023 14:27:49 +0000 (14:27 +0000)]
gccrs: Fix nullptr dereference
When we check if this is concrete the guard checks to ensure the argument
is non null but the check here is wrongly returning early when the check
is non null meaning when it is null and therefore not concrete it will
end up doing a null dereference.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty-subst.cc (SubstitutionArg::is_conrete): fix check
Philip Herron [Mon, 30 Jan 2023 18:19:07 +0000 (18:19 +0000)]
gccrs: Refactor the type unification code
This refactors the unification systems to be a consistent interface using
switch statements and simple functions instead of the old clunky visitor
system. This is more maintainable as it is harder to miss cases when we
can take advantages of switch statements.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* Make-lang.in: update names
* backend/rust-compile-expr.cc (CompileExpr::resolve_method_address):
update to use new interface
* typecheck/rust-coercion.cc (TypeCoercionRules::coerce_borrowed_pointer): likewise
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::unify_site): likewise
* typecheck/rust-tyty.cc (BaseType::destructure): likewise
(InferType::unify): removed old unify interface
(ErrorType::unify): likewise
(ADTType::unify): likewise
(TupleType::unify): likewise
(FnType::unify): likewise
(FnPtr::unify): likewise
(ClosureType::unify): likewise
(ArrayType::unify): likewise
(SliceType::unify): likewise
(BoolType::unify): likewise
(IntType::unify): likewise
(UintType::unify): likewise
(FloatType::unify): likewise
(USizeType::unify): likewise
(ISizeType::unify): likewise
(CharType::unify): likewise
(ReferenceType::unify): likewise
(PointerType::unify): likewise
(ParamType::unify): likewise
(StrType::unify): likewise
(NeverType::unify): likewise
(PlaceholderType::unify): likewise
(ProjectionType::unify): likewise
(DynamicObjectType::unify): likewise
* typecheck/rust-tyty.h: update destructure interface
* typecheck/rust-tyty-rules.h: Removed.
* typecheck/rust-unify.cc: New file.
* typecheck/rust-unify.h: New file.
gcc/testsuite/ChangeLog:
* rust/compile/never_type_err1.rs: Moved to...
* rust/compile/never_type1.rs: ...here. It now works
Philip Herron [Fri, 27 Jan 2023 15:38:58 +0000 (15:38 +0000)]
gccrs: Remove monomorphization hack to setup possible associated types
During CallExpr argument type checking we may be calling a default
implementation of a trait function this will require any possible
associated types to be resolved and setup. This monomoprhization call does
this but it will premtivly do extra unification of types which will throw
off type checking later on. This fix is required for my work into type
bounds checking.
Fixes #1773
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-reference.h: change interface to return self
* typecheck/rust-hir-trait-resolve.cc: likewise
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments): likewise
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): remove monomorphization hack
gcc/testsuite/ChangeLog:
* rust/compile/issue-1773.rs: New test.
Philip Herron [Fri, 27 Jan 2023 18:49:53 +0000 (18:49 +0000)]
gccrs: Add missing param subst callback
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty-subst.cc: add missing callback
Philip Herron [Fri, 27 Jan 2023 18:31:11 +0000 (18:31 +0000)]
gccrs: Clear the substitution callbacks when copying ArgumentMappings
When we set the callback on substitutions this is not safe to be copied
around since we store the used argument mappings and can reuse them in
different contexts. This clears the callback on copy's to make it safer.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty-subst.cc: update copy constructors
Philip Herron [Fri, 27 Jan 2023 18:28:06 +0000 (18:28 +0000)]
gccrs: Refactor handle_substitutions to take a reference
This patch changes the recusive substitution code to take a reference
instead of a copy. This is important as the callback field is going to be
made non-copyable in a future patch and this pipeline is for recursive
substitutions so its ok to reuse the same mappings here.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty-bounds.cc: refactor to take a reference
* typecheck/rust-tyty-subst.cc: likewise
(SubstitutionRef::get_substitution_arguments): likewise
(SubstitutionRef::infer_substitions): likewise
* typecheck/rust-tyty-subst.h: likewise
* typecheck/rust-tyty.cc (ADTType::handle_substitions): likewise
(TupleType::handle_substitions): likewise
(FnType::handle_substitions): likewise
(ClosureType::handle_substitions): likewise
(ArrayType::handle_substitions): likewise
(SliceType::handle_substitions): likewise
(ReferenceType::handle_substitions): likewise
(PointerType::handle_substitions): likewise
(ParamType::handle_substitions): likewise
(ProjectionType::handle_substitions): likewise
* typecheck/rust-tyty.h: likewise
Philip Herron [Tue, 17 Jan 2023 22:45:52 +0000 (22:45 +0000)]
gccrs: Rename header rust-hir-trait-ref.h to rust-hir-trait-reference.h
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-ref.h: Moved to...
* typecheck/rust-hir-trait-reference.h: ...here.
* typecheck/rust-hir-trait-resolve.cc: refactor
* typecheck/rust-hir-trait-resolve.h (RUST_HIR_TRAIT_RESOLVE_H): likewise
* typecheck/rust-hir-type-check.h: likewise
* typecheck/rust-tyty.cc: likewise
Philip Herron [Mon, 16 Jan 2023 19:31:11 +0000 (19:31 +0000)]
gccrs: Rename rust-tyctx.cc to rust-typecheck-context.cc
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* Make-lang.in: update name
* typecheck/rust-tyctx.cc: Moved to...
* typecheck/rust-typecheck-context.cc: ...here.
Philip Herron [Mon, 16 Jan 2023 19:27:36 +0000 (19:27 +0000)]
gccrs: Refactor all code out of the rust-tyty.h header
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check.h: refactor
* typecheck/rust-tyctx.cc (TypeCheckContext::iterate): refactor
(TypeCheckContext::have_loop_context): likewise
(TypeCheckContext::push_new_loop_context): likewise
(TypeCheckContext::push_new_while_loop_context): likewise
(TypeCheckContext::peek_loop_context): likewise
(TypeCheckContext::pop_loop_context): likewise
(TypeCheckContext::swap_head_loop_context): likewise
(TypeCheckContext::insert_trait_reference): likewise
(TypeCheckContext::lookup_trait_reference): likewise
(TypeCheckContext::insert_receiver): likewise
(TypeCheckContext::lookup_receiver): likewise
(TypeCheckContext::insert_associated_type_mapping): likewise
(TypeCheckContext::clear_associated_type_mapping): likewise
(TypeCheckContext::lookup_associated_type_mapping): likewise
(TypeCheckContext::insert_variant_definition): likewise
(TypeCheckContext::lookup_variant_definition): likewise
(TypeCheckContext::insert_operator_overload): likewise
(TypeCheckContext::lookup_operator_overload): likewise
(TypeCheckContext::insert_unconstrained_check_marker): likewise
(TypeCheckContext::have_checked_for_unconstrained): likewise
(TypeCheckContext::insert_resolved_predicate): likewise
(TypeCheckContext::lookup_predicate): likewise
(TypeCheckContext::insert_query): likewise
(TypeCheckContext::query_completed): likewise
(TypeCheckContext::query_in_progress): likewise
(TypeCheckContext::insert_trait_query): likewise
(TypeCheckContext::trait_query_completed): likewise
(TypeCheckContext::trait_query_in_progress): likewise
(TypeCheckContextItem::Item::Item): likewise
(TypeCheckContextItem::TypeCheckContextItem): likewise
(TypeCheckContextItem::get_item): likewise
(TypeCheckContextItem::get_impl_item): likewise
(TypeCheckContextItem::get_trait_item): likewise
(TypeCheckContextItem::get_type): likewise
* typecheck/rust-tyty.cc (StructFieldType::StructFieldType): likewise
(StructFieldType::get_ref): likewise
(StructFieldType::get_name): likewise
(StructFieldType::get_field_type): likewise
(StructFieldType::set_field_type): likewise
(StructFieldType::is_concrete): likewise
(StructFieldType::debug): likewise
(StructFieldType::get_locus): likewise
(VariantDef::variant_type_string): likewise
(VariantDef::VariantDef): likewise
(VariantDef::operator=): likewise
(VariantDef::get_error_node): likewise
(VariantDef::is_error): likewise
(VariantDef::get_id): likewise
(VariantDef::get_defid): likewise
(VariantDef::get_variant_type): likewise
(VariantDef::is_data_variant): likewise
(VariantDef::is_dataless_variant): likewise
(VariantDef::get_identifier): likewise
(VariantDef::num_fields): likewise
(VariantDef::get_field_at_index): likewise
(VariantDef::get_fields): likewise
(VariantDef::lookup_field): likewise
(VariantDef::get_discriminant): likewise
(VariantDef::as_string): likewise
(VariantDef::is_equal): likewise
(VariantDef::clone): likewise
(VariantDef::monomorphized_clone): likewise
(VariantDef::get_ident): likewise
(TupleType::TupleType): likewise
(TupleType::get_unit_type): likewise
(TupleType::is_unit): likewise
(TupleType::num_fields): likewise
(TupleType::is_concrete): likewise
(TupleType::get_fields): likewise
(BoolType::BoolType): likewise
(BoolType::get_name): likewise
(BoolType::is_concrete): likewise
(IntType::IntType): likewise
(IntType::get_name): likewise
(IntType::get_int_kind): likewise
(IntType::is_concrete): likewise
(UintType::UintType): likewise
(UintType::get_name): likewise
(UintType::get_uint_kind): likewise
(UintType::is_concrete): likewise
(FloatType::FloatType): likewise
(FloatType::get_name): likewise
(FloatType::get_float_kind): likewise
(FloatType::is_concrete): likewise
(USizeType::USizeType): likewise
(USizeType::get_name): likewise
(USizeType::is_concrete): likewise
(ISizeType::ISizeType): likewise
(ISizeType::get_name): likewise
(ISizeType::is_concrete): likewise
(CharType::CharType): likewise
(CharType::is_concrete): likewise
(CharType::get_name): likewise
(ReferenceType::ReferenceType): likewise
(ReferenceType::is_concrete): likewise
(ReferenceType::mutability): likewise
(ReferenceType::is_mutable): likewise
(ReferenceType::is_dyn_object): likewise
(ReferenceType::is_dyn_slice_type): likewise
(ReferenceType::is_dyn_str_type): likewise
(PointerType::PointerType): likewise
(PointerType::is_concrete): likewise
(PointerType::mutability): likewise
(PointerType::is_mutable): likewise
(PointerType::is_const): likewise
(PointerType::is_dyn_object): likewise
(PointerType::is_dyn_slice_type): likewise
(PointerType::is_dyn_str_type): likewise
(ParamType::ParamType): likewise
(ParamType::get_generic_param): likewise
(ParamType::can_resolve): likewise
(ParamType::is_concrete): likewise
(StrType::StrType): likewise
(StrType::get_name): likewise
(StrType::is_concrete): likewise
(NeverType::NeverType): likewise
(NeverType::get_name): likewise
(NeverType::is_unit): likewise
(NeverType::is_concrete): likewise
(PlaceholderType::PlaceholderType): likewise
(PlaceholderType::get_name): likewise
(PlaceholderType::is_unit): likewise
(PlaceholderType::get_symbol): likewise
(PlaceholderType::is_concrete): likewise
(ProjectionType::is_unit): likewise
(ProjectionType::get_name): likewise
(ProjectionType::needs_generic_substitutions): likewise
(ProjectionType::supports_substitutions): likewise
(ProjectionType::has_subsititions_defined): likewise
(ProjectionType::get): likewise
(ProjectionType::is_concrete): likewise
(DynamicObjectType::is_concrete): likewise
* typecheck/rust-tyty.h: likewise
Philip Herron [Mon, 16 Jan 2023 17:54:41 +0000 (17:54 +0000)]
gccrs: Refactor PathProbeType code into CC file
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-hir-path-probe.cc (PathProbeCandidate::Candidate::Candidate): refactor
(PathProbeCandidate::PathProbeCandidate): likewise
(PathProbeCandidate::as_string): likewise
(PathProbeCandidate::is_enum_candidate): likewise
(PathProbeCandidate::is_impl_candidate): likewise
(PathProbeCandidate::is_trait_candidate): likewise
(PathProbeCandidate::is_full_trait_item_candidate): likewise
(PathProbeCandidate::get_error): likewise
(PathProbeCandidate::is_error): likewise
(PathProbeCandidate::get_defid): likewise
(PathProbeCandidate::operator<): likewise
* typecheck/rust-hir-path-probe.h (struct PathProbeCandidate): likewise
Philip Herron [Mon, 16 Jan 2023 17:08:14 +0000 (17:08 +0000)]
gccrs: Refactor PathProbe into cc file
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-hir-path-probe.cc (PathProbeType::PathProbeType): refactor
(PathProbeType::Probe): likewise
(PathProbeType::visit): likewise
(PathProbeType::process_enum_item_for_candiates): likewise
(PathProbeType::process_impl_items_for_candidates): likewise
(PathProbeType::is_reciever_generic): likewise
(PathProbeImplTrait::PathProbeImplTrait): likewise
(PathProbeImplTrait::Probe): likewise
(PathProbeImplTrait::process_trait_impl_items_for_candidates): likewise
* typecheck/rust-hir-path-probe.h (struct PathProbeCandidate): likewise
* typecheck/rust-hir-trait-resolve.cc
(PathProbeImplTrait::process_trait_impl_items_for_candidates): likewise
Philip Herron [Sat, 14 Jan 2023 23:54:19 +0000 (23:54 +0000)]
gccrs: Refactor BaseType, InferType and ErrorType impl into cc file
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty.cc (BaseType::BaseType): refactor
(BaseType::~BaseType): likewise
(BaseType::get_ref): likewise
(BaseType::set_ref): likewise
(BaseType::get_ty_ref): likewise
(BaseType::set_ty_ref): likewise
(BaseType::is_equal): likewise
(BaseType::is_unit): likewise
(BaseType::get_kind): likewise
(BaseType::get_combined_refs): likewise
(BaseType::append_reference): likewise
(BaseType::supports_substitutions): likewise
(BaseType::has_subsititions_defined): likewise
(BaseType::can_substitute): likewise
(BaseType::needs_generic_substitutions): likewise
(BaseType::contains_type_parameters): likewise
(BaseType::get_ident): likewise
(BaseType::get_locus): likewise
(InferType::InferType): likewise
(InferType::get_infer_kind): likewise
(InferType::get_name): likewise
(InferType::is_concrete): likewise
(ErrorType::ErrorType): likewise
(ErrorType::is_unit): likewise
(ErrorType::is_concrete): likewise
(ErrorType::get_name): likewise
(ErrorType::monomorphized_clone): likewise
* typecheck/rust-tyty.h (class SubstitutionArgumentMappings): likewise
Philip Herron [Sat, 14 Jan 2023 23:36:47 +0000 (23:36 +0000)]
gccrs: Refactor all substitution mapper code implementation into its own CC file
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-substitution-mapper.cc (SubstMapper::SubstMapper): refactor
(SubstMapper::Resolve): likewise
(SubstMapper::InferSubst): likewise
(SubstMapper::have_generic_args): likewise
(SubstMapper::visit): likewise
(SubstMapperInternal::visit): likewise
(SubstMapperFromExisting::SubstMapperFromExisting): likewise
(SubstMapperFromExisting::Resolve): likewise
(SubstMapperFromExisting::visit): likewise
(GetUsedSubstArgs::GetUsedSubstArgs): likewise
(GetUsedSubstArgs::From): likewise
(GetUsedSubstArgs::visit): likewise
* typecheck/rust-substitution-mapper.h: refactor
* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::get_generic_param): likewise
Philip Herron [Sat, 14 Jan 2023 23:22:59 +0000 (23:22 +0000)]
gccrs: Refactor SubstitutionRef base class into its own CC file
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* Make-lang.in: update the makefile
* typecheck/rust-tyty.cc (SubstitutionParamMapping::need_substitution): likewise
(SubstitutionParamMapping::override_context): likewise
(SubstitutionRef::get_mappings_from_generic_args): likewise
(SubstitutionRef::infer_substitions): likewise
(SubstitutionRef::are_mappings_bound): likewise
(SubstitutionRef::solve_missing_mappings_from_this): likewise
(SubstitutionRef::monomorphize): likewise
* typecheck/rust-tyty.h (class SubstitutionParamMapping): likewise
(class SubstitutionArg): likewise
(std::function<void): likewise
(class SubstitutionArgumentMappings): likewise
(class SubstitutionRef): likewise
* typecheck/rust-tyty-subst.cc: New file.
* typecheck/rust-tyty-subst.h: New file.
Philip Herron [Thu, 12 Jan 2023 18:00:52 +0000 (18:00 +0000)]
gccrs: Refactor TyVar and TypeBoundPredicates
This extract these helpers into seperate files
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* Make-lang.in: update makefile
* typecheck/rust-tyty.cc (TyVar::TyVar): move to new file
(TyVar::get_tyty): likewise
(TyVar::get_implicit_infer_var): likewise
(TyVar::subst_covariant_var): likewise
(TyVar::clone): likewise
(TyVar::monomorphized_clone): likewise
(TyWithLocation::TyWithLocation): likewise
* typecheck/rust-tyty.h (class BaseType): cleanup
(class TypeBoundPredicate): move to its own file
(class TypeBoundPredicateItem): likewise
(class TypeBoundsMappings): likewise
(class TyVar): likewise
(class TyWithLocation): likewise
* typecheck/rust-tyty-bounds.h: New file.
* typecheck/rust-tyty-util.cc: New file.
* typecheck/rust-tyty-util.h: New file.
Philip Herron [Thu, 12 Jan 2023 16:40:30 +0000 (16:40 +0000)]
gccrs: Move TypePredicateItem impl out of the header
This moves the implementation code out of the header and into its
respective cc file.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty-bounds.cc (TypeBoundPredicateItem::error): refactor
(TypeBoundPredicateItem::is_error): likewise
(TypeBoundPredicateItem::get_parent): likewise
* typecheck/rust-tyty.h: Move the implementation for the above
Philip Herron [Thu, 12 Jan 2023 16:22:17 +0000 (16:22 +0000)]
gccrs: Add another test case for passing associated type-bounds
This demonstrates that this also works for custom algebraic data types too.
gcc/testsuite/ChangeLog:
* rust/execute/torture/issue-1720-2.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Owen Avery [Sat, 4 Feb 2023 17:07:38 +0000 (12:07 -0500)]
gccrs: Removed comment copy-pasted from gcc/tree.def
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): Removed copy-pasted comment.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
mxlol233 [Thu, 12 Jan 2023 14:08:57 +0000 (22:08 +0800)]
gccrs: Add support for feature check.
This commit implements a very basic feature checking module.
gcc/rust/ChangeLog:
* Make-lang.in: Add object files: `rust-feature.o` and `rust-feature-gate.o`
* checks/errors/rust-feature-gate.cc: New file.
* checks/errors/rust-feature-gate.h: New file.
* checks/errors/rust-feature.cc: New file.
* checks/errors/rust-feature.h: New file.
* rust-session-manager.cc: Add FeatureGate check.
gcc/testsuite/ChangeLog:
* rust/compile/feature.rs: New test.
Signed-off-by: Xiao Ma <mxlol233@outlook.com>
Arthur Cohen [Thu, 2 Feb 2023 14:32:17 +0000 (15:32 +0100)]
gccrs: parser: Fix parsing of closure param list
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_closure_expr): Advance tokens
properly when parsing closure param list.
gcc/testsuite/ChangeLog:
* rust/compile/closure_move_expr.rs: New test.
Arthur Cohen [Wed, 1 Feb 2023 11:41:47 +0000 (12:41 +0100)]
gccrs: parser: Improve parsing of complex generic arguments
The parser was missing code for handling complex type arguments such
as type paths or nested generics.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_generic_arg): Handle type
paths and nested generics properly.
gcc/testsuite/ChangeLog:
* rust/compile/parse_complex_generic_application.rs: New test.
* rust/compile/parse_complex_generic_application2.rs: New test.
Owen Avery [Thu, 2 Feb 2023 05:05:36 +0000 (00:05 -0500)]
gccrs: Implement lowering ReferencePattern from AST to HIR
gcc/rust/ChangeLog:
* ast/rust-pattern.h:
(ReferencePattern::is_double_reference): Add method.
(ReferencePattern::get_is_mut): Add method.
* hir/rust-ast-lower-pattern.cc
(ASTLoweringPattern::visit): Add ReferencePattern visitor.
* hir/rust-ast-lower-pattern.h:
(ASTLoweringPattern::visit): Add ReferencePattern visitor.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Thu, 2 Feb 2023 16:38:44 +0000 (11:38 -0500)]
gccrs: Optimize HIR::ReferencePattern
gcc/rust/ChangeLog:
* hir/tree/rust-hir-pattern.h
(class ReferencePattern): Remove has_two_amps field.
* hir/tree/rust-hir-full-test.cc
(ReferencePattern::as_string): Remove usage of ReferencePattern::has_two_amps.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Tue, 31 Jan 2023 01:14:34 +0000 (20:14 -0500)]
gccrs: Remove HIR::GroupedPattern
gcc/rust/ChangeLog:
* backend/rust-compile-fnparam.h
(CompileFnParam::visit): Remove HIR::GroupedPattern visitor.
* backend/rust-compile-pattern.cc
(CompilePatternCaseLabelExpr::visit): Remove HIR::GroupedPattern visitor.
(CompilePatternBindings::visit): Remove HIR::GroupedPattern visitor.
* backend/rust-compile-pattern.h
(CompilePatternCaseLabelExpr::visit): Remove HIR::GroupedPattern visitor.
(CompilePatternBindings::visit): Remove HIR::GroupedPattern visitor.
(CompilePatternLet::visit): Remove HIR::GroupedPattern visitor.
* backend/rust-compile-resolve-path.h
(ResolvePathRef::visit): Remove HIR::GroupedPattern visitor.
* backend/rust-compile-var-decl.h
(CompileVarDecl::visit): Remove HIR::GroupedPattern visitor.
* checks/errors/rust-const-checker.cc
(ConstChecker::visit): Remove HIR::GroupedPattern visitor.
* checks/errors/rust-const-checker.h
(ConstChecker::visit): Remove HIR::GroupedPattern visitor.
* checks/errors/rust-unsafe-checker.cc
(UnsafeChecker::visit): Remove HIR::GroupedPattern visitor.
* checks/errors/rust-unsafe-checker.h
(UnsafeChecker::visit): Remove HIR::GroupedPattern visitor.
* hir/rust-hir-dump.cc (Dump::visit): Remove HIR::GroupedPattern visitor.
* hir/rust-hir-dump.h (Dump::visit): Remove HIR::GroupedPattern visitor.
* hir/tree/rust-hir-full-decls.h (class GroupedPattern): Remove class.
* hir/tree/rust-hir-full-test.cc (GroupedPattern::accept_vis): Remove method.
* hir/tree/rust-hir-pattern.h (class GroupedPattern): Remove class.
* hir/tree/rust-hir-visitor.h
(HIRFullVisitor::visit): Remove HIR::GroupedPattern visitor.
(HIRFullVisitorBase::visit): Remove HIR::GroupedPattern visitor.
(HIRPatternVisitor::visit): Remove HIR::GroupedPattern visitor.
* typecheck/rust-hir-type-check-pattern.cc
(TypeCheckPattern::visit): Remove HIR::GroupedPattern visitor.
* typecheck/rust-hir-type-check-pattern.h
(TypeCheckPattern::visit): Remove HIR::GroupedPattern visitor.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Tue, 31 Jan 2023 01:13:52 +0000 (20:13 -0500)]
gccrs: Improve GroupedPattern lowering
gcc/rust/ChangeLog:
* hir/rust-ast-lower-pattern.cc
(ASTLoweringPattern::visit): Lower AST::GroupedPattern to its inner pattern.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
MAHAD [Wed, 1 Feb 2023 17:44:00 +0000 (22:44 +0500)]
gccrs: Move rust-buffered-queue.h to util folder #1766
gcc/rust/ChangeLog:
* rust-buffered-queue.h: Moved to...
* util/rust-buffered-queue.h: ...here.
Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
Arthur Cohen [Wed, 1 Feb 2023 10:40:13 +0000 (11:40 +0100)]
gccrs: parser: Allow parsing multiple reference types
The parser now recursively tries to parse a reference type after seeing
a `&` or `&&` token.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_type): Handle double ampersan
properly
(Parser::parse_reference_type): Call into `parse_reference_type_inner`
and wrap double reference types in another `AST::ReferenceType` node
(Parser::parse_reference_type_inner): Add parsing implementation
which does not care about the leading token (& or &&)
(Parser::parse_type_no_bounds): Handle double ampersand properly
* parse/rust-parse.h: Declare `parse_reference_type_inner`
gcc/testsuite/ChangeLog:
* rust/compile/multi_reference_type.rs: New test.
Owen Avery [Fri, 27 Jan 2023 16:47:30 +0000 (11:47 -0500)]
gccrs: Create and use CompilePatternLet visitor for compiling let statments
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc (CompilePatternLet::visit): New function.
* backend/rust-compile-stmt.cc (CompileStmt::visit): Likewise.
* backend/rust-compile-pattern.h (class CompilePatternLet): New visitor.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Arthur Cohen [Wed, 11 Jan 2023 14:29:22 +0000 (15:29 +0100)]
gccrs: macro: Allow builtin `MacroInvocation`s within the AST
gcc/rust/ChangeLog:
* ast/rust-macro.h (enum class): Add `BuiltinMacro` enum class.
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Mention
switching on `macro.kind` once builtin macro invocations are properly
handled.
* parse/rust-parse-impl.h (Parser::parse_macro_invocation): Switch to new MacroInvocation
API.
(Parser::parse_type): Likewise.
(Parser::parse_type_no_bounds): Likewise.
Abdul Rafey [Wed, 1 Feb 2023 05:32:16 +0000 (11:02 +0530)]
gccrs: fixed indentations in AST pretty expanded dump of trait
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): removed extra indentations in trait ast dump
Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
Abdul Rafey [Sun, 29 Jan 2023 11:35:23 +0000 (17:05 +0530)]
gccrs: fixed compiler error message on wildcard pattern within expression
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::null_denotation): Add proper error
when seeing wildcard var on right side of assignment.
gcc/testsuite/ChangeLog:
* rust/compile/issue-867.rs: New test.
Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
Abdul Rafey [Sun, 29 Jan 2023 11:29:17 +0000 (16:59 +0530)]
gccrs: moved operator.h to util/rust-operators.h
gcc/rust/ChangeLog:
* ast/rust-ast.cc: Fix include list.
* ast/rust-expr.h: Likewise.
* hir/tree/rust-hir-expr.h: Likewise.
* rust-backend.h: Likewise.
* util/rust-lang-item.h: Likewise.
* operator.h: Moved to...
* util/rust-operators.h: ...here.
Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
Parthib [Sat, 28 Jan 2023 16:37:45 +0000 (22:07 +0530)]
gccrs: Rename file rust-ast-full-test.cc to rust-ast.cc
gcc/rust/ChangeLog:
* Make-lang.in: Rename object file.
* ast/rust-ast-full-test.cc: Moved to...
* ast/rust-ast.cc: ...here.
Owen Avery [Wed, 11 Jan 2023 16:57:28 +0000 (11:57 -0500)]
gccrs: Added missing GroupedPattern visitors for code generation
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Add proper
visitor.
(CompilePatternBindings::visit): Likewise.
* backend/rust-compile-pattern.h: Declare them.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Wed, 11 Jan 2023 16:56:05 +0000 (11:56 -0500)]
gccrs: Add type resolution for grouped patterns
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Add proper
visitor.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Wed, 25 Jan 2023 18:00:38 +0000 (13:00 -0500)]
gccrs: Add get_item method for HIR::GroupedPattern
gcc/rust/ChangeLog:
* hir/tree/rust-hir-pattern.h: Add get_item method.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Wed, 11 Jan 2023 16:54:54 +0000 (11:54 -0500)]
gccrs: Add HIR lowering for GroupedPattern
gcc/rust/ChangeLog:
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Add proper visitor.
* hir/rust-ast-lower-pattern.h: Declare it.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Lyra [Tue, 24 Jan 2023 13:15:42 +0000 (14:15 +0100)]
gccrs: Do not crash on empty macros expand. Fixes #1712
This commit fixes a compiler crash when expanding an empty macro into an existing AST.
gcc/rust/ChangeLog:
* expand/rust-macro-expand.cc (transcribe_expression): Fix ICE when expanding
empty macros.
gcc/testsuite/ChangeLog:
* rust/compile/macro45.rs: New test.
Signed-off-by: Lyra Karenai <teromene@teromene.fr>
Owen Avery [Wed, 11 Jan 2023 16:53:51 +0000 (11:53 -0500)]
gccrs: Support GroupedPattern during name resolution
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-pattern.h: Support GroupedPattern properly.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Arthur Cohen [Wed, 11 Jan 2023 10:36:11 +0000 (11:36 +0100)]
gccrs: testsuite: Handle Windows carriage returns properly
In dg-output, check for \r* carriage returns to make sure execution
tests pass on windows platforms
gcc/testsuite/ChangeLog:
* rust/execute/torture/builtin_macro_cfg.rs: Handle carriage returns
properly.
* rust/execute/torture/builtin_macro_concat.rs: Likewise.
* rust/execute/torture/builtin_macro_env.rs: Likewise.
* rust/execute/torture/builtin_macro_include_bytes.rs: Likewise.
* rust/execute/torture/builtin_macro_include_str.rs: Likewise.
* rust/execute/torture/builtin_macro_line.rs: Likewise.
* rust/execute/torture/builtin_macros1.rs: Likewise.
* rust/execute/torture/builtin_macros3.rs: Likewise.
* rust/execute/torture/cfg1.rs: Likewise.
* rust/execute/torture/cfg2.rs: Likewise.
* rust/execute/torture/cfg3.rs: Likewise.
* rust/execute/torture/cfg4.rs: Likewise.
* rust/execute/torture/coercion1.rs: Likewise.
* rust/execute/torture/coercion2.rs: Likewise.
* rust/execute/torture/extern_mod4.rs: Likewise.
* rust/execute/torture/helloworld1.rs: Likewise.
* rust/execute/torture/helloworld2.rs: Likewise.
* rust/execute/torture/issue-1198.rs: Likewise.
* rust/execute/torture/issue-1231.rs: Likewise.
* rust/execute/torture/issue-1232.rs: Likewise.
* rust/execute/torture/issue-1249.rs: Likewise.
* rust/execute/torture/issue-1436.rs: Likewise.
* rust/execute/torture/issue-1496.rs: Likewise.
* rust/execute/torture/issue-647.rs: Likewise.
* rust/execute/torture/issue-845.rs: Likewise.
* rust/execute/torture/issue-851.rs: Likewise.
* rust/execute/torture/issue-858.rs: Likewise.
* rust/execute/torture/issue-976.rs: Likewise.
* rust/execute/torture/macros10.rs: Likewise.
* rust/execute/torture/macros11.rs: Likewise.
* rust/execute/torture/macros12.rs: Likewise.
* rust/execute/torture/macros13.rs: Likewise.
* rust/execute/torture/macros14.rs: Likewise.
* rust/execute/torture/macros2.rs: Likewise.
* rust/execute/torture/macros22.rs: Likewise.
* rust/execute/torture/macros29.rs: Likewise.
* rust/execute/torture/macros3.rs: Likewise.
* rust/execute/torture/macros30.rs: Likewise.
* rust/execute/torture/macros31.rs: Likewise.
* rust/execute/torture/macros7.rs: Likewise.
* rust/execute/torture/macros8.rs: Likewise.
* rust/execute/torture/macros9.rs: Likewise.
* rust/execute/torture/match1.rs: Likewise.
* rust/execute/torture/match2.rs: Likewise.
* rust/execute/torture/match3.rs: Likewise.
* rust/execute/torture/match_bool1.rs: Likewise.
* rust/execute/torture/match_byte1.rs: Likewise.
* rust/execute/torture/match_char1.rs: Likewise.
* rust/execute/torture/match_int1.rs: Likewise.
* rust/execute/torture/match_loop1.rs: Likewise.
* rust/execute/torture/match_range1.rs: Likewise.
* rust/execute/torture/match_range2.rs: Likewise.
* rust/execute/torture/match_tuple1.rs: Likewise.
* rust/execute/torture/method1.rs: Likewise.
* rust/execute/torture/method2.rs: Likewise.
* rust/execute/torture/method3.rs: Likewise.
* rust/execute/torture/method4.rs: Likewise.
* rust/execute/torture/operator_overload_1.rs: Likewise.
* rust/execute/torture/operator_overload_10.rs: Likewise.
* rust/execute/torture/operator_overload_11.rs: Likewise.
* rust/execute/torture/operator_overload_12.rs: Likewise.
* rust/execute/torture/operator_overload_2.rs: Likewise.
* rust/execute/torture/operator_overload_4.rs: Likewise.
* rust/execute/torture/operator_overload_5.rs: Likewise.
* rust/execute/torture/operator_overload_6.rs: Likewise.
* rust/execute/torture/operator_overload_7.rs: Likewise.
* rust/execute/torture/operator_overload_8.rs: Likewise.
* rust/execute/torture/operator_overload_9.rs: Likewise.
* rust/execute/torture/str-layout1.rs: Likewise.
* rust/execute/torture/str-zero.rs: Likewise.
* rust/execute/torture/trait1.rs: Likewise.
* rust/execute/torture/trait10.rs: Likewise.
* rust/execute/torture/trait11.rs: Likewise.
* rust/execute/torture/trait12.rs: Likewise.
* rust/execute/torture/trait13.rs: Likewise.
* rust/execute/torture/trait2.rs: Likewise.
* rust/execute/torture/trait3.rs: Likewise.
* rust/execute/torture/trait4.rs: Likewise.
* rust/execute/torture/trait5.rs: Likewise.
* rust/execute/torture/trait6.rs: Likewise.
* rust/execute/torture/trait7.rs: Likewise.
* rust/execute/torture/trait8.rs: Likewise.
* rust/execute/torture/trait9.rs: Likewise.
* rust/execute/torture/closure2.rs: Likewise.
* rust/execute/torture/closure3.rs: Likewise.
* rust/execute/torture/loop-condition-eval.rs: Likewise.
* rust/execute/torture/operator_overload_3.rs: Likewise.
Owen Avery [Wed, 11 Jan 2023 17:05:39 +0000 (12:05 -0500)]
gccrs: Change how CompileVarDecl outputs Bvariable's
This allows patterns to declare multiple/no variables
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc (HIRCompileBase::compile_locals_for_block):
Allow patterns to declare zero or multiple variables.
* backend/rust-compile-var-decl.h: Change function declaration.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
mxlol233 [Wed, 11 Jan 2023 12:36:13 +0000 (20:36 +0800)]
gccrs: diagnostics: Add underline for tokens in diagnostics.
Currently, the diagnostics only point to the corresponding token's
start position by carets, and lack of underlines for full token. This
commit add support for such underlines in diagnostics by encoding range
information in location_t.
gcc/rust/ChangeLog:
* lex/rust-lex.cc (Lexer::build_token): Make location enclose entire token.
(Lexer::parse_byte_char): Likewise.
(Lexer::parse_byte_string): Likewise.
(Lexer::parse_raw_byte_string): Likewise.
(Lexer::parse_raw_identifier): Likewise.
(Lexer::parse_string): Likewise.
(Lexer::parse_identifier_or_keyword): Likewise.
(Lexer::parse_raw_string): Likewise.
(Lexer::parse_non_decimal_int_literal): Likewise.
(Lexer::parse_decimal_int_or_float): Likewise.
(Lexer::parse_char_or_lifetime): Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/diagnostic_underline.rs: New test.
Signed-off-by: Xiao Ma <mxlol233@outlook.com>