]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 years agogccrs: Fix nullptr dereference
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

2 years agogccrs: Refactor the type unification code
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

2 years agogccrs: Remove monomorphization hack to setup possible associated types
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.

2 years agogccrs: Add missing param subst callback
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

2 years agogccrs: Clear the substitution callbacks when copying ArgumentMappings
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

2 years agogccrs: Refactor handle_substitutions to take a reference
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

2 years agogccrs: Rename header rust-hir-trait-ref.h to rust-hir-trait-reference.h
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

2 years agogccrs: Rename rust-tyctx.cc to rust-typecheck-context.cc
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.

2 years agogccrs: Refactor all code out of the rust-tyty.h header
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

2 years agogccrs: Refactor PathProbeType code into CC file
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

2 years agogccrs: Refactor PathProbe into cc file
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

2 years agogccrs: Refactor BaseType, InferType and ErrorType impl into cc file
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

2 years agogccrs: Refactor all substitution mapper code implementation into its own CC file
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

2 years agogccrs: Refactor SubstitutionRef base class into its own CC file
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.

2 years agogccrs: Refactor TyVar and TypeBoundPredicates
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.

2 years agogccrs: Move TypePredicateItem impl out of the header
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

2 years agogccrs: Add another test case for passing associated type-bounds
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>
2 years agoMerge #1818
bors[bot] [Fri, 3 Feb 2023 20:17:06 +0000 (20:17 +0000)] 
Merge #1818

1818: Implement lowering ReferencePattern from AST to HIR r=CohenArthur a=powerboat9

gcc/rust/ChangeLog:

* ast/rust-pattern.h (ReferencePattern::get_has_two_amps): 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>
Partially addresses #1813

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1737
bors[bot] [Fri, 3 Feb 2023 17:04:01 +0000 (17:04 +0000)] 
Merge #1737

1737: Add  support for feature check. r=CohenArthur a=TuringKi

This commit implements a very basic feature checking module.

The results like this:

```

../gcc/testsuite/rust/compile/feature.rs:1:12: error: unknown feature 'AA'
    1 | #![feature(AA)] //{ dg-error "unknown feature 'AA'" }
      |            ^

```

This commit is split from pr https://github.com/Rust-GCC/gccrs/pull/1718.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
Co-authored-by: mxlol233 <mxlol233@outlook.com>
2 years agoMerge #1698
bors[bot] [Fri, 3 Feb 2023 13:28:26 +0000 (13:28 +0000)] 
Merge #1698

1698: update the ubuntu version r=CohenArthur a=ArshErgon

Fixes: #1689
updated the ubuntu-version from 20.04 to 22.04

Thank you for making Rust GCC better!

If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.

Here is a checklist to help you with your PR.

- \[ ] GCC development requires copyright assignment or the Developer's Certificate of Origin sign-off, see https://gcc.gnu.org/contribute.html or https://gcc.gnu.org/dco.html
- \[ ] Read contributing guidlines
- \[ ] `make check-rust` passes locally
- \[ ] Run `clang-format`
- \[ ] Added any relevant test cases to `gcc/testsuite/rust/`

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
---

*Please write a comment explaining your change. This is the message
that will be part of the merge commit.

Co-authored-by: ArshErgon <arshergon@gmail.com>
2 years agoAdd support for feature check.
mxlol233 [Thu, 12 Jan 2023 14:08:57 +0000 (22:08 +0800)] 
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>
2 years agoMerge #1812
bors[bot] [Fri, 3 Feb 2023 12:45:58 +0000 (12:45 +0000)] 
Merge #1812

1812: parser: Allow parsing multiple reference types r=CohenArthur a=CohenArthur

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.

Addresses #1807 partly

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2 years agoMerge #1816
bors[bot] [Fri, 3 Feb 2023 11:03:52 +0000 (11:03 +0000)] 
Merge #1816

1816: Move rust-buffered-queue.h to util folder #1766 r=CohenArthur a=drmahad

### gcc/rust/ChangeLog:

-  rust-buffered-queue.h
-  Moved to util/rust-buffered-queue.h.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
Co-authored-by: MAHAD <mahadtxt@gmail.com>
2 years agoMerge #1783
bors[bot] [Thu, 2 Feb 2023 18:29:46 +0000 (18:29 +0000)] 
Merge #1783

1783: Remove HIR::GroupedPattern r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Removes HIR::GroupedPattern and lowers AST::GroupedPattern to its inner pattern directly. Addresses https://github.com/Rust-GCC/gccrs/pull/1771#pullrequestreview-1271272084

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoImplement lowering ReferencePattern from AST to HIR
Owen Avery [Thu, 2 Feb 2023 05:05:36 +0000 (00:05 -0500)] 
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>
2 years agoOptimize HIR::ReferencePattern
Owen Avery [Thu, 2 Feb 2023 16:38:44 +0000 (11:38 -0500)] 
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>
2 years agoRemove HIR::GroupedPattern
Owen Avery [Tue, 31 Jan 2023 01:14:34 +0000 (20:14 -0500)] 
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>
2 years agoImprove GroupedPattern lowering
Owen Avery [Tue, 31 Jan 2023 01:13:52 +0000 (20:13 -0500)] 
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>
2 years agoMove rust-buffered-queue.h to util folder #1766
MAHAD [Wed, 1 Feb 2023 17:44:00 +0000 (22:44 +0500)] 
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>
2 years agoci: update ubuntu version
ArshErgon [Tue, 13 Dec 2022 12:26:47 +0000 (16:56 +0430)] 
ci: update ubuntu version

This updates the CI to use ubuntu's latest LTS release, 22.04

ChangeLog:

* .github/bors_log_expected_warnings: Update warnings.
* .github/workflows/bootstrap.yml: Update Ubuntu version to 22.04.
* .github/workflows/ccpp.yml: Likewise.

2 years agoMerge #1811
bors[bot] [Wed, 1 Feb 2023 14:24:35 +0000 (14:24 +0000)] 
Merge #1811

1811: Merge upstream (dummy), "Rust front-end patches v4" r=tschwinge a=tschwinge

Last we did #1700 "Merge upstream, last commit before GCC/Rust upstreaming",
which merged commit b4fddbe9592e9feb37ce567d90af822b75995531 from GCC upstream
master branch.

