]>
git.ipfire.org Git - thirdparty/gcc.git/log
Pierre-Emmanuel Patry [Wed, 20 Sep 2023 15:39:16 +0000 (17:39 +0200)]
gccrs: Add macro buffer global variable export
Export a new symbol containing the proc macros.
gcc/rust/ChangeLog:
* backend/rust-compile-base.h: Make static function address_expression
public.
* backend/rust-compile.cc (CompileCrate::add_proc_macro_symbols): Add
new global variable in export function.
(build_bang_proc_macro): Add a function to build the bang proc macro
structure type.
(build_proc_macro): Add a function to build the proc macro structure
type.
(build_proc_macro_payload): Add a function to build the proc macro
union used in proc macro structures.
(init_derive_proc_macro): Add a function to initialize custom derive
proc macros.
(init_attribute_proc_macro): Add a function to initialize attribute
proc macros.
(init_bang_proc_macro): Add a function to initialize bang proc macros.
(init_proc_macro): Add a function to initialize proc macro structures.
(initialize_proc_macro_array): Add a function to initialize the proc
macro buffer array.
(CompileCrate::add_proc_macro_symbols): Add call to the new functions
to correctly initialize proc macros as well as their entrypoint.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Wed, 27 Sep 2023 14:21:25 +0000 (16:21 +0200)]
gccrs: Add an explicit value to proc macro enum kind
We'll need this value in the final binary, it should therefore be kept
explicit.
libgrust/ChangeLog:
* libproc_macro_internal/proc_macro.h (enum ProcmacroTag): Add
explicit value for proc macro tag enum.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Wed, 4 Oct 2023 10:01:44 +0000 (12:01 +0200)]
gccrs: Change proc macro entrypoint
Change proc macro entrypoint from a fixed constant declaration to a
proper generation from the stable crate id. Although the stable crate id
is not in use yet, the mechanism to handle it is.
gcc/rust/ChangeLog:
* expand/rust-proc-macro.cc (CustomDeriveProcMacro::CustomDeriveProcMacro):
Remove constant string declaration.
(load_macros_array): Add call to the new generation function.
(generate_proc_macro_decls_symbol): Add a new function to generate the
entrypoint symbol name from the stable crate id.
(PROC_MACRO_DECLS_FMT_ARGS):
New macro to keep formats arguments in sync between each call.
* expand/rust-proc-macro.h (generate_proc_macro_decls_symbol): Add
function prototype.
* rust-system.h: Include <iomanip>.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Fri, 15 Sep 2023 09:08:13 +0000 (11:08 +0200)]
gccrs: Add utility function to build proc macro types
Add some utility function to build proc macro entrypoint related types.
Those functions will help generate all required metadata in order for
proc macros to be expanded properly.
gcc/rust/ChangeLog:
* backend/rust-compile.cc (build_attribute_array): Add a function to
build the attribute array type.
(build_derive_proc_macro): Add a function to build the derive proc
macro type.
(build_bang_proc_macro): Add a function to build the bang proc macro
type.
(build_attribute_proc_macro): Add a function to build the attribute
proc macro type.
(build_proc_macro): Add a function to build the proc macro tagged union
type.
(build_proc_macro_buffer): Add a function to build the proc macro
buffer type.
(build_entrypoint): Add a function to build the proc macro entrypoint
type.
* backend/rust-compile.h: Add function prototype.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Fri, 8 Sep 2023 09:23:51 +0000 (11:23 +0200)]
gccrs: Add getters for proc macro mappings
Add three different getters, one for each proc macro type.
gcc/rust/ChangeLog:
* backend/rust-compile-context.h: Add getters.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Wed, 6 Sep 2023 12:44:20 +0000 (14:44 +0200)]
gccrs: Collect procedural macros in the crate
Collect informations on procedural macros in the compiled crate. For
attribute and bang procedural macros we only require the final address
as well as the name of the function. Derive procedural macros are a bit
different, we collect the fonction's address through it's fndecl tree as
well as the trait's name and the multiple attributes.
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc (HIRCompileBase::setup_fndecl):
Make the function non static in order to be able to access the
compile context. Also add the whole proc macro infomrmation
collection.
(get_attributes): Add a function to retrieve the different
attributes from a derive procedural macro definition attribute.
(get_trait_name): Add a function to retrieve the trait name from
a derive procedural macro definition attribute.
* backend/rust-compile-base.h: Add function prototypes.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Wed, 6 Sep 2023 12:39:46 +0000 (14:39 +0200)]
gccrs: Reformat comments
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc (HIRCompileBase::setup_abi_options):
Reformat uncorrectly formatted comments.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Wed, 6 Sep 2023 12:34:45 +0000 (14:34 +0200)]
gccrs: Add containers for proc macro collection mappings
Add one container for each kind of procedural macro mapping. Also add a
new structure to gather informations required for derive procedural
macros. Add different functions to fill those new containers.
gcc/rust/ChangeLog:
* backend/rust-compile-context.h (struct CustomDeriveInfo): Add
new derive procedural macro metadata information holder for
mappings.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Wed, 6 Sep 2023 12:09:25 +0000 (14:09 +0200)]
gccrs: Add const getter for tokentrees
We often need to retrieve the underlying tokentree without modifying it,
this getter will help achieve this.
gcc/rust/ChangeLog:
* ast/rust-ast.h: Add const getter.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 4 Sep 2023 12:23:10 +0000 (14:23 +0200)]
gccrs: Change ABI setup and add gccrs_proc_macro attr
Change the way the ABI is setup on a function to avoid duplicates. ABI
is setup by the setup function only now. Add a new attribute to the
function "gccrs_proc_macro" in order to differentiate it from another
type of function.
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc (handle_proc_macro_common): Add
new attribute "gccrs_proc_macro" to all procedural macro
functions.
(get_abi): Add a function to retrieve the correct ABI depending
on wether the function is a proc macro or not.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 4 Sep 2023 11:22:21 +0000 (13:22 +0200)]
gccrs: Make proc macro definition cdecl
We need to make sure proc macros have the C abi in order to be called by
the compiler with dlopen.
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc (HIRCompileBase::setup_fndecl):
Add proc macro handlers dispatch.
(handle_proc_macro_common): Add a function for common behavior
between all kinds of proc macros.
* backend/rust-compile-base.h: Add function prototypes.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Jakub Dupak [Thu, 19 Oct 2023 13:26:35 +0000 (15:26 +0200)]
gccrs: borrowck: Refactor and BIR improvements
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::setup_loop): Move.
(ExprStmtBuilder::get_label_ctx): Move.
(ExprStmtBuilder::get_unnamed_loop_ctx): Moved.
(ExprStmtBuilder::visit): BIR improvements.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Refactor.
* checks/errors/borrowck/rust-bir-builder-internal.h (class LifetimeResolver):
Refactor.
(struct BuilderContext): Move.Refactor.
(optional_from_ptr): Map on null ptr.
* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h (class LazyBooleanExprBuilder):
Refactor.
* checks/errors/borrowck/rust-bir-builder-pattern.h: Refactor.
* checks/errors/borrowck/rust-bir-builder-struct.h (class StructBuilder): Refactor.
* checks/errors/borrowck/rust-bir-builder.h: Refactor.
* checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Refactor.
(Dump::visit): Refactor.
(Dump::visit_place): Refactor.
(Dump::visit_move_place): Refactor.
(Dump::visit_lifetime): Refactor.
* checks/errors/borrowck/rust-bir-dump.h: Refactor.
* checks/errors/borrowck/rust-bir-place.h: Refactor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 24 Oct 2023 06:32:20 +0000 (08:32 +0200)]
gccrs: borrowck: Dev notes
gcc/rust/ChangeLog:
* checks/errors/borrowck/dev-notes.md: New file.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 18 Oct 2023 21:11:20 +0000 (23:11 +0200)]
gccrs: borrowck: Docs
gcc/rust/ChangeLog:
* checks/errors/borrowck/bir-design-notes.md: New file.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Thu, 19 Oct 2023 08:47:50 +0000 (10:47 +0200)]
gccrs: borrowck: Make goto explicit.
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Use goto.
* checks/errors/borrowck/rust-bir-builder-internal.h: Explicit goto.
* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Explicit goto.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 18 Oct 2023 21:01:06 +0000 (23:01 +0200)]
gccrs: borrowck: BIR continue
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Continue.
(ExprStmtBuilder::setup_loop): Continue.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Thu, 19 Oct 2023 09:04:29 +0000 (11:04 +0200)]
gccrs: borrowck: Dump: handle infinite loops
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-dump.cc (simplify_cfg): Detech infinite loops.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 18 Oct 2023 20:54:37 +0000 (22:54 +0200)]
gccrs: borrowck: BIR: handle break
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Push ctx.
(ExprStmtBuilder::setup_loop): Common loop infractructure setup.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Loop ctx.
* checks/errors/borrowck/rust-bir-builder-internal.h (struct BuilderContext): Loop ctx.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 18 Oct 2023 21:27:48 +0000 (23:27 +0200)]
gccrs: borrowck: Dump improve jumps
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Improve jumps dump.
(Dump::visit): Improve jumps dump.
* checks/errors/borrowck/rust-bir-dump.h (class Dump): Improve jumps dump.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 18 Oct 2023 20:50:02 +0000 (22:50 +0200)]
gccrs: borrowck: Dump: simplify cfg
Add option to simplify cfg for better readability. Off by default.
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-dump.cc (simplify_cfg): Simplify cfg logic.
(Dump::go): Run simplify cfg.
* checks/errors/borrowck/rust-bir-dump.h: Option to simplify cfg.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 18 Oct 2023 20:38:30 +0000 (22:38 +0200)]
gccrs: borrowck: Dump: proper comma separation
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Use new print.
(print_comma_separated): Comma separation print.
(Dump::visit): Use new print.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 18 Oct 2023 20:36:38 +0000 (22:36 +0200)]
gccrs: borrowck: BIR dump
gcc/rust/ChangeLog:
* Make-lang.in: Build BIR dump.
* checks/errors/borrowck/rust-borrow-checker.cc (mkdir_wrapped): Cross-platform mkdir.
(dump_function_bir): Save dump to file.
(BorrowChecker::go): Run dump during borrowck.
* checks/errors/borrowck/rust-bir-dump.cc: New file.
* checks/errors/borrowck/rust-bir-dump.h: New file.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 18 Oct 2023 18:43:17 +0000 (20:43 +0200)]
gccrs: borrowck: Create BIR builders (visitors)
gcc/rust/ChangeLog:
* Make-lang.in: Compile BIR expr visitor.
* checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Use BIR builder.
* rust-session-manager.cc (Session::compile_crate): Run borrow checker.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc: New file.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.h: New file.
* checks/errors/borrowck/rust-bir-builder-internal.h: New file.
* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: New file.
* checks/errors/borrowck/rust-bir-builder-pattern.h: New file.
* checks/errors/borrowck/rust-bir-builder-struct.h: New file.
* checks/errors/borrowck/rust-bir-builder.h: New file.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 18 Oct 2023 17:49:59 +0000 (19:49 +0200)]
gccrs: borrowck: Create Borrow-checker IR (BIR)
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-borrow-checker.cc: Include to compile new code.
* checks/errors/borrowck/rust-bir-place.h: New file.
* checks/errors/borrowck/rust-bir-visitor.h: New file.
* checks/errors/borrowck/rust-bir.h: New file.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Thu, 19 Oct 2023 09:37:41 +0000 (11:37 +0200)]
gccrs: borrowck: Execute only with CLI flag
gcc/rust/ChangeLog:
* lang.opt: CLI flag.
* rust-session-manager.cc (Session::compile_crate): Guard execution.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Thu, 19 Oct 2023 08:59:54 +0000 (10:59 +0200)]
gccrs: borrowck: Add CLI option for borrowck
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::BorrowChecker): Opt dump.
(BorrowChecker::go): Opt dump.
* checks/errors/borrowck/rust-borrow-checker.h (class BorrowChecker): Opt dump.
* lang.opt: Add compile until borrowcheck.
* rust-session-manager.cc (Session::enable_dump): Add BIR.
(Session::compile_crate): Handle new options.
* rust-session-manager.h (struct CompileOptions): Add BIR.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 18 Oct 2023 17:09:34 +0000 (19:09 +0200)]
gccrs: borrowck: Add initial structure for borrowchecking
gcc/rust/ChangeLog:
* Make-lang.in: Build borrowck.
* checks/errors/borrowck/rust-borrow-checker.cc: New file.
* checks/errors/borrowck/rust-borrow-checker.h: New file.
* checks/errors/borrowck/rust-function-collector.h: New file.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Pierre-Emmanuel Patry [Mon, 23 Oct 2023 14:09:54 +0000 (16:09 +0200)]
gccrs: Fix warning with overridden virtual methods
Overridden virtual methods were not marked as such.
gcc/rust/ChangeLog:
* ast/rust-pattern.h: Add override modifier to overriding methods.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 23 Oct 2023 15:16:25 +0000 (17:16 +0200)]
gccrs: Add a new regression test for issue 2665
Highlight issue 2665's fix for const with no value expression.
gcc/testsuite/ChangeLog:
* rust/compile/issue-2665.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 23 Oct 2023 15:06:43 +0000 (17:06 +0200)]
gccrs: Parse const with no value expression
Const with no value expression may exist either in trait or in disabled
blocks. This means we should be able to parse those correctly.
gcc/rust/ChangeLog:
* ast/rust-item.h: Add a new constructor for const with no value
expression.
* parse/rust-parse-impl.h (Parser::parse_const_item): Allow const with
no expression value.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Jakub Dupak [Tue, 17 Oct 2023 15:23:16 +0000 (17:23 +0200)]
gccrs: hir: Avoid copy in getter (PathPattern)
gcc/rust/ChangeLog:
* hir/tree/rust-hir-path.h: Avoid copy in getter.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 17 Oct 2023 14:21:56 +0000 (16:21 +0200)]
gccrs: hir: Rename ComoundAssignment getters
Use more a consistent name.
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): Rename method.
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Rename method.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Rename method.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Rename method.
* hir/rust-hir-dump.cc (Dump::visit): Rename method.
* hir/tree/rust-hir-expr.h: Rename method.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Rename method.
* typecheck/rust-tyty.h: Rename method.
Jakub Dupak [Tue, 17 Oct 2023 14:02:32 +0000 (16:02 +0200)]
gccrs: hir: Rename get_pattern_mappings method
Unify with the name used in Expr to allow convenient template over
everything that has mappings.
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc: Rename method.
* backend/rust-compile-expr.cc (sort_tuple_patterns): Rename method.
* backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Rename method.
(CompilePatternBindings::visit): Rename method.
(CompilePatternLet::visit): Rename method.
* backend/rust-compile-stmt.cc (CompileStmt::visit): Rename method.
* backend/rust-compile-var-decl.h: Rename method.
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Rename method.
* hir/rust-hir-dump.cc (Dump::visit): Rename method.
* hir/tree/rust-hir-path.h: Rename method.
* hir/tree/rust-hir-pattern.h: Rename method.
* hir/tree/rust-hir.h: Rename method.
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::Resolve): Rename method.
(TypeCheckPattern::visit): Rename method.
(ClosureParamInfer::visit): Rename method.
* typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Rename method.
* util/rust-hir-map.cc (Mappings::insert_hir_pattern): Rename method.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 17 Oct 2023 13:46:05 +0000 (15:46 +0200)]
gccrs: hir: Add missing getter
gcc/rust/ChangeLog:
* hir/tree/rust-hir-expr.h: Add getter for name.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 17 Oct 2023 13:39:06 +0000 (15:39 +0200)]
gccrs: ast: Handle tuplestruct pattern with indices
gcc/rust/ChangeLog:
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Implement for tuple pat.
* resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Implement for tupple pat.
gcc/testsuite/ChangeLog:
* rust/compile/tupple_struct_pattern_tuple.rs: New test.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 17 Oct 2023 13:18:03 +0000 (15:18 +0200)]
gccrs: hir: Refactor - avoid copy in getter
gcc/rust/ChangeLog:
* hir/tree/rust-hir-path.h: Avoid copy in getter.
* hir/tree/rust-hir-pattern.h: Avoid copy in getter.
* hir/tree/rust-hir.h: Avoid copy in getter.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Owen Avery [Wed, 11 Oct 2023 19:06:21 +0000 (15:06 -0400)]
gccrs: Make resolution of AssociatedItem instances polymorphic
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-implitem.h
(ResolveToplevelImplItem::go): Take AssociatedItem as parameter.
(ResolveTopLevelTraitItems::go): Likewise.
* resolve/rust-ast-resolve-item.cc
(ResolveTraitItems::go): Likewise.
(ResolveItem::resolve_impl_item): Likewise.
(ResolveImplItems::go): Likewise.
* resolve/rust-ast-resolve-item.h
(ResolveTraitItems::go): Likewise.
(ResolveItem::resolve_impl_item): Likewise.
(ResolveImplItems::go): Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Wed, 11 Oct 2023 19:02:38 +0000 (15:02 -0400)]
gccrs: Make lowering of AssociatedItem instances polymorphic
gcc/rust/ChangeLog:
* hir/rust-ast-lower-implitem.h
(ASTLoweringImplItem::translate): Take AssociatedItem as parameter.
(ASTLoweringTraitItem::translate): Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Jakub Dupak [Mon, 16 Oct 2023 13:33:19 +0000 (15:33 +0200)]
gccrs: compile: bail on labelled block
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): Bail on labelled block.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Mon, 16 Oct 2023 13:28:03 +0000 (15:28 +0200)]
gccrs: typecheck: add loop ctx for labelled block
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Add loop ctx.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Mon, 16 Oct 2023 13:25:29 +0000 (15:25 +0200)]
gccrs: resolve: Resolve labelled block
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Resolve using loop logic.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Mon, 16 Oct 2023 13:17:33 +0000 (15:17 +0200)]
gccrs: hir: Lower labelled block
gcc/rust/ChangeLog:
* hir/rust-ast-lower.cc (ASTLoweringBlock::visit): Call loop lowering and add it to constr.
* hir/tree/rust-hir-expr.h (class LoopLabel): Move before BlockExpr and add to BlockExpr.
Jakub Dupak [Mon, 16 Oct 2023 12:42:49 +0000 (14:42 +0200)]
gccrs: ast: Parse labelled block
gcc/rust/ChangeLog:
* ast/rust-ast-builder.cc (AstBuilder::block): Add label arg to constructor call.
* ast/rust-expr.h (class LoopLabel): Move before BlockExpr.
(class BlockExpr): Add LoopLabel member.
* expand/rust-derive-clone.cc (DeriveClone::clone_fn): Add label arg to constructor call.
* parse/rust-parse-impl.h (Parser::parse_block_expr): Add label parameter.
(Parser::parse_labelled_loop_expr): Add label arg to constructor call.
* parse/rust-parse.h: Add label arg to constructor call.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Owen Avery [Wed, 11 Oct 2023 16:58:27 +0000 (12:58 -0400)]
gccrs: Create base class AssociatedItem
gcc/rust/ChangeLog:
* ast/rust-ast.h
(class AssociatedItem):
New, based on TraitItem, InherentImplItem, and TraitImplItem classes.
(class TraitItem): Inherit from AssociatedItem.
(class InherentImplItem): Likewise.
(class TraitImplItem): Likewise.
* ast/rust-item.h
(class Method): Update cloning functions.
(class Function): Likewise.
(class TypeAlias): Likewise.
(class ConstantItem): Likewise.
(class TraitItemFunc): Likewise.
(class TraitItemMethod): Likewise.
(class TraitItemConst): Likewise.
(class TraitItemType): Likewise.
* ast/rust-macro.h
(class MacroInvocation): Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Raiki Tamura [Fri, 22 Sep 2023 10:39:21 +0000 (19:39 +0900)]
gccrs: Add tests for v0 mangling
gcc/rust/ChangeLog:
* backend/rust-mangle.cc (v0_identifier): Fix broken encoding.
(v0_scope_path): Modify paramter.
(v0_path): Fix namespace for modules.
gcc/testsuite/ChangeLog:
* rust/compile/v0-mangle1.rs: New test.
Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
Pierre-Emmanuel Patry [Tue, 10 Oct 2023 12:16:52 +0000 (14:16 +0200)]
gccrs: Add new test for closure in closure parsing
This new test highlight the fix of #2656.
gcc/testsuite/ChangeLog:
* rust/compile/closure_in_closure.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Tue, 10 Oct 2023 12:06:30 +0000 (14:06 +0200)]
gccrs: Break OR tokens in closure parameter list context
The parser was unable to process as closure inside a closure because the
lexer could not differentiate an OR from two PIPE tokens.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_closure_expr_pratt): Fix
closure parsing function to handle consecutive parameter lists.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 16 Oct 2023 08:41:06 +0000 (10:41 +0200)]
gccrs: Add new regression test for macro matcher behavior
Add a new test to highlight the fix introduced for #2653.
gcc/testsuite/ChangeLog:
* rust/compile/macro-issue2653.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 16 Oct 2023 08:29:35 +0000 (10:29 +0200)]
gccrs: Add path to macro fragment follow restrictions
The previous follow set rules did not allow PATH fragment, changing this
allow gccrs to accept more valid rust macros.
gcc/rust/ChangeLog:
* ast/rust-macro.h: Add PATH fragment to follow set restrictions.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Tue, 17 Oct 2023 12:56:09 +0000 (14:56 +0200)]
gccrs: Add a new test for mbe named macro_rules
Macro rules named macro_rules may cause some problems if not handled
correctly. This new test ensure we always compile those macros named
macro_rules correctly as well as other macro definitions.
gcc/testsuite/ChangeLog:
* rust/compile/macro57.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Tue, 10 Oct 2023 14:03:45 +0000 (16:03 +0200)]
gccrs: Add new regression test
This new test highlight the fix for #2651.
gcc/testsuite/ChangeLog:
* rust/compile/macro_rules_macro_rules.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Tue, 10 Oct 2023 13:46:48 +0000 (15:46 +0200)]
gccrs: Allow macro named macro_rules
Change the constraints around macro rules declaration in order to allow
macro_rules named macro as well as tighter constraint around macro rules
definitions.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::is_macro_rules_def): Add a function
that checks tokens given by the lexer represents an accurate macro
definition. This will reduce code duplication.
(Parser::parse_item): Replace condition with call to new checking
function.
(Parser::parse_stmt): Likewise.
* parse/rust-parse.h: Add function prototype for is_macro_rules_def.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 16 Oct 2023 12:21:42 +0000 (14:21 +0200)]
gccrs: Add new regression test
Add a new test to highlight fix of #2658.
gcc/testsuite/ChangeLog:
* rust/compile/while_break_expr.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Tue, 10 Oct 2023 11:20:33 +0000 (13:20 +0200)]
gccrs: Add a new regression test
Add a new test to highlight the fix made for #2660.
gcc/testsuite/ChangeLog:
* rust/compile/range_from_expr_for_loop.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Tue, 10 Oct 2023 11:11:55 +0000 (13:11 +0200)]
gccrs: Fix RangeFromExpr parsing in for loops
Those ranges were looking for a curly brace after the brace, leading
to an error when using range from expr in for loops.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_expr): Fix range from expr.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Tue, 10 Oct 2023 12:53:39 +0000 (14:53 +0200)]
gccrs: Add a new regression test for macro call "default"
This test highlight the fix required for #2655.
gcc/testsuite/ChangeLog:
* rust/compile/parse_item_default_macro.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Tue, 10 Oct 2023 12:36:35 +0000 (14:36 +0200)]
gccrs: Allow call to macro named "default" at item level
The parser was too agressive and did reject any line beginning with
default even if this was a macro call.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_item): Relax constraints
around default identifier at item scope to accept "default" macros.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Tue, 10 Oct 2023 08:21:16 +0000 (10:21 +0200)]
gccrs: Add a new regression test
New regression test to highlight behavior of #2652.
gcc/testsuite/ChangeLog:
* rust/compile/parse_generic_path_expr.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Tue, 10 Oct 2023 08:04:57 +0000 (10:04 +0200)]
gccrs: Fix path expr segment parsing with generic path
When a token was identified as bit left shift it slipped through the
parser and resulted in an error.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_path_expr_segment): Accept
left shift tokens in order to let generic parsing function split the
token.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Owen Avery [Wed, 11 Oct 2023 02:50:55 +0000 (22:50 -0400)]
gccrs: Replace get_pattern_node_id with get_node_id
gcc/rust/ChangeLog:
* ast/rust-ast.h
(Pattern::get_pattern_node_id): Rename to...
(Pattern::get_node_id): ...here.
* ast/rust-macro.h
(MacroInvocation::get_pattern_node_id): Rename to...
(MacroInvocation::get_node_id): ...here.
* ast/rust-path.h
(PathInExpression::get_pattern_node_id): Remove.
(QualifiedPathInExpression::get_pattern_node_id): Remove.
* ast/rust-pattern.h
(LiteralPattern::get_pattern_node_id): Remove.
(IdentifierPattern::get_pattern_node_id): Remove.
(WildcardPattern::get_pattern_node_id): Remove.
(RestPattern::get_pattern_node_id): Rename to...
(RestPattern::get_node_id): ...here.
(RangePattern::get_pattern_node_id): Remove.
(ReferencePattern::get_pattern_node_id): Remove.
(StructPattern::get_pattern_node_id): Remove.
(TupleStructPattern::get_pattern_node_id): Remove.
(TuplePattern::get_pattern_node_id): Remove.
(GroupedPattern::get_pattern_node_id): Remove.
(SlicePattern::get_pattern_node_id): Remove.
(AltPattern::get_pattern_node_id): Remove.
* resolve/rust-early-name-resolver.cc
(EarlyNameResolver::visit):
Use get_node_id instead of get_pattern_node_id.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Pierre-Emmanuel Patry [Wed, 11 Oct 2023 12:40:18 +0000 (14:40 +0200)]
gccrs: Add regression test
This new test highlight the fix for issue #2657.
gcc/testsuite/ChangeLog:
* rust/compile/match_break.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Wed, 11 Oct 2023 12:31:25 +0000 (14:31 +0200)]
gccrs: Add comma for expr delimiter to fix match arms
Add a comma as an expr delimiter, this will allow correct parsing of
match arm expressions.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_expr): Add comma delimiter.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 16 Oct 2023 09:41:27 +0000 (11:41 +0200)]
gccrs: Add regression test
Add a new test to highlight fix for #2648.
gcc/testsuite/ChangeLog:
* rust/compile/parse_pub_unit_type.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 16 Oct 2023 09:28:34 +0000 (11:28 +0200)]
gccrs: Fix pub unit type parsing
Public unit types where not parsed correctly due to visibility specifiers
within parenthesis. Fixes #2648.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_visibility): Relax constraints
over public visibility return condition in order to accept pub unit
types.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Jakub Dupak [Thu, 5 Oct 2023 10:36:08 +0000 (12:36 +0200)]
gccrs: TyTy: use new subclass API
gcc/rust/ChangeLog:
* typecheck/rust-tyty.cc (BaseType::is_unit): Refactor.
(BaseType::satisfies_bound): Refactor.
(BaseType::get_root): Refactor.
(BaseType::destructure): Refactor.
(BaseType::monomorphized_clone): Refactor.
(BaseType::is_concrete): Refactor.
(InferType::InferType): Refactor.
(InferType::clone): Refactor.
(InferType::apply_primitive_type_hint): Refactor.
(StructFieldType::is_equal): Refactor.
(ADTType::is_equal): Refactor.
(handle_substitions): Refactor.
(ADTType::handle_substitions): Refactor.
(TupleType::TupleType): Refactor.
(TupleType::is_equal): Refactor.
(TupleType::handle_substitions): Refactor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 3 Oct 2023 14:14:39 +0000 (16:14 +0200)]
gccrs: TyTy: TyTy improved subclass casting and checking
Associate each subclass with its kind and create cast/match+cast
methods.
gcc/rust/ChangeLog:
* typecheck/rust-tyty.cc (InferType::InferType): Use static constant for kind information.
(ErrorType::ErrorType): Use static constant for kind information.
(TupleType::TupleType): Use static constant for kind information.
(BoolType::BoolType): Use static constant for kind information.
(IntType::IntType): Use static constant for kind information.
(UintType::UintType): Use static constant for kind information.
(FloatType::FloatType): Use static constant for kind information.
(USizeType::USizeType): Use static constant for kind information.
(ISizeType::ISizeType): Use static constant for kind information.
(CharType::CharType): Use static constant for kind information.
(ReferenceType::ReferenceType): Use static constant for kind information.
(PointerType::PointerType): Use static constant for kind information.
(ParamType::ParamType): Use static constant for kind information.
(StrType::StrType): Use static constant for kind information.
(NeverType::NeverType): Use static constant for kind information.
(PlaceholderType::PlaceholderType): Use static constant for kind information.
* typecheck/rust-tyty.h: Add static kind information to all TyTy classes.
Create safe cast and check methods.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Pierre-Emmanuel Patry [Tue, 10 Oct 2023 08:37:18 +0000 (10:37 +0200)]
gccrs: Add a regression test for global path parsing
Add a new test to highlight fix for #2649.
gcc/testsuite/ChangeLog:
* rust/compile/parse_global_path_generic.rs: New test.
Pierre-Emmanuel Patry [Mon, 9 Oct 2023 12:46:55 +0000 (14:46 +0200)]
gccrs: Fix type param bound parsing with opening scope
The function parsing type param bounds had a problem with scope
resolution opening token.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_type_param_bound): Add missing
case for lifetime switch.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 9 Oct 2023 11:06:22 +0000 (13:06 +0200)]
gccrs: Change debug log call to as_string function
This will ensure an accurate representation of the token. Also update the
as_string function to represent accurately scope resolution tokens.
gcc/rust/ChangeLog:
* lex/rust-token.cc (Token::as_string): Update function to output scope
resolution tokens correctly.
* parse/rust-parse-impl.h (Parser::parse_generic_param): Change call to
as_string.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Raiki Tamura [Tue, 8 Aug 2023 08:13:29 +0000 (17:13 +0900)]
gccrs: Initial implementation of v0 mangling
gcc/rust/ChangeLog:
* backend/rust-compile-context.h: Modify declaration.
* backend/rust-mangle.cc (struct V0Path): New struct.
(v0_path): New function.
(legacy_mangle_name): Take Context as argument.
(v0_numeric_prefix): Fix type strings.
(v0_complex_type_prefix): New function.
(v0_add_integer_62): Deleted
(v0_integer_62): New function.
(v0_add_opt_integer_62): Deleted.
(v0_opt_integer_62): New function.
(v0_add_disambiguator): Deleted.
(v0_disambiguator): New function.
(v0_type_prefix): Support more types.
(v0_generic_args): New function.
(v0_add_identifier): Deleted.
(v0_identifier): New function.
(v0_type_path): New function.
(v0_function_path): New function.
(v0_scope_path): New function.
(v0_crate_path): New function.
(v0_inherent_or_trait_impl_path): New function.
(v0_mangle_item): Use v0_path.
(Mangler::mangle_item): Take Context as argument.
* backend/rust-mangle.h (class Context): Add forward declaration.
* hir/tree/rust-hir-item.h: Fix include.
Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
Owen Avery [Sat, 7 Oct 2023 03:16:41 +0000 (23:16 -0400)]
gccrs: Rename cloning methods in TupleStructItems and TuplePatternItems
gcc/rust/ChangeLog:
* hir/tree/rust-hir-pattern.h
(TupleStructItems::clone_tuple_struct_items_impl): Rename to...
(TupleStructItems::clone_tuple_items_impl): ...here.
(TupleStructItemsNoRange::clone_tuple_struct_items_impl): Rename to...
(TupleStructItemsNoRange::clone_tuple_items_impl): ...here.
(TupleStructItemsRange::clone_tuple_struct_items_impl): Rename to...
(TupleStructItemsRange::clone_tuple_items_impl): ...here.
(TuplePatternItems::clone_tuple_pattern_items_impl): Rename to...
(TuplePatternItems::clone_tuple_items_impl): ...here.
(TuplePatternItemsMultiple::clone_tuple_pattern_items_impl): Rename to...
(TuplePatternItemsMultiple::clone_tuple_items_impl): ...here.
(TuplePatternItemsRanged::clone_tuple_pattern_items_impl): Rename to...
(TuplePatternItemsRanged::clone_tuple_items_impl): ...here.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Tue, 3 Oct 2023 21:56:33 +0000 (17:56 -0400)]
gccrs: Adjust methods for TuplePatternItems to match TupleStructItems
gcc/rust/ChangeLog:
* hir/tree/rust-hir-pattern.h
(TuplePatternItems::get_pattern_type): Rename to...
(TuplePatternItems::get_item_type): ...here.
(TuplePatternItemsMultiple::get_pattern_type): Rename to...
(TuplePatternItemsMultiple::get_item_type): ...here.
(TuplePatternItemsRanged::get_pattern_type): Rename to...
(TuplePatternItemsRanged::get_item_type): ...here.
* backend/rust-compile-expr.cc: Adjust calls to renamed methods.
* backend/rust-compile-pattern.cc: Likewise.
* typecheck/rust-hir-type-check-pattern.cc: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Marc Poulhiès [Fri, 13 Oct 2023 22:02:47 +0000 (00:02 +0200)]
gccrs: minor changes (typo and minor refactor)
Fix a typo and merge 2 if clauses using the same condition.
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): Merge 2 if clauses.
* backend/rust-compile-extern.h: Fix typo in comment.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Jakub Dupak [Thu, 5 Oct 2023 12:52:24 +0000 (14:52 +0200)]
gccrs: Add test for parser bug
gcc/testsuite/ChangeLog:
* rust/compile/issue-2645.rs: New test.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Thu, 5 Oct 2023 10:10:37 +0000 (12:10 +0200)]
gccrs: Fix parser bug on tupplestruct pattern
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h: Add missing token consumption
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Mohammed Rizan Farooqui [Wed, 4 Oct 2023 08:19:24 +0000 (13:49 +0530)]
gccrs: Removed unnecessary comments
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::include_str_handler): Comment removed
(MacroBuiltin::env_handler): Comment removed
(MacroBuiltin::cfg_handler): Comment removed
(MacroBuiltin::line_handler): Comment removed
Signed-off-by: Mohammed Rizan Farooqui <rizanfarooqui@gmail.com>
Jakub Dupak [Mon, 2 Oct 2023 19:54:16 +0000 (21:54 +0200)]
gccrs: Fix type confusion in coercion
There was a mismatch between a manual discriminant test and the static cast.
gcc/rust/ChangeLog:
* backend/rust-compile.cc (HIRCompileBase::coercion_site1): Fix wrong cast
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Pierre-Emmanuel Patry [Tue, 26 Sep 2023 12:49:10 +0000 (14:49 +0200)]
gccrs: Fix ICE when emitting an error during cfg strip
When an error was emitted during the cfg strip pass by the crate loader,
it was ignored and the error state propagated until another pass
(name resolver).
gcc/rust/ChangeLog:
* rust-session-manager.cc (Session::expansion): Add early break on
error.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Raiki Tamura [Wed, 20 Sep 2023 04:42:02 +0000 (13:42 +0900)]
gccrs: Fix CanonicalPath for inherent impl
gcc/rust/ChangeLog:
* util/rust-canonical-path.h: Add new segment kind for inherent impl.
* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Use it.
* resolve/rust-ast-resolve-toplevel.h: Use it.
Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
Owen Avery [Tue, 19 Sep 2023 15:48:02 +0000 (11:48 -0400)]
gccrs: Fix spelling
gcc/rust/ChangeLog:
* ast/rust-expr.h: Fix spelling of "doesn't".
* backend/rust-compile-expr.cc: Fix spelling of "accessors".
* backend/rust-compile-implitem.h: Fix spelling of "normal".
* backend/rust-constexpr.cc: Fix spelling of "actual".
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Marc Poulhiès [Mon, 18 Sep 2023 20:16:06 +0000 (22:16 +0200)]
gccrs: Add debug helper to dump HIR
Add simple debug wrapper to dump HIR nodes on stderr.
Similar to what we already have for AST.
gcc/rust/ChangeLog:
* hir/rust-hir-dump.cc (Dump::debug): New.
(debug): New.
* hir/rust-hir-dump.h (debug): New.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Philip Herron [Sun, 17 Sep 2023 19:11:23 +0000 (20:11 +0100)]
gccrs: port over readonly_error from c-family for lvalue assignment checks
Fixes #2391
gcc/rust/ChangeLog:
* Make-lang.in: fixup formatting
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): remove old check
* rust-session-manager.cc (Session::compile_crate): call new lint
* resolve/rust-ast-verify-assignee.h: Removed.
* checks/errors/rust-readonly-check.cc: New file.
* checks/errors/rust-readonly-check.h: New file.
gcc/testsuite/ChangeLog:
* rust/compile/wrong_lhs_assignment.rs: update error message
* rust/compile/issue-2391.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Muhammad Mahad [Sun, 17 Sep 2023 11:58:51 +0000 (16:58 +0500)]
gccrs: [E0617] attempt for invalid type variable in variadic function
There are some certain rust types must be cast before
passing them to a variadic function, because of arcane
ABI rules dictated by the C standard. To fix the error,
cast the value to the type specified by the error message.
gcc/rust/ChangeLog:
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit):
Added ErrorCode & more fixit hints.
gcc/testsuite/ChangeLog:
* rust/compile/variadic.rs: Added new checks.
Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
Philip Herron [Sun, 17 Sep 2023 14:08:42 +0000 (15:08 +0100)]
gccrs: Remove HIR::ForLoopExpr
This will end up getting desugared into a LoopExpr with a MatchExpr body.
gcc/rust/ChangeLog:
* backend/rust-compile-block.h: remove HIR::ForLoopExpr
* backend/rust-compile-expr.h: likewise
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): likewise
* checks/errors/privacy/rust-privacy-reporter.h: likewise
* checks/errors/rust-const-checker.cc (ConstChecker::visit): likewise
* checks/errors/rust-const-checker.h: likewise
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): likewise
* checks/errors/rust-unsafe-checker.h: likewise
* checks/lints/rust-lint-marklive.h: likewise
* hir/rust-ast-lower.cc (ASTLoweringExprWithBlock::visit): likewise
* hir/rust-hir-dump.cc (Dump::visit): likewise
* hir/rust-hir-dump.h: likewise
* hir/tree/rust-hir-expr.h (class ForLoopExpr): likewise
* hir/tree/rust-hir-full-decls.h (class ForLoopExpr): likewise
* hir/tree/rust-hir-visitor.h: likewise
* hir/tree/rust-hir.cc (ForLoopExpr::as_string): likewise
(ForLoopExpr::accept_vis): likewise
* typecheck/rust-hir-type-check-expr.h: likewise
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Marc Poulhiès [Sat, 16 Sep 2023 21:31:34 +0000 (23:31 +0200)]
gccrs: Minor typo fix
Fix varadic -> variadic
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): Fix typo in varIadic.
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise.
* rust-backend.h (function_type_varadic): Rename into ...
(function_type_variadic): ... this.
* rust-gcc.cc (function_type_varadic): Rename into ...
(function_type_variadic): ... this.
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise.
* typecheck/rust-tyty.h (is_varadic): Renamed into ...
(is_variadic): ... this.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Pierre-Emmanuel Patry [Mon, 11 Sep 2023 10:13:01 +0000 (12:13 +0200)]
gccrs: Add license text to libproc_macro rust interface
The license text was missing in rust files producing the libproc_macro
interface to the libproc_macro_internal library.
libgrust/ChangeLog:
* libproc_macro/bridge.rs: Add license text.
* libproc_macro/bridge/ffistring.rs: Likewise.
* libproc_macro/bridge/group.rs: Likewise.
* libproc_macro/bridge/ident.rs: Likewise.
* libproc_macro/bridge/literal.rs: Likewise.
* libproc_macro/bridge/punct.rs: Likewise.
* libproc_macro/bridge/span.rs: Likewise.
* libproc_macro/bridge/token_stream.rs: Likewise.
* libproc_macro/group.rs: Likewise.
* libproc_macro/ident.rs: Likewise.
* libproc_macro/lib.rs: Likewise.
* libproc_macro/literal.rs: Likewise.
* libproc_macro/punct.rs: Likewise.
* libproc_macro/span.rs: Likewise.
* libproc_macro/token_stream.rs: Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Marc Poulhiès [Thu, 14 Sep 2023 21:24:26 +0000 (23:24 +0200)]
gccrs: trivial typo fix.
Fix subsititions -> substitutions
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc (HIRCompileBase::compile_function):
Fix typo in substitutions.
(HIRCompileBase::resolve_method_address): Likewise.
* backend/rust-compile-extern.h (CompileExternItem::visit):
Likewise.
* backend/rust-compile-implitem.cc (CompileTraitItem::visit):
Likewise.
* backend/rust-compile-intrinsic.cc (maybe_override_ctx):
Likewise.
* backend/rust-compile-item.cc (CompileItem::visit): Likewise.
* backend/rust-compile-resolve-path.cc
(HIRCompileBase::query_compile): Likewise.
* typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion):
Likewise.
* typecheck/rust-hir-type-check-item.cc
(TypeCheckItem::ResolveImplBlockSelfWithInference): Likewise.
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit):
Likewise.
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit):
Likewise.
* typecheck/rust-tyty.cc (BaseType::has_subsititions_defined):
Renamed into ...
(BaseType::has_substitutions_defined): ... this.
(ADTType::is_equal): Fix typo in substitutions.
(handle_substitions): Likewise.
(FnType::is_equal): Likewise.
(FnType::handle_substitions): Likewise.
* typecheck/rust-tyty.h (has_subsititions_defined): Renamed into
...
(has_substitutions_defined): ... this.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Owen Avery [Wed, 13 Sep 2023 16:32:33 +0000 (12:32 -0400)]
gccrs: Add intrinsics::assume
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc
(get_identifier): Add declaration.
(assume_handler): New.
(generic_intrinsics): Add assume_handler entry.
gcc/testsuite/ChangeLog:
* rust/compile/assume.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Tue, 12 Sep 2023 16:52:25 +0000 (12:52 -0400)]
gccrs: Memoize Backend::wchar_type
gcc/rust/ChangeLog:
* rust-gcc.cc
(Backend::wchar_type): Store static wchar tree.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Wed, 13 Sep 2023 01:42:01 +0000 (21:42 -0400)]
gccrs: Remove unused complex number support
gcc/rust/ChangeLog:
* rust-backend.h
(complex_type): Remove.
(complex_constant_expression): Remove.
(real_part_expression): Remove.
(imag_part_expression): Remove.
(complex_expression): Remove.
* rust-gcc.cc
(complex_type): Remove.
(complex_constant_expression): Remove.
(real_part_expression): Remove.
(imag_part_expression): Remove.
(complex_expression): Remove.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Thu, 7 Sep 2023 23:07:52 +0000 (19:07 -0400)]
gccrs: Use namespace definition to simplify function declarations
gcc/rust/ChangeLog:
* rust-gcc.cc
(namespace Backend):
Use namespace definition instead of qualified names.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
liushuyu [Thu, 1 Jun 2023 04:22:35 +0000 (22:22 -0600)]
gccrs: rust-compile-intrinsic: add `copy` intrinsics ...
... also made `copy_nonoverlapping` handler more generic
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc: add `copy`
intrinsics and make `copy_nonoverlapping` handler more generic
Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
liushuyu [Thu, 1 Jun 2023 04:08:02 +0000 (22:08 -0600)]
gccrs: rust-builtins: add likely and unlikey intrinsics
gcc/rust/ChangeLog:
* backend/rust-builtins.cc: add `expect` builtin definition.
* backend/rust-compile-intrinsic.cc: add `likely` and `unlikely`
intrinsics handler.
Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
Owen Avery [Wed, 13 Sep 2023 04:36:06 +0000 (00:36 -0400)]
gccrs: Rename "rust_error_codes.def" to "rust-error-codes.def"
gcc/rust/ChangeLog:
* rust_error_codes.def: Moved to...
* rust-error-codes.def: ...here...
* rust-diagnostics.h: ...and update references.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Guillaume Gomez [Fri, 8 Sep 2023 13:40:28 +0000 (15:40 +0200)]
gccrs: Shorten `make_unsigned_long_tree` code and remove `Backend::integer_constant_expression`
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc: Simplify `make_unsigned_long_tree`
* rust-backend.h: Remove `integer_constant_expression`
* rust-gcc.cc: Remove `integer_constant_expression`
Dave Evans [Thu, 24 Aug 2023 19:10:42 +0000 (14:10 -0500)]
gccrs: Fix typechecking (and compilation) error for alt patterns in match expressions.
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit):
Add AltPattern visitor function
* backend/rust-compile-pattern.h:
Update CompilePatternCaseLabelExpr::visit(AltPattern&).
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
Update AltPattern visitor
gcc/testsuite/ChangeLog:
* rust/compile/issue-2431.rs: New test.
Signed-off-by: Dave Evans <dave@dmetwo.org>
Guillaume Gomez [Mon, 11 Sep 2023 14:38:40 +0000 (16:38 +0200)]
gccrs: Remove unused `ctx` argument in `make_unsigned_long_tree` function
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc: Remove unused argument
Arthur Cohen [Mon, 21 Aug 2023 14:28:03 +0000 (16:28 +0200)]
gccrs: privacy: Uncomment test relying on #1257
gcc/testsuite/ChangeLog:
* rust/compile/privacy6.rs: Uncomment commented out functions.
* rust/compile/privacy9.rs: Fix unused variables.
Arthur Cohen [Mon, 21 Aug 2023 14:26:51 +0000 (16:26 +0200)]
gccrs: privacy: Add testcase for #1260
gcc/testsuite/ChangeLog:
* rust/compile/privacy9.rs: New test.
Muhammad Mahad [Tue, 29 Aug 2023 15:00:18 +0000 (20:00 +0500)]
gccrs: [E0599] Failed to resovle method implementation
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Added new error message, rich location and error code.
gcc/testsuite/ChangeLog:
* rust/compile/cfg2.rs: Updated according to new message.
* rust/compile/issue-2139.rs: likewise.
* rust/compile/issue-2190-1.rs: likewise.
* rust/compile/method1.rs: likewise.
Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>