]>
git.ipfire.org Git - thirdparty/gcc.git/log
jjasmine [Sat, 9 Mar 2024 22:16:34 +0000 (17:16 -0500)]
Store visibility properly in ExternalTypeItem
Fix issue 2897
gcc/rust/ChangeLog:
* hir/rust-ast-lower-extern.h: Add translate_visiblity
* hir/tree/rust-hir-item.h: Fix constructor of ExternalTypeItem
Jakub Dupak [Fri, 2 Feb 2024 13:12:13 +0000 (14:12 +0100)]
TyTy: Collect variance info from types
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):
Collect variance info from types.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Fri, 2 Feb 2024 13:09:38 +0000 (14:09 +0100)]
TyTy: Variance analysis module
gcc/rust/ChangeLog:
* Make-lang.in: Add new .cc file.
* rust-session-manager.cc (Session::compile_crate): Run
analysis.
* typecheck/rust-tyty-variance-analysis-private.h: New file.
* typecheck/rust-tyty-variance-analysis.cc: New file.
* typecheck/rust-tyty-variance-analysis.h: New file.
* typecheck/rust-typecheck-context.cc
(TypeCheckContext::get_variance_analysis_ctx):
Variance analysis context.
* typecheck/rust-hir-type-check.h (TypeCheckItem::visit):
Variance analysis context.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Fri, 2 Feb 2024 11:11:45 +0000 (12:11 +0100)]
TyTy: add common SubstitutionRef API
gcc/rust/ChangeLog:
* typecheck/rust-tyty-subst.cc (SubstitutionRef::get_arg_at):
Add unified API.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Arthur Cohen [Thu, 7 Mar 2024 13:57:54 +0000 (14:57 +0100)]
format-args: Only pass the format string to the parser.
This fixes an issue we had where the generated code ended with more static
pieces than its rustc counterpart.
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (struct FormatArgsInput): Store the format_str
as a string instead of an AST::Expr.
(format_args_parse_arguments): Transform format_expr into a format string
properly - add note for handling eager macro invocations later on.
(MacroBuiltin::format_args_handler): Parse the correct input, append
newline to format_str if necessary.
Arthur Cohen [Thu, 29 Feb 2024 15:09:23 +0000 (16:09 +0100)]
format-args: Add basic test case
gcc/testsuite/ChangeLog:
* rust/compile/format_args_basic_expansion.rs: New test.
Arthur Cohen [Thu, 29 Feb 2024 13:53:05 +0000 (14:53 +0100)]
format-args: Add basic expansion of unnamed Display::fmt arguments.
gcc/rust/ChangeLog:
* ast/rust-ast-builder.h: Rename AST::AstBuilder -> AST::Builder
* ast/rust-ast-builder.cc: Likewise.
* expand/rust-derive.cc: Use new AST::Builder name.
* expand/rust-derive.h: Likewise.
* ast/rust-builtin-ast-nodes.h: Add required getters.
* expand/rust-expand-format-args.cc (format_arg): New.
(get_trait_name): New.
(expand_format_args): Properly expand basic format_args!() invocations.
* expand/rust-expand-format-args.h (expand_format_args): Fix signature.
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Call into expand_format_args().
Arthur Cohen [Thu, 22 Feb 2024 15:26:40 +0000 (16:26 +0100)]
format-args: Start storing string in Rust memory
gcc/rust/ChangeLog:
* ast/rust-fmt.cc (ffi::RustHamster::to_string): New.
(Pieces::collect): Adapt to use new handle API.
(Pieces::~Pieces): Likewise.
(Pieces::Pieces): Likewise.
(Pieces::operator=): Likewise.
* ast/rust-fmt.h (struct RustString): Add members.
(struct FormatArgsHandle): New.
(clone_pieces): Adapt for new FFI API.
(destroy_pieces): Likewise.
(struct Pieces): Store new FormatArgsHandle type.
* expand/rust-expand-format-args.cc (expand_format_args): Use proper
namespace.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): FormatArgs
nodes are already resolved, so do nothing.
libgrust/ChangeLog:
* libformat_parser/src/lib.rs: Use new Handle struct and expose it.
Arthur Cohen [Thu, 29 Feb 2024 12:01:32 +0000 (13:01 +0100)]
format-args: Add base for expanding FormatArgs nodes
gcc/rust/ChangeLog:
* Make-lang.in: Add new object.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Remove calls to
FormatArgsLowering.
* expand/rust-expand-format-args.cc: New file.
* expand/rust-expand-format-args.h: New file.
Arthur Cohen [Tue, 19 Mar 2024 12:12:20 +0000 (13:12 +0100)]
macro: Use MacroInvocation's node_id in ExternalItem constructor.
gcc/rust/ChangeLog:
* ast/rust-macro.h: Use proper node id instead of the one in the base
Expr class - which is uninitialized.
Arthur Cohen [Mon, 18 Mar 2024 14:10:43 +0000 (15:10 +0100)]
ci: Install Rust directly from rustup instead of apt
ChangeLog:
* .github/workflows/ccpp.yml: Install Rust manually.
Pierre-Emmanuel Patry [Thu, 22 Feb 2024 17:55:53 +0000 (18:55 +0100)]
Replace unique_ptr references with references
This kind of double indirection is pointless and prone to error. This
commit change the api of all getters from the AST to use references
directly instead of references to unique pointers.
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): Remove reference
to unique pointer and replace it with a direct reference to the wrapped
data.
* ast/rust-ast.cc (VariadicParam::as_string): Likewise.
(BlockExpr::normalize_tail_expr): Likewise.
* ast/rust-expr.h: Likewise and add pointer getter in order to allow
pointer reseat.
* ast/rust-item.h: Likewise and add pointer getter for reseat.
* ast/rust-path.h: Likewise.
* ast/rust-pattern.h: Likewise.
* ast/rust-stmt.h: Likewise.
* ast/rust-type.h: Likewise.
* expand/rust-cfg-strip.cc (CfgStrip::maybe_strip_struct_fields):
Remove references to unique pointers and replace it with direct
references to the wrapped object.
(CfgStrip::maybe_strip_tuple_fields): Likewise.
(CfgStrip::maybe_strip_generic_args): Likewise.
(CfgStrip::maybe_strip_qualified_path_type): Likewise.
(CfgStrip::visit): Likewise.
* expand/rust-expand-visitor.cc (ExpandVisitor::maybe_expand_expr):
Likewise.
(ExpandVisitor::maybe_expand_type): Likewise.
(ExpandVisitor::visit): Likewise.
* expand/rust-expand-visitor.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_binding):
Likewise.
(ASTLoweringBase::lower_generic_args): Likewise.
(ASTLoweringBase::lower_self): Likewise.
(ASTLoweringBase::lower_type_no_bounds): Likewise.
(ASTLoweringBase::lower_bound): Likewise.
(ASTLoweringBase::lower_range_pattern_bound): Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-block.h: Likewise.
* hir/rust-ast-lower-enumitem.h: Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::translate): Likewise.
(ASTLoweringExpr::visit): Likewise.
* hir/rust-ast-lower-expr.h: Likewise.
* hir/rust-ast-lower-extern.h: Likewise.
* hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::translate):
Likewise.
(ASTLowerImplItem::visit): Likewise.
(ASTLowerTraitItem::translate): Likewise.
(ASTLowerTraitItem::visit): Likewise.
* hir/rust-ast-lower-implitem.h: Likewise.
* hir/rust-ast-lower-item.cc (ASTLoweringItem::translate): Likewise.
(ASTLoweringItem::visit): Likewise.
* hir/rust-ast-lower-item.h: Likewise.
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate):
Likewise.
(ASTLoweringPattern::visit): Likewise.
* hir/rust-ast-lower-pattern.h: Likewise.
* hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Likewise.
* hir/rust-ast-lower-struct-field-expr.h: Likewise.
* hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Likewise.
(ASTLowerQualifiedPathInType::visit): Likewise.
(ASTLoweringType::translate): Likewise.
(ASTLoweringType::visit): Likewise.
(ASTLowerGenericParam::translate): Likewise.
(ASTLowerGenericParam::visit): Likewise.
(ASTLoweringTypeBounds::translate): Likewise.
(ASTLoweringTypeBounds::visit): Likewise.
(ASTLowerWhereClauseItem::visit): Likewise.
* hir/rust-ast-lower-type.h: Likewise.
* hir/rust-ast-lower.cc (ASTLowering::go): Likewise.
(ASTLoweringBlock::visit): Likewise.
(ASTLoweringIfBlock::visit): Likewise.
(ASTLoweringIfLetBlock::visit): Likewise.
(ASTLowerStructExprField::visit): Likewise.
(ASTLoweringExprWithBlock::visit): Likewise.
(ASTLoweringBase::lower_qual_path_type): Likewise.
(ASTLoweringBase::lower_closure_param): Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::resolve_visibility):
Likewise.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::go): Likewise.
(ResolveExpr::visit): Likewise.
(ResolveExpr::resolve_closure_param): Likewise.
* resolve/rust-ast-resolve-expr.h: Likewise.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit):
Likewise.
(ResolveItem::go): Likewise.
(ResolveItem::visit): Likewise.
(ResolveItem::resolve_impl_item): Likewise.
(ResolveItem::resolve_extern_item): Likewise.
(ResolveImplItems::go): Likewise.
(ResolveExternItem::go): Likewise.
(ResolveExternItem::visit): Likewise.
* resolve/rust-ast-resolve-item.h: Likewise.
* resolve/rust-ast-resolve-path.cc (ResolvePath::go): Likewise.
(ResolvePath::resolve_path): Likewise.
* resolve/rust-ast-resolve-path.h: Likewise.
* resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::go):
Likewise.
(PatternDeclaration::visit): Likewise.
(resolve_range_pattern_bound): Likewise.
* resolve/rust-ast-resolve-pattern.h: Likewise.
* resolve/rust-ast-resolve-stmt.cc (ResolveStmt::visit): Likewise.
* resolve/rust-ast-resolve-stmt.h: Likewise.
* resolve/rust-ast-resolve-struct-expr-field.cc (ResolveStructExprField::go):
Likewise.
(ResolveStructExprField::visit): Likewise.
* resolve/rust-ast-resolve-struct-expr-field.h: Likewise.
* resolve/rust-ast-resolve-toplevel.h: Likewise.
* resolve/rust-ast-resolve-type.cc (ResolveType::visit): Likewise.
(ResolveRelativeTypePath::go): Likewise.
(ResolveRelativeQualTypePath::resolve_qual_seg): Likewise.
(ResolveTypeToCanonicalPath::go): Likewise.
(ResolveTypeToCanonicalPath::visit): Likewise.
(ResolveGenericArgs::resolve_disambiguated_generic): Likewise.
(ResolveGenericArgs::go): Likewise.
* resolve/rust-ast-resolve-type.h: Likewise.
* resolve/rust-ast-resolve.cc (NameResolution::go): Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::resolve_qualified_path_type):
Likewise.
(EarlyNameResolver::visit): Likewise.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Likewise.
* checks/errors/rust-ast-validation.cc: Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Wed, 21 Feb 2024 15:45:18 +0000 (16:45 +0100)]
Replace reference to unique pointer with reference
Reference to unique pointers are a known anti pattern, only the element
shall be taken by reference instead of the whole wrapper.
gcc/rust/ChangeLog:
* ast/rust-item.h: Change getter function prototype to return a
reference directly instead of a reference to the wrapper type.
* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Fix
the code to accept references instead.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_self): Change
function implementation to return a reference.
* hir/rust-ast-lower-base.h: Accept a reference instead of a unique
pointer reference.
* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Adapt the code
to a reference instead of a unique pointer.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Thomas Schwinge [Tue, 12 Mar 2024 08:41:55 +0000 (09:41 +0100)]
Thomas Schwinge [Tue, 12 Mar 2024 08:36:43 +0000 (09:36 +0100)]
Placate clang-format re 'gcc/rust/backend/rust-tree.cc'
Reformat the upstream GCC commit
f4a2ae2338962208b8039f154f5912402e94c378
"Change MODE_BITSIZE to MODE_PRECISION for MODE_VECTOR_BOOL" change to
'gcc/rust/backend/rust-tree.cc' to clang-format's liking.
gcc/rust/
* backend/rust-tree.cc (c_common_type_for_mode): Placate clang-format.
Thomas Schwinge [Mon, 11 Mar 2024 22:44:18 +0000 (23:44 +0100)]
Adjust '.github/bors_log_expected_warnings'
Jakub Jelinek [Wed, 18 Oct 2023 15:01:26 +0000 (17:01 +0200)]
cse: Workaround GCC < 5 bug in cse_insn [PR111852]
Before the r5-3834 commit for PR63362, GCC 4.8-4.9 refuses to compile
cse.cc which contains a variable with rtx_def type, because rtx_def
contains a union with poly_uint16 element. poly_int template has
defaulted default constructor and a variadic template constructor which
could have empty parameter pack. GCC < 5 treated it as non-trivially
constructible class and deleted rtunion and rtx_def default constructors.
For the cse_insn purposes, all we need is a variable with size and alignment
of rtx_def, not necessarily rtx_def itself, which we then memset to 0 and
fill in like rtx is normally allocated from heap, so this patch for
GCC_VERSION < 5000 uses an unsigned char array of the right size/alignment.
2023-10-18 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/111852
* cse.cc (cse_insn): Add workaround for GCC 4.8-4.9, instead of
using rtx_def type for memory_extend_buf, use unsigned char
arrayy with size of rtx_def and its alignment.
(cherry picked from commit
bc4bd69faf986326f6b0fd0400cdd6871577afd1 )
Thomas Schwinge [Mon, 11 Mar 2024 21:51:28 +0000 (22:51 +0100)]
Thomas Schwinge [Mon, 11 Mar 2024 21:43:19 +0000 (22:43 +0100)]
Thomas Schwinge [Mon, 11 Mar 2024 21:38:33 +0000 (22:38 +0100)]
Thomas Schwinge [Mon, 11 Mar 2024 00:05:15 +0000 (01:05 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:59:26 +0000 (00:59 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:58:39 +0000 (00:58 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:57:51 +0000 (00:57 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:56:06 +0000 (00:56 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:47:49 +0000 (00:47 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:45:13 +0000 (00:45 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:34:47 +0000 (00:34 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:34:22 +0000 (00:34 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:33:08 +0000 (00:33 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:26:50 +0000 (00:26 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:25:25 +0000 (00:25 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:25:10 +0000 (00:25 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:24:32 +0000 (00:24 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:24:01 +0000 (00:24 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:21:19 +0000 (00:21 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:20:06 +0000 (00:20 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:18:11 +0000 (00:18 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:17:15 +0000 (00:17 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 23:15:40 +0000 (00:15 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:58:16 +0000 (23:58 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:54:17 +0000 (23:54 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:42:52 +0000 (23:42 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:42:46 +0000 (23:42 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:38:46 +0000 (23:38 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:38:38 +0000 (23:38 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:34:31 +0000 (23:34 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:34:09 +0000 (23:34 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:24:35 +0000 (23:24 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:22:34 +0000 (23:22 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:19:06 +0000 (23:19 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:18:49 +0000 (23:18 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:16:21 +0000 (23:16 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 22:15:52 +0000 (23:15 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 21:57:58 +0000 (22:57 +0100)]
Thomas Schwinge [Sun, 10 Mar 2024 21:56:03 +0000 (22:56 +0100)]
0xn4utilus [Wed, 28 Feb 2024 14:05:30 +0000 (19:35 +0530)]
Remove dead code associated with `AST::ExternalFunctionItem`
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit):
Remove dead code.
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-full-decls.h (class ExternalFunctionItem):
Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit):
Likewise.
* ast/rust-ast-visitor.h: Likewise.
* ast/rust-ast.cc (ExternalFunctionItem::as_string): Likewise.
(ExternalFunctionItem::accept_vis): Likewise.
* checks/errors/rust-ast-validation.cc (ASTValidation::visit):
Likewise.
* checks/errors/rust-ast-validation.h: Likewise.
* checks/errors/rust-feature-gate.h: Likewise.
* expand/rust-cfg-strip.cc (CfgStrip::visit):
Likewise.
* expand/rust-cfg-strip.h: Likewise.
* expand/rust-derive.h: Likewise.
* expand/rust-expand-visitor.cc (ExpandVisitor::visit):
Likewise.
* expand/rust-expand-visitor.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit):
Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* metadata/rust-export-metadata.cc (ExportContext::emit_function):
Likewise.
* parse/rust-parse-impl.h: Likewise.
* parse/rust-parse.h: Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit):
Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Likewise.
* resolve/rust-default-resolver.h: Likewise.
* util/rust-attributes.cc (AttributeChecker::visit): Likewise.
* util/rust-attributes.h: Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/extern_func_with_body.rs: New test.
Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
0xn4utilus [Sun, 25 Feb 2024 23:09:43 +0000 (04:39 +0530)]
Update resolver to use `AST::Function` instead of `AST::ExternalFunctionItem`
gcc/rust/ChangeLog:
* checks/errors/rust-feature-gate.cc (FeatureGate::visit):
Check if function is_external or not.
* hir/rust-ast-lower-extern.h: Use AST::Function
instead of AST::ExternalFunctionItem.
* parse/rust-parse-impl.h (Parser::parse_external_item):
Likewise.
(Parser::parse_pattern): Fix clang format.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveExternItem::visit):
Likewise.
* resolve/rust-ast-resolve-item.h: Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Check if param has_pattern before using get_pattern.
Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
0xn4utilus [Sun, 25 Feb 2024 13:33:55 +0000 (19:03 +0530)]
Unify ASTValidation::visit for ExternalFunctionItem and Function
gcc/rust/ChangeLog:
* checks/errors/rust-ast-validation.cc (ASTValidation::visit):
Add external function validation support. Add ErrorCode::E0130.
* parse/rust-parse-impl.h (Parser::parse_function): Parse
external functions from `parse_function`.
(Parser::parse_external_item): Clang format.
(Parser::parse_pattern): Clang format.
* parse/rust-parse.h: Add default parameter
`is_external` in `parse_function`.
Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
0xn4utilus [Sun, 25 Feb 2024 00:50:51 +0000 (06:20 +0530)]
Add get_pattern_kind to Pattern
gcc/rust/ChangeLog:
* ast/rust-ast.h: Add Kind Enum to
Pattern.
* ast/rust-macro.h: Add get_pattern_kind().
* ast/rust-path.h: Likewise.
* ast/rust-pattern.h: Likewise.
Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
0xn4utilus [Sun, 25 Feb 2024 00:02:26 +0000 (05:32 +0530)]
Add support for external functions
gcc/rust/ChangeLog:
* ast/rust-ast.cc (Function::Function): Add `is_external_function` field.
(Function::operator=): Likewise.
* ast/rust-ast.h: New constructor for ExternalItem.
* ast/rust-item.h (class Function): Add `is_external_function`
field. Update `get_node_id`.
* ast/rust-macro.h: Update copy constructor.
Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
Sourabh Jaiswal [Fri, 1 Mar 2024 11:46:23 +0000 (19:46 +0800)]
Clean BiMap to use tl::optional for lookups
gcc/rust/Changelog:
* expand/rust-expand-visitor.cc
(ExpandVisitor::expand_inner_items): Adjust to use has_value ()
(ExpandVisitor::expand_inner_stmts): Likewise
* expand/rust-macro-builtins.cc (builtin_macro_from_string): Likewise
(make_macro_path_str): Likewise
* util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise
* util/rust-lang-item.cc (LangItem::Parse): Adjust to return tl::optional
(LangItem::toString) Likewise
* util/rust-token-converter.cc (handle_suffix): Adjust to use value.or ()
(from_literal) Likewise
* util/bi-map.h (BiMap::lookup): Adjust to use tl::optional for
lookups
Signed-off-by: Sourabh Jaiswal <sourabhrj31@gmail.com>
Owen Avery [Tue, 27 Feb 2024 21:34:23 +0000 (16:34 -0500)]
Ensure TupleStructPattern and TuplePattern have items
Note that instances of both classes which have been
moved from will have (items == nullptr).
gcc/rust/ChangeLog:
* ast/rust-pattern.h
(class TupleStructPattern): Assert that items != nullptr.
(class TuplePattern): Likewise.
(TupleStructPattern::has_items): Remove.
(TuplePattern::has_tuple_pattern_items): Likewise.
* parse/rust-parse-impl.h
(Parser::parse_ident_leading_pattern):
Prevent construction of TupleStructPattern with
(items == nullptr).
(Parser::parse_pattern_no_alt): Likewise.
* ast/rust-ast-collector.cc
(TokenCollector::visit): Remove usage of
TupleStructPattern::has_items.
* ast/rust-ast-visitor.cc
(DefaultASTVisitor::visit): Likewise.
* resolve/rust-early-name-resolver.cc
(EarlyNameResolver::visit): Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/pattern-struct.rs: Fix test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
jjasmine [Fri, 1 Mar 2024 21:40:17 +0000 (16:40 -0500)]
Add curly brackets, formatted clang
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add error emitting
jjasmine [Fri, 1 Mar 2024 10:31:15 +0000 (05:31 -0500)]
Add error emitting when we can't resolve id expr
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add error emitting
Arthur Cohen [Fri, 1 Mar 2024 14:37:45 +0000 (15:37 +0100)]
format-args: Add documentation for future expansion of function
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Add
documentation regarding future tasks.
Arthur Cohen [Thu, 22 Feb 2024 13:59:17 +0000 (14:59 +0100)]
lower: Add base for lowering FormatArgs nodes
gcc/rust/ChangeLog:
* Make-lang.in: Compile the new source file.
* ast/rust-ast-collector.cc (TokenCollector::visit): Error out when
visiting FormatArgs nodes.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
* ast/rust-ast.cc (FormatArgs::get_locus): New.
* ast/rust-builtin-ast-nodes.h: Improve FormatArgs API.
* ast/rust-fmt.cc (Pieces::~Pieces): Cleanup.
(Pieces::Pieces): Likewise.
* ast/rust-fmt.h (struct Pieces): Add pieces_vector member.
* hir/rust-ast-lower-format-args.cc: New file.
* hir/rust-ast-lower-format-args.h: New file.
Arthur Cohen [Fri, 16 Feb 2024 17:27:22 +0000 (18:27 +0100)]
format-args: Fix Rust interface and add input parsing.
gcc/rust/ChangeLog:
* Make-lang.in: Do not build Rust library in release mode.
* ast/rust-ast.cc: Make FormatArgs inherit from AST::Expr
* ast/rust-builtin-ast-nodes.h: Improve FormatArg* nodes and helpers.
* ast/rust-fmt.cc (Pieces::collect): Fix interface to match FFI function.
* ast/rust-fmt.h (collect_pieces): Likewise.
(struct Pieces): Add append_newline parameter.
* expand/rust-macro-builtins.cc: Add proper parsing of format_args
input.
* hir/rust-ast-lower-base.cc: Include diagnostics header.
libgrust/ChangeLog:
* libformat_parser/src/lib.rs: Switch interface to use more parser
parameters.
* libformat_parser/src/bin.rs: Use new interface.
Arthur Cohen [Mon, 19 Feb 2024 19:41:50 +0000 (20:41 +0100)]
parser: Add peek(n) method to parser
gcc/rust/ChangeLog:
* parse/rust-parse.h: New method.
Arthur Cohen [Fri, 16 Feb 2024 15:19:27 +0000 (16:19 +0100)]
macro-builtins: Add newline generic format_args!() handler
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (format_args_maker): New function.
(try_expand_many_expr): Add comment about reworking function.
(MacroBuiltin::format_args_handler): Add newline parameter.
* expand/rust-macro-builtins.h: Likewise.
Arthur Cohen [Thu, 15 Feb 2024 19:58:48 +0000 (20:58 +0100)]
ast: Add base nodes for FormatArgs
This commit adds a base for creating AST FormatArgs nodes after expanding
invocations of `format_args!()`. These nodes will then be expanded to
the proper runtime function calls (to core::fmt::rt) during the AST
lowering.
gcc/rust/ChangeLog:
* ast/rust-builtin-ast-nodes.h: New file.
* ast/rust-ast-full-decls.h (class FormatArgs): Declare new class.
* ast/rust-ast-collector.cc: Handle FormatArgs nodes properly.
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-full.h: Likewise.
* ast/rust-ast-visitor.cc: Likewise.
* ast/rust-ast-visitor.h: Likewise.
* ast/rust-ast.cc: Likewise.
* ast/rust-ast.h: Likewise.
* expand/rust-derive.h: Likewise.
* hir/rust-ast-lower-base.cc: Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-expr.cc: Likewise.
* hir/rust-ast-lower-expr.h: Likewise.
* resolve/rust-ast-resolve-base.cc: Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.
Owen Avery [Wed, 28 Feb 2024 22:42:49 +0000 (17:42 -0500)]
Make DefaultResolver visit more of the AST
gcc/rust/ChangeLog:
* resolve/rust-default-resolver.cc
(DefaultResolver::visit): Visit inner AST nodes of ClosureExprInner,
ClosureExprInnerTyped, IfExpr, IfExprConseqElse, MatchExpr,
PathInExpression, EnumItemTuple, EnumItemStruct, and
EnumItemDiscriminant.
* ast/rust-item.h
(EnumItemDiscriminant::has_expr): New function.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Arthur Cohen [Tue, 20 Feb 2024 15:22:20 +0000 (16:22 +0100)]
extern-types: Lower to HIR::ExternalTypeItem properly
gcc/rust/ChangeLog:
* hir/rust-ast-lower-extern.h: Lower to HIR::ExternalTypeItem nodes.
* hir/tree/rust-hir-item.h (class ExternalTypeItem): Create private
visibility by default as extern types have no visibility - add a comment
about the correctness of this.
Arthur Cohen [Tue, 20 Feb 2024 14:45:35 +0000 (15:45 +0100)]
hir: Add ExternalTypeItem node
gcc/rust/ChangeLog:
* hir/tree/rust-hir-item.h (class ExternalTypeItem): New class.
* hir/tree/rust-hir.cc (ExternalTypeItem::as_string): Likewise.
* backend/rust-compile-extern.h: Add base for handling HIR::ExternalTypeItem
node.
* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
* checks/errors/borrowck/rust-function-collector.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.
* hir/rust-ast-lower-extern.h: Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/rust-hir-dump.h: Likewise.
* hir/tree/rust-hir-full-decls.h (class ExternalTypeItem): Likewise.
* hir/tree/rust-hir-visitor.h: Likewise.
(ExternalTypeItem::accept_vis): Likewise.
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise.
* typecheck/rust-hir-type-check-implitem.h: Likewise.
Arthur Cohen [Tue, 20 Feb 2024 13:53:32 +0000 (14:53 +0100)]
extern-types: Declare external types in name resolver.
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-implitem.h: Declare external types as new
types.
Arthur Cohen [Tue, 27 Feb 2024 13:39:22 +0000 (14:39 +0100)]
lang-items: Make lang items enum stronger, rename class, cleanup ns.
gcc/rust/ChangeLog:
* util/rust-lang-item.h (class RustLangItem): Renamed to...
(class LangItem): ...this. Rename ItemType enum to Kind
* util/rust-lang-item.cc: Rename methods to use new class name.
* backend/rust-compile-expr.cc (CompileExpr::visit): Use new lang-item API.
(CompileExpr::resolve_operator_overload): Likewise.
* backend/rust-compile-expr.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Likewise.
* typecheck/rust-autoderef.cc (Adjuster::try_deref_type): Likewise.
(AutoderefCycle::cycle): Likewise.
* typecheck/rust-autoderef.h: Likewise.
* typecheck/rust-hir-type-bounds.h: Likewise.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::get_marker_predicate): Likewise.
* typecheck/rust-hir-type-check-base.h: Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.
* typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise.
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_sized_builtin): Likewise.
(TypeBoundsProbe::assemble_builtin_candidate): Likewise.
(TypeCheckBase::get_predicate_from_bound): Likewise.
* typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise.
* util/rust-hir-map.cc (Mappings::get_lang_item): Likewise.
(Mappings::lookup_trait_item_lang_item): Likewise.
* util/rust-hir-map.h: Likewise.
Arthur Cohen [Tue, 27 Feb 2024 12:35:50 +0000 (13:35 +0100)]
lang-items: Cleanup parsing and lookups of lang items.
gcc/rust/ChangeLog:
* Make-lang.in: Compile new rust-lang-item.o.
* util/rust-lang-item.h: Split into header and source.
* util/rust-lang-item.cc: Cleanup parsing of lang items by using a hashmap
and returning optional values, cleanup handling of exhaustive lang item
lookups.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Use
new optional API.
Thomas Schwinge [Thu, 29 Feb 2024 13:04:29 +0000 (14:04 +0100)]
jjasmine [Fri, 23 Feb 2024 21:06:14 +0000 (13:06 -0800)]
Fix small FixMe task in rust macro builtins
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc: Change BuiltinMacro in
builtin_macro_from_string to tl::optional<>
* expand/rust-macro-builtins.h (enum class): Change BuiltinMacro
in builtin_macro_from_string to tl::optional<>
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
Resolved wrong type dependency of builtin_macro_from_string
Signed-off-by: jjasmine <tanghocle456@gmail.com>
Owen Avery [Fri, 23 Feb 2024 15:20:55 +0000 (10:20 -0500)]
Adjust error checks to match name resolution 2.0
gcc/testsuite/ChangeLog:
* rust/compile/bad_stmt_enums.rs: Adjust redefinition error.
* rust/compile/bad_toplevel_enums.rs: Likewise.
* rust/compile/redef_error1.rs: Likewise.
* rust/compile/redef_error3.rs: Likewise.
* rust/compile/redef_error4.rs: Likewise.
* rust/compile/redef_error6.rs: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Arthur Cohen [Mon, 26 Feb 2024 10:57:54 +0000 (11:57 +0100)]
ci: Install cargo on ubuntu 18.04 container.
ChangeLog:
* .github/workflows/ccpp.yml: Install cargo for GCC 4.8 job.
Arthur Cohen [Mon, 26 Feb 2024 10:55:47 +0000 (11:55 +0100)]
format-parser: Add `is_some_and` method for Option<T>
Workaround for Ubuntu 18.04, since we still use it for the GCC 4.8 CI.
The default Rust package is 1.65 (and unlikely to change I assume?),
but the generic format parser library uses `is_some_and` which was
introduced in 1.70. So this is a simple reimplementation, directly taken
from the standard library sources.
libgrust/ChangeLog:
* libformat_parser/generic_format_parser/src/lib.rs: Add IsSomeAnd<T>
trait, impl it for Option<T>.
Arthur Cohen [Thu, 15 Feb 2024 12:11:26 +0000 (13:11 +0100)]
libformat_parser: Fix Rust warnings.
libgrust/ChangeLog:
* libformat_parser/generic_format_parser/src/lib.rs: Remove
unused deprecated attribute and unused import.
* libformat_parser/src/lib.rs: Remove unused import.
Arthur Cohen [Tue, 13 Feb 2024 15:31:25 +0000 (16:31 +0100)]
rust-fmt: Store parsed string in Pieces struct
gcc/rust/ChangeLog:
* ast/rust-fmt.cc (Pieces::collect): Fix signature to take ownership
of the given string.
* ast/rust-fmt.h (struct Pieces): Store parsed string in the struct.
libgrust/ChangeLog:
* libformat_parser/src/lib.rs: Add debug prompt.
Arthur Cohen [Wed, 7 Feb 2024 11:46:16 +0000 (12:46 +0100)]
format_args: Parse entire token invocation
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Transform entire invocation token stream into string for the parser.
Arthur Cohen [Tue, 30 Jan 2024 15:16:36 +0000 (16:16 +0100)]
format_args: Parse format string properly
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Construct string to parser properly.
Arthur Cohen [Tue, 30 Jan 2024 00:48:13 +0000 (01:48 +0100)]
libformat_parser: Send boxed values across FFI properly
gcc/rust/ChangeLog:
* ast/rust-fmt.cc (Pieces::~Pieces): Call libformat_parser's release
function in destructor.
* ast/rust-fmt.h (struct PieceSlice): Add capacity.
(destroy_pieces): New.
(struct Pieces): Add destructor.
libgrust/ChangeLog:
* libformat_parser/src/lib.rs: Leak Boxes properly for C++ to
see them, add memory release function.
Arthur Cohen [Mon, 29 Jan 2024 21:06:39 +0000 (22:06 +0100)]
libformat_parser: Update header and remove old interface
gcc/rust/ChangeLog:
* ast/rust-fmt.cc (Pieces::collect): Use new Pieces API.
* ast/rust-fmt.h: Update interface with new FFI bindings.
libgrust/ChangeLog:
* libformat_parser/src/lib.rs: Add IntoFFI trait.
* libformat_parser/libformat-parser.h: Removed.
Arthur Cohen [Mon, 29 Jan 2024 15:17:00 +0000 (16:17 +0100)]
git: Ignore libgrust build folders
ChangeLog:
* .gitignore: Add libgrust target folders to the ignore list.
Arthur Cohen [Mon, 29 Jan 2024 15:14:13 +0000 (16:14 +0100)]
libformat_parser: Start experimenting with cbindgen
libgrust/ChangeLog:
* libformat_parser/cbindgen.toml: New file.
* libformat_parser/libformat-parser.h: New file.
gcc/rust/ChangeLog:
* ast/rust-fmt.h: Add remaining FFI types.
Arthur Cohen [Mon, 29 Jan 2024 15:13:24 +0000 (16:13 +0100)]
libformat_parser: Add FFI safe interface
libgrust/ChangeLog:
* libformat_parser/generic_format_parser/src/lib.rs: Add generic
library.
* libformat_parser/src/lib.rs: Add base for FFI interface.
Arthur Cohen [Thu, 30 Nov 2023 13:11:41 +0000 (14:11 +0100)]
libgrust: Add format_parser library
Compile libformat_parser and link to it.
gcc/rust/ChangeLog:
* Make-lang.in: Compile libformat_parser.
* ast/rust-fmt.cc: New FFI definitions.
* ast/rust-fmt.h: Likewise.
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Call
into libformat_parser.
* expand/rust-macro-builtins.h: Define format_args!() handler proper.
libgrust/ChangeLog:
* libformat_parser/Cargo.lock: New file.
* libformat_parser/Cargo.toml: New file.
* libformat_parser/generic_format_parser/Cargo.toml: New file.
* libformat_parser/generic_format_parser/src/lib.rs: New file.
* libformat_parser/src/bin.rs: New file.
* libformat_parser/src/lib.rs: New file.
Arthur Cohen [Thu, 9 Nov 2023 17:32:52 +0000 (18:32 +0100)]
fmt: Start working on format_args!() parser
This commit adds a base class for parsing the various constructs of a
Rust format string, according to the grammar in the reference:
https://doc.rust-lang.org/std/fmt/index.html#syntax
gcc/rust/ChangeLog:
* Make-lang.in: Compile rust-fmt object
* ast/rust-fmt.cc: New file.
* ast/rust-fmt.h: New file.
Marc Poulhiès [Mon, 19 Feb 2024 21:52:29 +0000 (22:52 +0100)]
gccrs: minor cleanup in langhook.type_for_mode
gcc/rust/ChangeLog:
* rust-lang.cc (grs_langhook_type_for_mode): simplify code for
xImode. Add missing long_double_type_node.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Owen Avery [Sun, 18 Feb 2024 05:19:25 +0000 (00:19 -0500)]
Fix false positive for top-level AltPattern
gcc/rust/ChangeLog:
* hir/rust-ast-lower-pattern.cc
(ASTLoweringPattern::visit):
Reset is_let_top_level while visiting GroupedPattern.
gcc/testsuite/ChangeLog:
* rust/compile/let_alt.rs: Check for false positive.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Marc Poulhiès [Mon, 19 Feb 2024 21:36:39 +0000 (22:36 +0100)]
gccrs: fix powif64 intrinsic
The signature was incorrectly using an i64 for the integer power,
instead of an i32.
gcc/testsuite/ChangeLog:
* rust/compile/torture/intrinsics-math.rs: Adjust powif64
intrinsic signature.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Pierre-Emmanuel Patry [Tue, 28 Nov 2023 12:40:55 +0000 (13:40 +0100)]
libgrust: Add entry for maintainers
ChangeLog:
* MAINTAINERS: Add maintainers for libgrust.
contrib/ChangeLog:
* gcc-changelog/git_commit.py: Add libgrust.
(cherry picked from commit
e4f0eb725d836ef0eec780cbb9e7be0d31c6fe8b )
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Tue, 28 Nov 2023 12:39:35 +0000 (13:39 +0100)]
libgrust: Add ChangeLog file
libgrust/ChangeLog:
* ChangeLog: New file.
(cherry picked from commit
a857ec6aada08d8c334c389c7b682198d749b6c9 )
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Jakub Jelinek [Thu, 15 Feb 2024 12:55:49 +0000 (13:55 +0100)]
gccrs: Avoid *.bak suffixed tests - use dg-skip-if instead
On Fri, Feb 09, 2024 at 11:03:38AM +0100, Jakub Jelinek wrote:
> On Wed, Feb 07, 2024 at 12:43:59PM +0100, arthur.cohen@embecosm.com wrote:
> > This patch introduces one regression because generics are getting better
> > understood over time. The code here used to apply generics with the same
> > symbol from previous segments which was a bit of a hack with out limited
> > inference variable support. The regression looks like it will be related
> > to another issue which needs to default integer inference variables much
> > more aggresivly to default integer.
> >
> > Fixes #2723
> > * rust/compile/issue-1773.rs: Moved to...
> > * rust/compile/issue-1773.rs.bak: ...here.
>
> Please don't use such suffixes in the testsuite.
> Either delete the testcase, or xfail it somehow until the bug is fixed.
To be precise, I have scripts to look for backup files in the tree (*~,
*.bak, *.orig, *.rej etc.) and this stands in the way several times a day.
Here is a fix for that in patch form, tested on x86_64-linux with
make check-rust RUNTESTFLAGS='compile.exp=issue-1773.rs'
2024-02-15 Jakub Jelinek <jakub@redhat.com>
* rust/compile/issue-1773.rs.bak: Rename to ...
* rust/compile/issue-1773.rs: ... this. Add dg-skip-if directive.
Sahil Yeole [Thu, 15 Feb 2024 20:48:44 +0000 (02:18 +0530)]
Update copyright years.
Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>