This one now merges the "Rust front-end patches v4", commits
b4fddbe9592e9feb37ce567d90af822b75995531..edc676cfe8988c62c81b0df224c7fe82583012b1:

      - dd950cbbb97 Use DW_ATE_UTF for the Rust 'char' type
      - b772a504eff gccrs: Add necessary hooks for a Rust front-end testsuite
      - 4b8f3005af0 gccrs: Add Debug info testsuite
      - f60df7e6202 gccrs: Add link cases testsuite
      - 97705b4459b gccrs: Add general compilation test cases
      - 5a56869d6e3 gccrs: Add execution test cases
      - dc4171edb3c gccrs: Add gcc-check-target check-rust
      - 6b35ae12ce9 gccrs: Add Rust front-end base AST data structures
      - 438ae944fa6 gccrs: Add definitions of Rust Items in AST data structures
      - d588754c826 gccrs: Add full definitions of Rust AST data structures
      - 5b981e9c741 gccrs: Add Rust AST visitors
      - 18f6990f842 gccrs: Add Lexer for Rust front-end
      - 35e4f3b4af4 gccrs: Add Parser for Rust front-end pt.1
      - 32c8fb0eeaf gccrs: Add Parser for Rust front-end pt.2
      - 1841081a8a3 gccrs: Add expansion pass for the Rust front-end
      - 85a8fe00f80 gccrs: Add name resolution pass to the Rust front-end
      - 8ad1d56d68a gccrs: Add declarations for Rust HIR
      - 7641eaead40 gccrs: Add HIR definitions and visitor framework
      - 7999cf327de gccrs: Add AST to HIR lowering pass
      - b32b1b1576a gccrs: Add wrapper for make_unique
      - c7f8347e83c gccrs: Add port of FNV hash used during legacy symbol mangling
      - 15b0278905e gccrs: Add Rust ABI enum helpers
      - eb10bc5225e gccrs: Add Base62 implementation
      - 9a4fee5f57c gccrs: Add implementation of Optional
      - 2e7fc8780e0 gccrs: Add attributes checker
      - 9ce37e72062 gccrs: Add helpers mappings canonical path and lang items
      - c6c3db21769 gccrs: Add type resolution and trait solving pass
      - 24393cb68fa gccrs: Add Rust type information
      - 06688fe40a2 gccrs: Add remaining type system transformations
      - b1b35204d8a gccrs: Add unsafe checks for Rust
      - 5215235f016 gccrs: Add const checker
      - ca246e573fb gccrs: Add privacy checks
      - 520b52b24e7 gccrs: Add dead code scan on HIR
      - 4d67468d1d4 gccrs: Add unused variable scan
      - 509e4c32c6a gccrs: Add metadata output pass
      - 15f04af347e gccrs: Add base for HIR to GCC GENERIC lowering
      - 019b2f15581 gccrs: Add HIR to GCC GENERIC lowering for all nodes
      - cfbda2f78ba gccrs: Add HIR to GCC GENERIC lowering entry point
      - fe6264fa28a gccrs: These are wrappers ported from reusing gccgo
      - bba14a0790f gccrs: Add compiler driver
      - ea34614225d gccrs: Compiler proper interface kicks off the pipeline
      - ab1e0db43c2 gccrs: Add lang-spec.h
      - 5e7d199739f gccrs: Add lang.opt
      - 88415d33bb3 gccrs: Add GCC Rust front-end Make-lang.in
      - b07ef39ffbf gccrs: Add fatal_error when experimental flag is not present
      - a75f038c069 gccrs: Add config-lang.in
      - edc676cfe89 gccrs: Add README, CONTRIBUTING and compiler logo

This merge is done with `git merge --strategy=ours`, so that we effectively
don't bring any changes.  Rationale: any changes due to upstream review etc.,
have already been applied individually to GCC/Rust master branch, and any
remaining changes we'd either like to persist, or assess individually, later.

Co-authored-by: Tom Tromey <tom@tromey.com>
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Co-authored-by: Joel Phillips <simplytheother@gmail.com>
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2 years agoparser: Allow parsing multiple reference types
Arthur Cohen [Wed, 1 Feb 2023 10:40:13 +0000 (11:40 +0100)] 
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.

2 years agoMerge commit 'edc676cfe8988c62c81b0df224c7fe82583012b1' into HEAD
Thomas Schwinge [Wed, 1 Feb 2023 09:34:30 +0000 (10:34 +0100)] 
Merge commit 'edc676cfe8988c62c81b0df224c7fe82583012b1' into HEAD

Last we did #1700 "Merge upstream, last commit before GCC/Rust upstreaming",
which merged commit b4fddbe9592e9feb37ce567d90af822b75995531 from GCC upstream
master branch.

This one now merges the "Rust front-end patches v4", commits
b4fddbe9592e9feb37ce567d90af822b75995531..edc676cfe8988c62c81b0df224c7fe82583012b1:

      - dd950cbbb97 Use DW_ATE_UTF for the Rust 'char' type
      - b772a504eff gccrs: Add necessary hooks for a Rust front-end testsuite
      - 4b8f3005af0 gccrs: Add Debug info testsuite
      - f60df7e6202 gccrs: Add link cases testsuite
      - 97705b4459b gccrs: Add general compilation test cases
      - 5a56869d6e3 gccrs: Add execution test cases
      - dc4171edb3c gccrs: Add gcc-check-target check-rust
      - 6b35ae12ce9 gccrs: Add Rust front-end base AST data structures
      - 438ae944fa6 gccrs: Add definitions of Rust Items in AST data structures
      - d588754c826 gccrs: Add full definitions of Rust AST data structures
      - 5b981e9c741 gccrs: Add Rust AST visitors
      - 18f6990f842 gccrs: Add Lexer for Rust front-end
      - 35e4f3b4af4 gccrs: Add Parser for Rust front-end pt.1
      - 32c8fb0eeaf gccrs: Add Parser for Rust front-end pt.2
      - 1841081a8a3 gccrs: Add expansion pass for the Rust front-end
      - 85a8fe00f80 gccrs: Add name resolution pass to the Rust front-end
      - 8ad1d56d68a gccrs: Add declarations for Rust HIR
      - 7641eaead40 gccrs: Add HIR definitions and visitor framework
      - 7999cf327de gccrs: Add AST to HIR lowering pass
      - b32b1b1576a gccrs: Add wrapper for make_unique
      - c7f8347e83c gccrs: Add port of FNV hash used during legacy symbol mangling
      - 15b0278905e gccrs: Add Rust ABI enum helpers
      - eb10bc5225e gccrs: Add Base62 implementation
      - 9a4fee5f57c gccrs: Add implementation of Optional
      - 2e7fc8780e0 gccrs: Add attributes checker
      - 9ce37e72062 gccrs: Add helpers mappings canonical path and lang items
      - c6c3db21769 gccrs: Add type resolution and trait solving pass
      - 24393cb68fa gccrs: Add Rust type information
      - 06688fe40a2 gccrs: Add remaining type system transformations
      - b1b35204d8a gccrs: Add unsafe checks for Rust
      - 5215235f016 gccrs: Add const checker
      - ca246e573fb gccrs: Add privacy checks
      - 520b52b24e7 gccrs: Add dead code scan on HIR
      - 4d67468d1d4 gccrs: Add unused variable scan
      - 509e4c32c6a gccrs: Add metadata output pass
      - 15f04af347e gccrs: Add base for HIR to GCC GENERIC lowering
      - 019b2f15581 gccrs: Add HIR to GCC GENERIC lowering for all nodes
      - cfbda2f78ba gccrs: Add HIR to GCC GENERIC lowering entry point
      - fe6264fa28a gccrs: These are wrappers ported from reusing gccgo
      - bba14a0790f gccrs: Add compiler driver
      - ea34614225d gccrs: Compiler proper interface kicks off the pipeline
      - ab1e0db43c2 gccrs: Add lang-spec.h
      - 5e7d199739f gccrs: Add lang.opt
      - 88415d33bb3 gccrs: Add GCC Rust front-end Make-lang.in
      - b07ef39ffbf gccrs: Add fatal_error when experimental flag is not present
      - a75f038c069 gccrs: Add config-lang.in
      - edc676cfe89 gccrs: Add README, CONTRIBUTING and compiler logo

