Skip to content
Snippets Groups Projects
  1. Feb 21, 2023
    • Richard Biener's avatar
      tree-optimization/108793 - niter compute type mismatch · a7e706df
      Richard Biener authored
      When computing the number of iterations until wrap types are mixed up,
      eventually leading to checking ICEs with a pointer bitwise inversion.
      The following uses niter_type for the calculation.
      
      	PR tree-optimization/108793
      	* tree-ssa-loop-niter.cc (number_of_iterations_until_wrap):
      	Use convert operands to niter_type when computing num.
      
      	* gcc.dg/torture/pr108793.c: New testcase.
      a7e706df
    • Thomas Schwinge's avatar
      Update copyright years. · e28c5b33
      Thomas Schwinge authored
      ... which accidentally had gotten reverted in recent
      commit r13-6156-g1e8eb102200902e12c1b00e867e338be0a92c292
      "gccrs: dump: Emit visibility when dumping items".
      e28c5b33
    • Raiki Tamura's avatar
      gccrs: add math intrinsics · ecb409b2
      Raiki Tamura authored
      gcc/rust/ChangeLog:
      
      	* backend/rust-builtins.cc (BuiltinsContext::setup_math_fns): New functions.
      
      gcc/testsuite/ChangeLog:
      
      	* rust/compile/torture/intrinsics-math.rs: New test.
      ecb409b2
    • Arthur Cohen's avatar
      gccrs: const evaluator: Remove get_nth_callarg · 064bbd0f
      Arthur Cohen authored
      We only used one path of the C++ folder's get_nth_callarg function:
      CALL_EXPR_ARG. Replace all calls to get_nth_callarg by macro calls to
      CALL_EXPR_ARG
      
      gcc/rust/ChangeLog:
      
      	* backend/rust-constexpr.cc (get_nth_callarg): Remove function.
      	(rs_bind_parameters_in_call): Use CALL_EXPR_ARG instead.
      	(potential_constant_expression_1): Likewise.
      064bbd0f
    • Thomas Schwinge's avatar
      gccrs: Repair 'gcc/rust/lang.opt' comment · b9203d82
      Thomas Schwinge authored
      ... lost in #1527 commit 138a6260124740208b8f3aff2e38617f43b05fe8
      "rust: Add -frust-compile-until option".
      
      gcc/rust/ChangeLog:
      
      	* lang.opt: Fix ordering of file.
      b9203d82
    • Philip Herron's avatar
      gccrs: Cleanup unused parameters to fix the bootstrap build · 9f455ed8
      Philip Herron authored
      gcc/rust/ChangeLog:
      
      	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Remove unused parameters.
      	* backend/rust-constexpr.cc (constant_value_1): Likewise.
      	(fold_non_dependent_init): Likewise.
      	* backend/rust-tree.cc (publicly_uniquely_derived_p): Likewise.
      	(instantiation_dependent_expression_p): Likewise.
      	(type_has_nontrivial_copy_init): Likewise.
      	(is_normal_capture_proxy): Likewise.
      	(resolve_nondeduced_context): Likewise.
      	(undeduced_auto_decl): Likewise.
      	(require_deduced_type): Likewise.
      	* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise.
      	* checks/errors/privacy/rust-reachability.cc (ReachabilityVisitor::visit): Likewise.
      	* checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::visit): Likewise.
      	* checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
      	* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
      	* checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise.
      	* checks/lints/rust-lint-unused-var.cc (unused_var_walk_fn): Likewise.
      	* expand/rust-macro-builtins.cc (try_expand_single_string_literal): Likewise.
      	(try_expand_many_expr): Likewise.
      	(parse_single_string_literal): Likewise.
      	(MacroBuiltin::assert_handler): Likewise.
      	(MacroBuiltin::file_handler): Likewise.
      	(MacroBuiltin::column_handler): Likewise.
      	(MacroBuiltin::concat_handler): Likewise.
      	(MacroBuiltin::env_handler): Likewise.
      	(MacroBuiltin::line_handler): Likewise.
      	* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
      	(ASTLoweringBase::handle_doc_item_attribute): Likewise.
      	* hir/rust-hir-dump.cc (Dump::visit): Likewise.
      	* hir/tree/rust-hir-full-test.cc (ConstGenericParam::accept_vis): Likewise.
      	* lex/rust-lex.cc (Lexer::parse_utf8_escape): Likewise.
      	(Lexer::parse_string): Likewise.
      	(Lexer::parse_char_or_lifetime): Likewise.
      	* lex/rust-lex.h: Likewise.
      	* metadata/rust-export-metadata.cc: Likewise.
      	* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise.
      	* resolve/rust-ast-resolve-type.cc (ResolveType::visit): Likewise.
      	(ResolveTypeToCanonicalPath::visit): Likewise.
      	* resolve/rust-ast-verify-assignee.h: Likewise.
      	* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise.
      	* typecheck/rust-hir-type-check-expr.h: Likewise.
      	* typecheck/rust-hir-type-check-item.h: Likewise.
      	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise.
      	* typecheck/rust-tyty-rules.h: Likewise.
      	* util/rust-attributes.cc (AttributeChecker::visit): Likewise.
      9f455ed8
    • Philip Herron's avatar
      gccrs: Skip this debug test case which is failing on the latest mac-os... · 03df9a04
      Philip Herron authored
      gccrs: Skip this debug test case which is failing on the latest mac-os devtools and its only for debug info
      
      gcc/testsuite/ChangeLog:
      
      	* rust/debug/chartype.rs: Skip testcases on Darwin architectures.
      03df9a04
    • Philip Herron's avatar
      gccrs: Fix undefined behaviour issues on macos · e7a69d45
      Philip Herron authored
      This adds missing copy constructors to HIR::PathExprSegment which were
      wrongly defaulting to empty vectors when apply specified generic arguments
      to method calls.
      
      gcc/rust/ChangeLog:
      
      	* hir/tree/rust-hir-expr.h: Add const `get_method_name`.
      	* hir/tree/rust-hir-full-decls.h (struct GenericArgs): Move from `struct`...
      	(class GenericArgs): ...to `class`.
      	* hir/tree/rust-hir-path.h (struct GenericArgs): Likewise.
      	(class GenericArgs): Clear `type_args` in copy constructor.
      	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Reorder
      	debug print.
      	* typecheck/rust-tyty.h: Add default constructors for `SubstitutionArgumentMappings`.
      e7a69d45
    • Philip Herron's avatar
      gccrs: Add initial support for argument capture of closures · 92389b46
      Philip Herron authored
      When we have a closure expression that captures a parent function's
      variable we must setup the closure data to contain this. Ignoring
      moveability and mutability requires for now, this patch creates the closure
      structure with fields for each of the captured variables. When it comes to
      compilation of the closure expression in order to support nested closures
      we must setup a context of implicit mappings so that for all path
      resolution we hit this implicit closure mappings lookups code before any
      lookup_var_decl as this decl will not exist so the order here is important
      during path resolution which is a similar problem to match expression
      destructuring.
      
      Fixes #195
      
      gcc/rust/ChangeLog:
      
      	* backend/rust-compile-context.cc (Context::push_closure_context): New function.
      	(Context::pop_closure_context): Likewise.
      	(Context::insert_closure_binding): Likewise.
      	(Context::lookup_closure_binding): Likewise.
      	* backend/rust-compile-context.h: Declare new functions and closure mappings.
      	* backend/rust-compile-expr.cc (CompileExpr::visit): Visit captures properly.
      	(CompileExpr::generate_closure_function): Compile captures properly.
      	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Check for
      	closure bindings.
      	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Compile capture list's
      	types as well.
      
      gcc/testsuite/ChangeLog:
      
      	* rust/execute/torture/closure3.rs: New test.
      92389b46
    • Philip Herron's avatar
      gccrs: Add capture tracking to the type info for closures · eb120222
      Philip Herron authored
      gcc/rust/ChangeLog:
      
      	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Pass captures
      	properly to `TyTy::ClosureType` constructor.
      	* typecheck/rust-tyty.cc (ClosureType::as_string): Fix string representation.
      	(ClosureType::clone): Pass `captures` argument.
      	* typecheck/rust-tyty.h: Add `captures` field.
      eb120222
    • Philip Herron's avatar
      gccrs: Add closure binding's tracking to name resolution · f7c258b2
      Philip Herron authored
      When we have a closure block referencing variables in a parent function,
      we must track what these are. We do this by having a context of closures
      so if we have a variable reference and its declared in a rib whose node id
      is less than the node id of the closure's node id we know it must be a
      captured variable. We also need to iterate all possible closure contexts
      as we might be in the case of a nested closure.
      
      Addresses #195
      
      gcc/rust/ChangeLog:
      
      	* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Use proper closure
      	contexts.
      	* resolve/rust-name-resolver.cc (Scope::lookup_decl_type): New function.
      	(Scope::lookup_rib_for_decl): Likewise.
      	(Resolver::insert_resolved_name): Insert captured items.
      	(Resolver::push_closure_context): New function.
      	(Resolver::pop_closure_context): Likewise.
      	(Resolver::insert_captured_item): Likewise.
      	(Resolver::decl_needs_capture): Likewise.
      	(Resolver::get_captures): Likewise.
      	* resolve/rust-name-resolver.h: Declare new functions.
      f7c258b2
    • Philip Herron's avatar
      gccrs: Refactor name resolver to take a Rib::ItemType · 32a4659c
      Philip Herron authored
      This allows us to track the type of declaration that is stored within a
      Rib.
      
      gcc/rust/ChangeLog:
      
      	* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Add Rib argument.
      	(ResolveExpr::resolve_closure_param): Likewise.
      	* resolve/rust-ast-resolve-implitem.h: Likewise.
      	* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise.
      	(ResolveItem::visit): Likewise.
      	* resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Likewise.
      	* resolve/rust-ast-resolve-pattern.h: Likewise.
      	* resolve/rust-ast-resolve-stmt.h: Likewise.
      	* resolve/rust-ast-resolve-toplevel.h: Likewise.
      	* resolve/rust-ast-resolve-type.h: Likewise.
      	* resolve/rust-name-resolver.cc (Rib::lookup_decl_type): Likewise.
      	(Scope::insert): Likewise.
      	(Resolver::insert_builtin_types): Likewise.
      	* resolve/rust-name-resolver.h: Likewise.
      32a4659c
    • Philip Herron's avatar
      gccrs: Get rid of make builtin macro · 01af6693
      Philip Herron authored
      This macro is a mess and a helper method is much better for this case.
      
      gcc/rust/ChangeLog:
      
      	* resolve/rust-name-resolver.cc (MKBUILTIN_TYPE): Remove macro.
      	(Rib::Rib): Remove `mappings` field.
      	(Resolver::generate_builtins): Use `setup_builtin` instead of macro.
      	(Resolver::setup_builtin): New function.
      	* resolve/rust-name-resolver.h: Declare `setup_builtin`, add FIXME
      	comment.
      01af6693
    • Raiki Tamura's avatar
      gccrs: Improve lexer dump · 0ef795c3
      Raiki Tamura authored
      
      gcc/rust/ChangeLog:
      
      	* lex/rust-lex.cc (Lexer::Lexer): Add `dump_lex` boolean flag.
      	(Lexer::skip_token): Dump tokens if flag is enabled.
      	(Lexer::dump_and_skip): New function.
      	* lex/rust-lex.h: Include optional.h and declare functions.
      	* parse/rust-parse-impl.h (Parser::debug_dump_lex_output): Remove old
      	unused function.
      	* parse/rust-parse.h: Likewise.
      	* rust-session-manager.cc (Session::compile_crate): Pass lexer dump
      	option to lexer.
      	(Session::dump_lex): New function.
      	* util/rust-optional.h: Add missing constructor.
      
      Signed-off-by: default avatarRaiki Tamura <tamaron1203@gmail.com>
      0ef795c3
    • Dave's avatar
      gccrs: Remove default location. Add visibility location to create_* functions · 78c70a50
      Dave authored
      gcc/rust/ChangeLog:
      
      	* ast/rust-item.h: Remoe default location for Visibility class.
      	* parse/rust-parse-impl.h (Parser::parse_visibility): Pass proper location
      	when instantiating visibilities.
      78c70a50
    • Jakub Dupak's avatar
      gccrs: ast: Dump no comma after self in fn params if it is the last one · 567494f7
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Fix dumping of fn params.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      567494f7
    • Jakub Dupak's avatar
      gccrs: ast: Dump remove /* stmp */ comment to not clutter the dump · 0e44abb1
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Remove extraneous string when
      	dumping statements.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      0e44abb1
    • Jakub Dupak's avatar
      gccrs: ast: Remove unused include in rust-ast-dump.cc · ce13edd8
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc: Remove unused include.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      ce13edd8
    • Jakub Dupak's avatar
      gccrs: ast: Dump generic parameters · b8863414
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
      	* ast/rust-ast-dump.h: Likewise.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      b8863414
    • Jakub Dupak's avatar
      gccrs: ast: Dump type param type · 1acb7e02
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      1acb7e02
    • Jakub Dupak's avatar
      gccrs: ast: Dump trait object type one bound · 0bb33cb5
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      0bb33cb5
    • Jakub Dupak's avatar
      gccrs: ast: Dump parenthesised type · e311e9b7
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      e311e9b7
    • Jakub Dupak's avatar
      gccrs: ast: Dump trait object type · 7ed4a0eb
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      7ed4a0eb
    • Jakub Dupak's avatar
      gccrs: ast: Dump impl trait type · 638f65b2
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      638f65b2
    • Jakub Dupak's avatar
      gccrs: ast: Dump impl trait type one bound · ca06115e
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      ca06115e
    • Jakub Dupak's avatar
      gccrs: ast: Dump bare function type · ae1f6b3a
      Jakub Dupak authored
      
      + Return FunctionQualifiers as ref to work in ast dump
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
      	* ast/rust-ast-dump.h: Add missing getter declaration.
      	* ast/rust-ast-full-test.cc (BareFunctionType::as_string): Fix bare function
      	string representation.
      	* ast/rust-type.h (class BareFunctionType): Declare said getter.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      ae1f6b3a
    • Jakub Dupak's avatar
      gccrs: ast: Dump inferred type · ee0166fa
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      ee0166fa
    • Jakub Dupak's avatar
      gccrs: ast: Dump tuple type · 91409d27
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing tuple type visitor.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      91409d27
    • Jakub Dupak's avatar
      gccrs: ast: Dump never type · c4c859bf
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing never type visitor.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      c4c859bf
    • Jakub Dupak's avatar
      gccrs: ast: Dump raw pointer type · 971d16cb
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing RawPointer visitor.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      971d16cb
    • Jakub Dupak's avatar
      gccrs: ast: Dump array type · 140a2aed
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing array visitor
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      140a2aed
    • Jakub Dupak's avatar
      gccrs: ast: Dump slice type · 59fb0747
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing slice visitor.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      59fb0747
    • Jakub Dupak's avatar
      gccrs: ast: Dump where clause and recursively needed nodes · bd2240d3
      Jakub Dupak authored
      
      This is currently needed for lifetimes to use the existing infrastructure.
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add missing visitors.
      	* ast/rust-ast-dump.h: Likewise.
      	* ast/rust-ast.h: Add `get_lifetime_bounds` method.
      	* ast/rust-item.h: Add missing getter for lifetimes.
      	* ast/rust-type.h: Likewise.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      bd2240d3
    • Jakub Dupak's avatar
      gccrs: ast: add visit overload for references · 907d1119
      Jakub Dupak authored
      
      This is currently needed for lifetimes to use the existing infrastructure.
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add new reference visitor wrapper.
      	* ast/rust-ast-dump.h: Declare it.
      	* ast/rust-item.h: Add mutable visibility getters.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      907d1119
    • Arthur Cohen's avatar
      gccrs: typecheck: Fix overzealous `delete` call · 85f69a9b
      Arthur Cohen authored
      gcc/rust/ChangeLog:
      
      	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Fix extra call
      	to `delete`.
      85f69a9b
    • Dave's avatar
      gccrs: add Location to AST::Visibility · b8422289
      Dave authored
      gcc/rust/ChangeLog:
      
      	* ast/rust-item.h: Add location member.
      	* hir/rust-ast-lower.cc (translate_visibility): Pass location argument.
      	* hir/tree/rust-hir-item.h: Fix constructor to accept Location argument.
      b8422289
    • Raiki Tamura's avatar
      gccrs: add lang item "phantom_data" · 2fc01303
      Raiki Tamura authored
      gcc/rust/ChangeLog:
      
      	* util/rust-lang-item.h: Add handling for `phantom_data` lang item.
      
      gcc/testsuite/ChangeLog:
      
      	* rust/compile/torture/phantom_data.rs: New test.
      2fc01303
    • Jakub Dupak's avatar
      gccrs: ast: Dump unit struct · 04a16c58
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::visit): Add handling for unit structures.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      04a16c58
    • Jakub Dupak's avatar
      gccrs: ast: refer correctly to arguments in docs-strings · a56faba9
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.h: Fix documentation.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      a56faba9
    • Jakub Dupak's avatar
      gccrs: ast: transform helper methods to visits and add methods to simplify repeated patterns · 3b5fb3f8
      Jakub Dupak authored
      
      gcc/rust/ChangeLog:
      
      	* ast/rust-ast-dump.cc (Dump::go): Use new API.
      	(Dump::format_function_param): Refactor.
      	(Dump::visit_items_joined_by_separator): New function.
      	(Dump::emit_attrib): Refactor.
      	(Dump::visit_as_line): New function.
      	(Dump::visit_items_as_lines): Likewise.
      	(Dump::visit_items_as_block): Likewise.
      	(Dump::visit): Use new API.
      	(Dump::emit_visibility): Likewise.
      	(Dump::emit_indented_string): Likewise.
      	(Dump::emit_generic_params): Likewise.
      	(Dump::format_tuple_field): Likewise.
      	(Dump::format_struct_field): Likewise.
      	(Dump::format_function_common): Likewise.
      	(Dump::visit_function_common): Likewise.
      	* ast/rust-ast-dump.h: Declare new functions and add documentation.
      
      Signed-off-by: default avatarJakub Dupak <dev@jakubdupak.com>
      3b5fb3f8
Loading