This merge is done with `git merge --strategy=ours`, so that we effectively
don't bring any changes.  Rationale: any changes due to upstream review etc.,
have already been applied individually to GCC/Rust master branch, and any
remaining changes we'd either like to persist, or assess individually, later.

2 years agoMerge #1788
bors[bot] [Tue, 31 Jan 2023 21:46:24 +0000 (21:46 +0000)] 
Merge #1788

1788: ci: Add commit format checker r=CohenArthur a=CohenArthur

Bring over the commit checker from `gcc-patch-dev` with the `gccrs` prefix checker enabled only for `gcc-patch-dev` PRs. I'll open up an issue to make sure that in the future it's easier to keep that folder in sync between the two branches

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2 years agoci: Add commit format checker
Arthur Cohen [Tue, 31 Jan 2023 14:38:02 +0000 (15:38 +0100)] 
ci: Add commit format checker

2 years agoMerge #1775
bors[bot] [Mon, 30 Jan 2023 23:46:48 +0000 (23:46 +0000)] 
Merge #1775

1775: Create and use CompilePatternLet visitor for compiling let statments r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Implements and utilizes CompilePatternLet to compile let statements

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoCreate and use CompilePatternLet visitor for compiling let statments
Owen Avery [Fri, 27 Jan 2023 16:47:30 +0000 (11:47 -0500)] 
Create and use CompilePatternLet visitor for compiling let statments

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1776
bors[bot] [Mon, 30 Jan 2023 13:27:16 +0000 (13:27 +0000)] 
Merge #1776

1776: fixed compiler error message on wildcard pattern within expression r=CohenArthur a=00AR

Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
fixed compiler error message on wildcard pattern '_'  within expression.
Added a new testcase for the same.
#867

Co-authored-by: Abdul Rafey <abdulrafeyq@gmail.com>
2 years agoMerge #1735
bors[bot] [Mon, 30 Jan 2023 12:44:25 +0000 (12:44 +0000)] 
Merge #1735

1735: macro: Allow builtin `MacroInvocation`s within the AST r=CohenArthur a=CohenArthur

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): Switch to new MacroInvocation API
(Parser::parse_type_no_bounds): Switch to new MacroInvocation API

This will be necessary for proper handling of builtin macros with the new `EarlyNameResolver` class and associated fixed-point algorithm

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2 years agomacro: Allow builtin `MacroInvocation`s within the AST
Arthur Cohen [Wed, 11 Jan 2023 14:29:22 +0000 (15:29 +0100)] 
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.

2 years agoMerge #1778
bors[bot] [Mon, 30 Jan 2023 11:41:57 +0000 (11:41 +0000)] 
Merge #1778

1778: Moved operator.h to util/rust-operators.h. r=CohenArthur a=00AR

Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
Refactored operator.h. #1768
Changes shown in rust-operators.h are done by clang-formater.

Co-authored-by: Abdul Rafey <abdulrafeyq@gmail.com>
2 years agofixed compiler error message on wildcard pattern within expression
Abdul Rafey [Sun, 29 Jan 2023 11:35:23 +0000 (17:05 +0530)] 
fixed compiler error message on wildcard pattern within expression

Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
2 years agomoved operator.h to util/rust-operators.h
Abdul Rafey [Sun, 29 Jan 2023 11:29:17 +0000 (16:59 +0530)] 
moved operator.h to util/rust-operators.h

Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
2 years agoMerge #1777
bors[bot] [Mon, 30 Jan 2023 09:06:03 +0000 (09:06 +0000)] 
Merge #1777

1777: Rename file rust-ast-full-test.cc to rust-ast.cc r=CohenArthur a=Parthib314

* Fixes issue  #1765

**Rename the `rust-ast-full-test.cc` to `rust-ast.cc` and also update it on `Make-lang.in`**

Co-authored-by: Parthib <parthibdutta02@gmail.com>
2 years agoRename file rust-ast-full-test.cc to rust-ast.cc
Parthib [Sat, 28 Jan 2023 16:37:45 +0000 (22:07 +0530)] 
Rename file rust-ast-full-test.cc to rust-ast.cc

2 years agoMerge #1759
bors[bot] [Fri, 27 Jan 2023 16:10:43 +0000 (16:10 +0000)] 
Merge #1759

1759: Revert 10-second timeout for each test r=philberty a=Parthib314

* Fixes issue #1747

**Remove the 10-second timeout for each compile case**

Co-authored-by: vagrant <vagrant@vagrant.vm>
2 years agoMerge #1772
bors[bot] [Fri, 27 Jan 2023 15:25:48 +0000 (15:25 +0000)] 
Merge #1772

1772: Added missing GroupedPattern visitors for code generation r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Implements some missing visitor methods for GroupedPattern compilation.

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoAdded missing GroupedPattern visitors for code generation
Owen Avery [Wed, 11 Jan 2023 16:57:28 +0000 (11:57 -0500)] 
Added missing GroupedPattern visitors for code generation

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1771
bors[bot] [Thu, 26 Jan 2023 15:28:46 +0000 (15:28 +0000)] 
Merge #1771

1771: Add type resolution for grouped patterns r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Adds type resolution for GroupedPattern.

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoAdd type resolution for grouped patterns
Owen Avery [Wed, 11 Jan 2023 16:56:05 +0000 (11:56 -0500)] 
Add type resolution for grouped patterns

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoAdd get_item method for HIR::GroupedPattern
Owen Avery [Wed, 25 Jan 2023 18:00:38 +0000 (13:00 -0500)] 
Add get_item method for HIR::GroupedPattern

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1769
bors[bot] [Wed, 25 Jan 2023 09:49:08 +0000 (09:49 +0000)] 
Merge #1769

1769: Add HIR lowering for GroupedPattern r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Implements HIR lowering for grouped patterns.

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoAdd HIR lowering for GroupedPattern
Owen Avery [Wed, 11 Jan 2023 16:54:54 +0000 (11:54 -0500)] 
Add HIR lowering for GroupedPattern

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1763
bors[bot] [Tue, 24 Jan 2023 16:39:54 +0000 (16:39 +0000)] 
Merge #1763

1763: Do not crash on empty macros expand. Fixes #1712 r=philberty a=teromene

This PR fixes a compiler crash when expanding an empty macro into an existing AST.
(I ran clang-format but it marked a few other files as dirty, and I therefore did not touch them)

Signed-off-by: Lyra Karenai <teromene@teromene.fr>
Co-authored-by: Lyra <teromene@teromene.fr>
2 years agoMerge #1760
bors[bot] [Tue, 24 Jan 2023 15:52:01 +0000 (15:52 +0000)] 
Merge #1760

1760: Support GroupedPattern during name resolution r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Adds support for GroupedPattern during name resolution.

Addresses #1136

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoDo not crash on empty macros expand. Fixes #1712
Lyra [Tue, 24 Jan 2023 13:15:42 +0000 (14:15 +0100)] 
Do not crash on empty macros expand. Fixes #1712

This commit fixes a compiler crash when expanding an empty macro into an existing AST.

Signed-off-by: Lyra Karenai <teromene@teromene.fr>
2 years agoSupport GroupedPattern during name resolution
Owen Avery [Wed, 11 Jan 2023 16:53:51 +0000 (11:53 -0500)] 
Support GroupedPattern during name resolution

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoRevert 10-second timeout for each test
vagrant [Sat, 21 Jan 2023 18:33:07 +0000 (18:33 +0000)] 
Revert 10-second timeout for each test

2 years agoMerge #1732
bors[bot] [Fri, 20 Jan 2023 08:36:23 +0000 (08:36 +0000)] 
Merge #1732

1732: testsuite: Handle Windows carriage returns properly r=CohenArthur a=CohenArthur

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: Handle carriage returns properly
* rust/execute/torture/builtin_macro_env.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macro_include_bytes.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macro_include_str.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macro_line.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macros1.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macros3.rs: Handle carriage returns properly
* rust/execute/torture/cfg1.rs: Handle carriage returns properly
* rust/execute/torture/cfg2.rs: Handle carriage returns properly
* rust/execute/torture/cfg3.rs: Handle carriage returns properly
* rust/execute/torture/cfg4.rs: Handle carriage returns properly
* rust/execute/torture/coercion1.rs: Handle carriage returns properly
* rust/execute/torture/coercion2.rs: Handle carriage returns properly
* rust/execute/torture/extern_mod4.rs: Handle carriage returns properly
* rust/execute/torture/helloworld1.rs: Handle carriage returns properly
* rust/execute/torture/helloworld2.rs: Handle carriage returns properly
* rust/execute/torture/issue-1198.rs: Handle carriage returns properly
* rust/execute/torture/issue-1231.rs: Handle carriage returns properly
* rust/execute/torture/issue-1232.rs: Handle carriage returns properly
* rust/execute/torture/issue-1249.rs: Handle carriage returns properly
* rust/execute/torture/issue-1436.rs: Handle carriage returns properly
* rust/execute/torture/issue-1496.rs: Handle carriage returns properly
* rust/execute/torture/issue-647.rs: Handle carriage returns properly
* rust/execute/torture/issue-845.rs: Handle carriage returns properly
* rust/execute/torture/issue-851.rs: Handle carriage returns properly
* rust/execute/torture/issue-858.rs: Handle carriage returns properly
* rust/execute/torture/issue-976.rs: Handle carriage returns properly
* rust/execute/torture/macros10.rs: Handle carriage returns properly
* rust/execute/torture/macros11.rs: Handle carriage returns properly
* rust/execute/torture/macros12.rs: Handle carriage returns properly
* rust/execute/torture/macros13.rs: Handle carriage returns properly
* rust/execute/torture/macros14.rs: Handle carriage returns properly
* rust/execute/torture/macros2.rs: Handle carriage returns properly
* rust/execute/torture/macros22.rs: Handle carriage returns properly
* rust/execute/torture/macros29.rs: Handle carriage returns properly
* rust/execute/torture/macros3.rs: Handle carriage returns properly
* rust/execute/torture/macros30.rs: Handle carriage returns properly
* rust/execute/torture/macros31.rs: Handle carriage returns properly
* rust/execute/torture/macros7.rs: Handle carriage returns properly
* rust/execute/torture/macros8.rs: Handle carriage returns properly
* rust/execute/torture/macros9.rs: Handle carriage returns properly
* rust/execute/torture/match1.rs: Handle carriage returns properly
* rust/execute/torture/match2.rs: Handle carriage returns properly
* rust/execute/torture/match3.rs: Handle carriage returns properly
* rust/execute/torture/match_bool1.rs: Handle carriage returns properly
* rust/execute/torture/match_byte1.rs: Handle carriage returns properly
* rust/execute/torture/match_char1.rs: Handle carriage returns properly
* rust/execute/torture/match_int1.rs: Handle carriage returns properly
* rust/execute/torture/match_loop1.rs: Handle carriage returns properly
* rust/execute/torture/match_range1.rs: Handle carriage returns properly
* rust/execute/torture/match_range2.rs: Handle carriage returns properly
* rust/execute/torture/match_tuple1.rs: Handle carriage returns properly
* rust/execute/torture/method1.rs: Handle carriage returns properly
* rust/execute/torture/method2.rs: Handle carriage returns properly
* rust/execute/torture/method3.rs: Handle carriage returns properly
* rust/execute/torture/method4.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_1.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_10.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_11.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_12.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_2.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_4.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_5.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_6.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_7.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_8.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_9.rs: Handle carriage returns properly
* rust/execute/torture/str-layout1.rs: Handle carriage returns properly
* rust/execute/torture/str-zero.rs: Handle carriage returns properly
* rust/execute/torture/trait1.rs: Handle carriage returns properly
* rust/execute/torture/trait10.rs: Handle carriage returns properly
* rust/execute/torture/trait11.rs: Handle carriage returns properly
* rust/execute/torture/trait12.rs: Handle carriage returns properly
* rust/execute/torture/trait13.rs: Handle carriage returns properly
* rust/execute/torture/trait2.rs: Handle carriage returns properly
* rust/execute/torture/trait3.rs: Handle carriage returns properly
* rust/execute/torture/trait4.rs: Handle carriage returns properly
* rust/execute/torture/trait5.rs: Handle carriage returns properly
* rust/execute/torture/trait6.rs: Handle carriage returns properly
* rust/execute/torture/trait7.rs: Handle carriage returns properly
* rust/execute/torture/trait8.rs: Handle carriage returns properly
* rust/execute/torture/trait9.rs: Handle carriage returns properly

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2 years agotestsuite: Handle Windows carriage returns properly
Arthur Cohen [Wed, 11 Jan 2023 10:36:11 +0000 (11:36 +0100)] 
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.

2 years agoMerge #1751
bors[bot] [Tue, 17 Jan 2023 16:32:09 +0000 (16:32 +0000)] 
Merge #1751

1751: README.md: Added experimental flag & updated gccrs path r=CohenArthur a=DrMahad

(1) There is a need of the flag "-frust-incomplete-and-experimental-compiler-do-not-use" because the rust1 compiler didn't work without this.

(2) The gccrs was not present in the $HOME/gccrs-install/, so updated the path to $HOME/gccrs-install/bin

Signed-off-by: MAHAD <mahadtxt@gmail.com>
Co-authored-by: MAHAD <mahadtxt@gmail.com>
2 years agoREADME.md: Added experimental flag & updated gccrs path
MAHAD [Tue, 17 Jan 2023 15:47:26 +0000 (20:47 +0500)] 
README.md: Added experimental flag & updated gccrs path

(1) There is a need of the flag "-frust-incomplete-and-experimental-compiler-do-not-use" because the rust1 compiler didn't work without this.

(2) The gccrs was not present in the $HOME/gccrs-install/, so updated the path to $HOME/gccrs-install/bin

Signed-off-by: MAHAD <mahadtxt@gmail.com>
2 years agoMerge #1736
bors[bot] [Sat, 14 Jan 2023 22:35:55 +0000 (22:35 +0000)] 
Merge #1736

1736: Change how CompileVarDecl outputs Bvariable's r=philberty a=powerboat9

This allows patterns to declare multiple/no variables

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
---

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoChange how CompileVarDecl outputs Bvariable's
Owen Avery [Wed, 11 Jan 2023 17:05:39 +0000 (12:05 -0500)] 
Change how CompileVarDecl outputs Bvariable's

This allows patterns to declare multiple/no variables

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1733
bors[bot] [Thu, 12 Jan 2023 13:54:04 +0000 (13:54 +0000)] 
Merge #1733

1733: diagnostics: Add underline for tokens in diagnostics. r=CohenArthur a=TuringKi

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.

the results like this:

```
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:5:14: error: invalid cast 'bool' to 'f32' [E0054]
    5 |   let fone = t as f32;   // { dg-error "invalid cast" }
      |              ^    ~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:6:15: error: invalid cast 'bool' to 'f64' [E0054]
    6 |   let fzero = f as f64;  // { dg-error "invalid cast" }
      |               ^    ~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:8:12: error: invalid cast 'u8' to 'bool' [E0054]
    8 |   let nb = 0u8 as bool;  // { dg-error "invalid cast .u8. to .bool. \\\[E0054\\\]" }
      |            ^~~    ~~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:9:12: error: invalid cast 'bool' to 'char' [E0054]
    9 |   let nc = true as char; // { dg-error "invalid cast" }
      |            ^~~~    ~~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:13:12: error: invalid cast 'char' to 'f32' [E0054]
   13 |   let fa = a as f32;     // { dg-error "invalid cast" }
      |            ^    ~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:14:12: error: invalid cast 'char' to 'bool' [E0054]
   14 |   let bb = b as bool;    // { dg-error "invalid cast .char. to .bool. \\\[E0054\\\]" }
      |            ^    ~~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:17:12: error: invalid cast 'u32' to 'char' [E0054]
   17 |   let ab = t32 as char;  // { dg-error "invalid cast" }
      |            ^~~    ~~~~

```

This commit is split from pr #1718.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
Co-authored-by: mxlol233 <mxlol233@outlook.com>
2 years agodiagnostics: Add underline for tokens in diagnostics.
mxlol233 [Wed, 11 Jan 2023 12:36:13 +0000 (20:36 +0800)] 
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.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
2 years agoMerge #1734
bors[bot] [Wed, 11 Jan 2023 16:45:18 +0000 (16:45 +0000)] 
Merge #1734

1734: Add get_locus function for abstract class MetaItemInner. r=CohenArthur a=TuringKi

This commit adds virtual function get_locus to base class MetaItemInner, which is helpful when we need to print  diagnostics on some sub-classes of MetaItemInner.

This commit is split from pr https://github.com/Rust-GCC/gccrs/pull/1718.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
Co-authored-by: mxlol233 <mxlol233@outlook.com>
2 years agoAdd get_locus function for abstract class MetaItemInner.
mxlol233 [Wed, 11 Jan 2023 15:24:07 +0000 (23:24 +0800)] 
Add get_locus function for abstract class MetaItemInner.

This commit adds virtual function get_locus to base class MetaItemInner, which is helpful when we need to print  diagnostics on some sub-classes of MetaItemInner.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
2 years agoMerge #1730
bors[bot] [Wed, 11 Jan 2023 11:39:37 +0000 (11:39 +0000)] 
Merge #1730

1730: Improve type checking on let statements r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
---

Improves the typechecking of patterns in let statements.

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoReuse TypeCheckPattern on LetStmt's
Owen Avery [Tue, 10 Jan 2023 00:54:55 +0000 (19:54 -0500)] 
Reuse TypeCheckPattern on LetStmt's

Update Rust type-checking to reuse TypeCheckPattern on HIR::LetStmt's.
This will unify the paths and improve error handling.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1724
bors[bot] [Tue, 10 Jan 2023 22:39:41 +0000 (22:39 +0000)] 
Merge #1724

1724: Add support for generics associated type binding r=philberty a=philberty

This patch set adds support to specify the associated type via the argument
binding syntax. We are still missing general bounds checking so in order to
properly add more test cases for bad types we need to implement that first.
I have also changed a test case to -fsyntax-only as at the time I always get
confused between Generic arguments of foo=i32 and bar: baz only specifies
the associated type and the latter adds a bound. Currently we are lacking a
way to represent adding a bound in the AST and HIR within generic arguments
so I have raised: #1725 and #1726

Fixes #1720

Co-authored-by: Philip Herron <herron.philip@googlemail.com>
2 years agoSupport associated type bound arguments
Philip Herron [Sat, 7 Jan 2023 14:41:12 +0000 (14:41 +0000)] 
Support associated type bound arguments

This patch adds support for the GenercArgsBinding type, where you can
specify the associated types of a trait bound using `<Foo=i32>` style
syntax. Note that the type-resolution relys on the i32 impl for Add
as type resolution will resolve the `a+a` to the core::ops::Add method
so code generation will require this to exist.

I have ameded testsuite/rust/compile/bounds.rs as this code is wrongly
creating an HIR::GenericArgs with a trait-object type and causing issues.
the parsing is still correct but we dont have the mechanism to represent
this in AST and HIR properly. I think we will need a new HIR::GenericArgs
AssociatedTypeBindingBound or something similar. We are still lacking
bounds checking during are type coercions and unifications so running this
example using an f32 will wrongly pass type checking, this will need
addressed next.

Fixes #1720

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* hir/tree/rust-hir-path.h:
* typecheck/rust-hir-path-probe.h:
* typecheck/rust-hir-trait-resolve.cc:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
* typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound):
(TypeBoundPredicate::TypeBoundPredicate):
(TypeBoundPredicate::operator=):
(TypeBoundPredicate::apply_generic_arguments):
(TypeBoundPredicateItem::get_tyty_for_receiver):
(TypeBoundPredicate::get_num_associated_bindings):
(TypeBoundPredicate::lookup_associated_type):
(TypeBoundPredicate::get_associated_type_items):
* typecheck/rust-tyty.cc (SubstitutionRef::get_mappings_from_generic_args):
(SubstitutionRef::infer_substitions):
(SubstitutionRef::solve_missing_mappings_from_this):
* typecheck/rust-tyty.h:

gcc/testsuite/ChangeLog:

* rust/compile/bounds.rs: change to use -fsyntax-only
* rust/execute/torture/issue-1720.rs: New test.

2 years agoAdd name resolution to generic argument associated item bindings
Philip Herron [Sat, 7 Jan 2023 17:15:23 +0000 (17:15 +0000)] 
Add name resolution to generic argument associated item bindings

When specifying generic arguments to Traits we can also specify the
associated types using `<BindingName=i32>` syntax we need to add
name resolution to the type argument here and rely on the type
resolution pass to ensure the associated type exists and to setup the
associated types accordingly.

Addresses #1720

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-type.cc (ResolveGenericArgs::go):

2 years agoMerge #1708
bors[bot] [Mon, 9 Jan 2023 15:48:12 +0000 (15:48 +0000)] 
Merge #1708

1708: Parse declarative macro (decl_macro 2.0) r=CohenArthur a=tamaroning

This PR is currentry wip.
Opinions and advices are welcome!

Co-authored-by: Raiki Tamura <tamaron1203@gmail.com>
2 years agoImplement declarative macro 2.0 parser
Raiki Tamura [Sun, 18 Dec 2022 16:48:54 +0000 (01:48 +0900)] 
Implement declarative macro 2.0 parser
Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2 years agoMerge #1707 #1717
bors[bot] [Thu, 5 Jan 2023 15:59:10 +0000 (15:59 +0000)] 
Merge #1707 #1717

1707: Fix frust very long typo r=CohenArthur a=CohenArthur

Missing space character

1717: format: Fix git whitespace errors r=CohenArthur a=CohenArthur

Addresses #1680
Fixes #1680

Probably does not need a changelog since I assume this commit will just be dropped when we merge

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2 years agoMerge #1711
bors[bot] [Thu, 5 Jan 2023 15:17:27 +0000 (15:17 +0000)] 
Merge #1711

1711: unsafe: check use of `target_feature` attribute r=CohenArthur a=snprajwal

The `target_feature` attribute is for conditional compilation and may or may not compile on all platforms. Using it requires an unsafe function or block.

Addresses #1411

Co-authored-by: Prajwal S N <prajwalnadig21@gmail.com>
2 years agoMerge #1709
bors[bot] [Thu, 5 Jan 2023 08:36:42 +0000 (08:36 +0000)] 
Merge #1709

1709: Check const functions for mutable references r=CohenArthur a=dme2

Fixes #1552

Co-authored-by: Dave <dme2223@gmail.com>
2 years agoMerge #1716
bors[bot] [Wed, 4 Jan 2023 20:12:07 +0000 (20:12 +0000)] 
Merge #1716

1716: rust: add bound parsing in parse_generic_arg. r=philberty a=TuringKi

This patch adds parsing for generic parameters like: <F: Foo<Bar: Foo>>. In current version, this pattern  leads to endless loop.

Co-authored-by: mxlol233 <mxlol233@outlook.com>
2 years agoformat: Fix git whitespace errors
Arthur Cohen [Sat, 10 Dec 2022 07:58:58 +0000 (08:58 +0100)] 
format: Fix git whitespace errors

2 years agorust: add bound parsing in parse_generic_arg.
mxlol233 [Wed, 4 Jan 2023 13:21:59 +0000 (21:21 +0800)] 
rust: add bound parsing in parse_generic_arg.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
2 years agoCheck for mutable references in const functions
Dave [Mon, 19 Dec 2022 16:59:00 +0000 (10:59 -0600)] 
Check for mutable references in const functions

Use StackedContext instead. Fix error string

Signed-off-by: Dave Evans <dave@dmetwo.org>
(Squashed commits) Check for mutable references in const functions using StackedContext

Signed-off-by: Dave Evans <dave@dmetwo.org>
2 years agounsafe: check use of `target_feature` attribute
Prajwal S N [Sat, 31 Dec 2022 07:19:02 +0000 (12:49 +0530)] 
unsafe: check use of `target_feature` attribute

The `target_feature` attribute is for conditional compilation and may or
may not compile on all platforms. Using it requires an unsafe function
or block.

Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
2 years agoMerge #1706
bors[bot] [Fri, 16 Dec 2022 12:46:03 +0000 (12:46 +0000)] 
Merge #1706

1706: Add math intrinsics r=CohenArthur a=tamaroning

Addresses https://github.com/Rust-GCC/gccrs/issues/658
Added math intrinsic functions.

Co-authored-by: Raiki Tamura <tamaron1203@gmail.com>
2 years agofatal_error_flag: Fix typo in error message
Arthur Cohen [Fri, 16 Dec 2022 12:38:36 +0000 (13:38 +0100)] 
fatal_error_flag: Fix typo in error message

2 years agoadd math intrinsics
Raiki Tamura [Thu, 15 Dec 2022 17:27:59 +0000 (02:27 +0900)] 
add math intrinsics

2 years agoMerge #1700
bors[bot] [Thu, 15 Dec 2022 14:13:33 +0000 (14:13 +0000)] 
Merge #1700

1700: Merge upstream, last commit before GCC/Rust upstreaming r=CohenArthur a=tschwinge

Co-authored-by: Eric Botcazou <ebotcazou@adacore.com>
Co-authored-by: Richard Biener <rguenther@suse.de>
Co-authored-by: Patrick Palka <ppalka@redhat.com>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Harald Anlauf <anlauf@gmx.de>
Co-authored-by: Ian Lance Taylor <iant@golang.org>
Co-authored-by: GCC Administrator <gccadmin@gcc.gnu.org>
Co-authored-by: David Malcolm <dmalcolm@redhat.com>
Co-authored-by: Lulu Cheng <chenglulu@loongson.cn>
Co-authored-by: Alexandre Oliva <oliva@adacore.com>
Co-authored-by: Paul-Antoine Arras <pa@codesourcery.com>
Co-authored-by: Tobias Burnus <tobias@codesourcery.com>
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Co-authored-by: Martin Liska <mliska@suse.cz>
Co-authored-by: Iskander Shakirzyanov <iskander@ispras.ru>
Co-authored-by: Iain Buclaw <ibuclaw@gdcproject.org>
Co-authored-by: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Co-authored-by: John David Anglin <danglin@gcc.gnu.org>
2 years agoAdjust '.github/bors_log_expected_warnings'
Thomas Schwinge [Thu, 15 Dec 2022 13:52:24 +0000 (14:52 +0100)] 
Adjust '.github/bors_log_expected_warnings'

2 years agoMerge #1704
bors[bot] [Thu, 15 Dec 2022 09:06:54 +0000 (09:06 +0000)] 
Merge #1704

1704: rust: fix link serialization [PR108113] r=CohenArthur a=dkm

The Make-lang.in was missing the link serialization support.

    PR rust/108113

gcc/rust
* Make-lang.in (rust.serial): New variable.
(rust1$(exeext)): Depend on $(rust.prev). Call LINK_PROGRESS.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Co-authored-by: Marc Poulhiès <dkm@kataplop.net>
2 years agorust: fix link serialization [PR108113]
Marc Poulhiès [Wed, 14 Dec 2022 20:29:13 +0000 (21:29 +0100)] 
rust: fix link serialization [PR108113]

The Make-lang.in was missing the link serialization support.

    PR rust/108113

gcc/rust
* Make-lang.in (rust.serial): New variable.
(rust1$(exeext)): Depend on $(rust.prev). Call LINK_PROGRESS.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2 years agoAdjust for "Make Warray-bounds alias to Warray-bounds= [PR107787]"
Thomas Schwinge [Wed, 14 Dec 2022 09:33:24 +0000 (10:33 +0100)] 
Adjust for "Make Warray-bounds alias to Warray-bounds= [PR107787]"

See GCC upstream commit 7c01d029fca669263b9c2dcb8837c42f7ae3a77f
"Make Warray-bounds alias to Warray-bounds= [PR107787]".

2 years agoMerge commit '3b89428c0d5710c8093055b3d92c543888759f93' into HEAD
Thomas Schwinge [Wed, 14 Dec 2022 16:30:07 +0000 (17:30 +0100)] 
Merge commit '3b89428c0d5710c8093055b3d92c543888759f93' into HEAD

2 years agoMerge commit '3d6dbb6fc5d1d14bf36a879b6f4a00ae91090a63' into HEAD
Thomas Schwinge [Wed, 14 Dec 2022 16:27:01 +0000 (17:27 +0100)] 
Merge commit '3d6dbb6fc5d1d14bf36a879b6f4a00ae91090a63' into HEAD

2 years agoMerge #1703
bors[bot] [Wed, 14 Dec 2022 14:46:30 +0000 (14:46 +0000)] 
Merge #1703

1703: Backport "c++: Quash -Wdangling-reference for member operator* [PR107488]" r=tschwinge a=tschwinge

As had also been reported in <https://gcc.gnu.org/PR107633> "Bootstrap failure due to -Werror=unused-parameter and -Werror=dangling-reference", GCC `--enable-bootstrap` build is currently broken:

    [...]/gcc/rust/backend/rust-compile-expr.cc: In member function ‘tree_node* Rust::Compile::CompileExpr::resolve_method_address(Rust::TyTy::FnType*, Rust::HirId, Rust::TyTy::BaseType*, Rust::HIR::PathIdentSegment&, Rust::Analysis::NodeMapping, Location)’:
    [...]/gcc/rust/backend/rust-compile-expr.cc:2019:13: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
     2019 |       auto &candidate = *candidates.begin ();
          |             ^~~~~~~~~
    [...]/gcc/rust/backend/rust-compile-expr.cc:2019:44: note: the temporary was destroyed at the end of the full expression ‘candidates.std::set<Rust::Resolver::PathProbeCandidate>::begin().std::_Rb_tree_const_iterator<Rust::Resolver::PathProbeCandidate>::operator*()’
     2019 |       auto &candidate = *candidates.begin ();
          |                                            ^
    [...]/gcc/rust/backend/rust-compile-expr.cc: In member function ‘tree_node* Rust::Compile::CompileExpr::generate_closure_fntype(Rust::HIR::ClosureExpr&, const Rust::TyTy::ClosureType&, tree, Rust::TyTy::FnType**)’:
    [...]/gcc/rust/backend/rust-compile-expr.cc:3034:35: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
     3034 |   const TyTy::TypeBoundPredicate &predicate
          |                                   ^~~~~~~~~
    [...]/gcc/rust/backend/rust-compile-expr.cc:3035:52: note: the temporary was destroyed at the end of the full expression ‘(&(& closure_tyty)->Rust::TyTy::ClosureType::<anonymous>.Rust::TyTy::BaseType::<anonymous>.Rust::TyTy::TypeBoundsMappings::get_specified_bounds())->std::vector<Rust::TyTy::TypeBoundPredicate>::begin().__gnu_cxx::__normal_iterator<const Rust::TyTy::TypeBoundPredicate*, std::vector<Rust::TyTy::TypeBoundPredicate> >::operator*()’
     3035 |     = *closure_tyty.get_specified_bounds ().begin ();
          |                                                    ^

    [...]/gcc/rust/typecheck/rust-hir-type-check-path.cc: In member function ‘void Rust::Resolver::TypeCheckExpr::resolve_segments(Rust::NodeId, std::vector<Rust::HIR::PathExprSegment>&, size_t, Rust::TyTy::BaseType*, const Rust::Analysis::NodeMapping&, Location)’:
    [...]/gcc/rust/typecheck/rust-hir-type-check-path.cc:340:13: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
      340 |       auto &candidate = *candidates.begin ();
          |             ^~~~~~~~~
    [...]/gcc/rust/typecheck/rust-hir-type-check-path.cc:340:44: note: the temporary was destroyed at the end of the full expression ‘candidates.std::set<Rust::Resolver::PathProbeCandidate>::begin().std::_Rb_tree_const_iterator<Rust::Resolver::PathProbeCandidate>::operator*()’
      340 |       auto &candidate = *candidates.begin ();
          |                                            ^

    [...]/gcc/rust/typecheck/rust-hir-type-check-type.cc: In member function ‘Rust::TyTy::BaseType* Rust::Resolver::TypeCheckType::resolve_segments(Rust::NodeId, Rust::HirId, std::vector<std::unique_ptr<Rust::HIR::TypePathSegment> >&, size_t, Rust::TyTy::BaseType*, const Rust::Analysis::NodeMapping&, Location)’:
    [...]/gcc/rust/typecheck/rust-hir-type-check-type.cc:465:13: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
      465 |       auto &candidate = *candidates.begin ();
          |             ^~~~~~~~~
    [...]/gcc/rust/typecheck/rust-hir-type-check-type.cc:465:44: note: the temporary was destroyed at the end of the full expression ‘candidates.std::set<Rust::Resolver::PathProbeCandidate>::begin().std::_Rb_tree_const_iterator<Rust::Resolver::PathProbeCandidate>::operator*()’
      465 |       auto &candidate = *candidates.begin ();
          |                                            ^

I understand this code has been changed in the GCC/Rust upstream submission; but in order to make progress with #1700, I'd like to first individually backport "c++: Quash -Wdangling-reference for member operator* [PR107488]", to resolve this issue here.

Co-authored-by: Marek Polacek <polacek@redhat.com>
2 years agoc++: Quash -Wdangling-reference for member operator* [PR107488]
Marek Polacek [Tue, 1 Nov 2022 21:05:52 +0000 (17:05 -0400)] 
c++: Quash -Wdangling-reference for member operator* [PR107488]

-Wdangling-reference complains here:

  std::vector<int> v = ...;
  std::vector<int>::const_iterator it = v.begin();
  while (it != v.end()) {
    const int &r = *it++; // warning
  }

because it sees a call to
__gnu_cxx::__normal_iterator<const int*, std::vector<int> >::operator*
which returns a reference and its argument is a TARGET_EXPR representing
the result of
__gnu_cxx::__normal_iterator<const int*, std::vector<int> >::operator++
But 'r' above refers to one of the int elements of the vector 'v', not
to a temporary object.  Therefore the warning is a false positive.

I suppose code like the above is relatively common (the warning broke
cppunit-1.15.1 and a few other projects), so presumably it makes sense
to suppress the warning when it comes to member operator*.  In this case
it's defined as

      reference
      operator*() const _GLIBCXX_NOEXCEPT
      { return *_M_current; }

and I'm guessing a lot of member operator* are like that, at least when
it comes to iterators.  I've looked at _Fwd_list_iterator,
_Fwd_list_const_iterator, __shared_ptr_access, _Deque_iterator,
istream_iterator, etc, and they're all like that, so adding #pragmas
would be quite tedious.  :/

PR c++/107488

gcc/cp/ChangeLog:

* call.cc (do_warn_dangling_reference): Quash -Wdangling-reference
for member operator*.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wdangling-reference5.C: New test.

(cherry picked from commit 32a06ce38a38bf37db468f0e6c83520fcc221534)

2 years agoMerge #1701
bors[bot] [Wed, 14 Dec 2022 11:51:46 +0000 (11:51 +0000)] 
Merge #1701

1701: Standardize warning flags r=tschwinge a=tschwinge

Bring in #1670, revert #1623 and parts of #1585.

Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
2 years agoReally fix up '.github/bors_log_expected_warnings'
Thomas Schwinge [Wed, 14 Dec 2022 10:25:45 +0000 (11:25 +0100)] 
Really fix up '.github/bors_log_expected_warnings'

2 years agoRevert "bors: Fix warning list"
Thomas Schwinge [Wed, 14 Dec 2022 09:14:55 +0000 (10:14 +0100)] 
Revert "bors: Fix warning list"

This reverts #1585 commit 94d11161c1abe8927f571aedbf39871f21ccf73a.

Conflicts:
.github/bors_log_expected_warnings
... manually resolved and adjusted; let's see...

2 years agoRevert "ci: Apply warnings in CI"
Thomas Schwinge [Wed, 14 Dec 2022 08:45:58 +0000 (09:45 +0100)] 
Revert "ci: Apply warnings in CI"

As discussed in
<https://inbox.sourceware.org/gcc-patches/871qpjtmd8.fsf@euler.schwinge.homeip.net>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7aa18c45e7047f539b11cd572f0f9502b6d.

2 years agoRevert "ci: Use same CXXFLAGS in bootstrap workflow"
Thomas Schwinge [Wed, 14 Dec 2022 08:39:44 +0000 (09:39 +0100)] 
Revert "ci: Use same CXXFLAGS in bootstrap workflow"

As discussed in
<https://inbox.sourceware.org/gcc-patches/871qpjtmd8.fsf@euler.schwinge.homeip.net>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror'.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1623 commit b3222881f443f2b09e2dd72699def43d5ae928ba.