aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2023-04-06gccrs: Refactor TyVar and TypeBoundPredicatesPhilip Herron6-178/+276
This extract these helpers into seperate files Signed-off-by: Philip Herron <herron.philip@googlemail.com> gcc/rust/ChangeLog: * Make-lang.in: update makefile * typecheck/rust-tyty.cc (TyVar::TyVar): move to new file (TyVar::get_tyty): likewise (TyVar::get_implicit_infer_var): likewise (TyVar::subst_covariant_var): likewise (TyVar::clone): likewise (TyVar::monomorphized_clone): likewise (TyWithLocation::TyWithLocation): likewise * typecheck/rust-tyty.h (class BaseType): cleanup (class TypeBoundPredicate): move to its own file (class TypeBoundPredicateItem): likewise (class TypeBoundsMappings): likewise (class TyVar): likewise (class TyWithLocation): likewise * typecheck/rust-tyty-bounds.h: New file. * typecheck/rust-tyty-util.cc: New file. * typecheck/rust-tyty-util.h: New file.
2023-04-06gccrs: Move TypePredicateItem impl out of the headerPhilip Herron2-12/+28
This moves the implementation code out of the header and into its respective cc file. Signed-off-by: Philip Herron <herron.philip@googlemail.com> gcc/rust/ChangeLog: * typecheck/rust-tyty-bounds.cc (TypeBoundPredicateItem::error): refactor (TypeBoundPredicateItem::is_error): likewise (TypeBoundPredicateItem::get_parent): likewise * typecheck/rust-tyty.h: Move the implementation for the above
2023-04-06gccrs: Add another test case for passing associated type-boundsPhilip Herron1-0/+30
This demonstrates that this also works for custom algebraic data types too. gcc/testsuite/ChangeLog: * rust/execute/torture/issue-1720-2.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2023-04-06gccrs: Removed comment copy-pasted from gcc/tree.defOwen Avery1-24/+0
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Removed copy-pasted comment. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: Add support for feature check.mxlol2337-0/+406
This commit implements a very basic feature checking module. gcc/rust/ChangeLog: * Make-lang.in: Add object files: `rust-feature.o` and `rust-feature-gate.o` * checks/errors/rust-feature-gate.cc: New file. * checks/errors/rust-feature-gate.h: New file. * checks/errors/rust-feature.cc: New file. * checks/errors/rust-feature.h: New file. * rust-session-manager.cc: Add FeatureGate check. gcc/testsuite/ChangeLog: * rust/compile/feature.rs: New test. Signed-off-by: Xiao Ma <mxlol233@outlook.com>
2023-04-06gccrs: parser: Fix parsing of closure param listArthur Cohen2-0/+11
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_closure_expr): Advance tokens properly when parsing closure param list. gcc/testsuite/ChangeLog: * rust/compile/closure_move_expr.rs: New test.
2023-04-06gccrs: parser: Improve parsing of complex generic argumentsArthur Cohen3-1/+30
The parser was missing code for handling complex type arguments such as type paths or nested generics. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_generic_arg): Handle type paths and nested generics properly. gcc/testsuite/ChangeLog: * rust/compile/parse_complex_generic_application.rs: New test. * rust/compile/parse_complex_generic_application2.rs: New test.
2023-04-06gccrs: Implement lowering ReferencePattern from AST to HIROwen Avery3-0/+34
gcc/rust/ChangeLog: * ast/rust-pattern.h: (ReferencePattern::is_double_reference): Add method. (ReferencePattern::get_is_mut): Add method. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Add ReferencePattern visitor. * hir/rust-ast-lower-pattern.h: (ASTLoweringPattern::visit): Add ReferencePattern visitor. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: Optimize HIR::ReferencePatternOwen Avery2-13/+5
gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h (class ReferencePattern): Remove has_two_amps field. * hir/tree/rust-hir-full-test.cc (ReferencePattern::as_string): Remove usage of ReferencePattern::has_two_amps. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: Remove HIR::GroupedPatternOwen Avery17-132/+0
gcc/rust/ChangeLog: * backend/rust-compile-fnparam.h (CompileFnParam::visit): Remove HIR::GroupedPattern visitor. * backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Remove HIR::GroupedPattern visitor. (CompilePatternBindings::visit): Remove HIR::GroupedPattern visitor. * backend/rust-compile-pattern.h (CompilePatternCaseLabelExpr::visit): Remove HIR::GroupedPattern visitor. (CompilePatternBindings::visit): Remove HIR::GroupedPattern visitor. (CompilePatternLet::visit): Remove HIR::GroupedPattern visitor. * backend/rust-compile-resolve-path.h (ResolvePathRef::visit): Remove HIR::GroupedPattern visitor. * backend/rust-compile-var-decl.h (CompileVarDecl::visit): Remove HIR::GroupedPattern visitor. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Remove HIR::GroupedPattern visitor. * checks/errors/rust-const-checker.h (ConstChecker::visit): Remove HIR::GroupedPattern visitor. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Remove HIR::GroupedPattern visitor. * checks/errors/rust-unsafe-checker.h (UnsafeChecker::visit): Remove HIR::GroupedPattern visitor. * hir/rust-hir-dump.cc (Dump::visit): Remove HIR::GroupedPattern visitor. * hir/rust-hir-dump.h (Dump::visit): Remove HIR::GroupedPattern visitor. * hir/tree/rust-hir-full-decls.h (class GroupedPattern): Remove class. * hir/tree/rust-hir-full-test.cc (GroupedPattern::accept_vis): Remove method. * hir/tree/rust-hir-pattern.h (class GroupedPattern): Remove class. * hir/tree/rust-hir-visitor.h (HIRFullVisitor::visit): Remove HIR::GroupedPattern visitor. (HIRFullVisitorBase::visit): Remove HIR::GroupedPattern visitor. (HIRPatternVisitor::visit): Remove HIR::GroupedPattern visitor. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Remove HIR::GroupedPattern visitor. * typecheck/rust-hir-type-check-pattern.h (TypeCheckPattern::visit): Remove HIR::GroupedPattern visitor. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: Improve GroupedPattern loweringOwen Avery1-11/+1
gcc/rust/ChangeLog: * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Lower AST::GroupedPattern to its inner pattern. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: Move rust-buffered-queue.h to util folder #1766MAHAD1-0/+0
gcc/rust/ChangeLog: * rust-buffered-queue.h: Moved to... * util/rust-buffered-queue.h: ...here. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
2023-04-06gccrs: parser: Allow parsing multiple reference typesArthur Cohen3-6/+41
The parser now recursively tries to parse a reference type after seeing a `&` or `&&` token. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_type): Handle double ampersan properly (Parser::parse_reference_type): Call into `parse_reference_type_inner` and wrap double reference types in another `AST::ReferenceType` node (Parser::parse_reference_type_inner): Add parsing implementation which does not care about the leading token (& or &&) (Parser::parse_type_no_bounds): Handle double ampersand properly * parse/rust-parse.h: Declare `parse_reference_type_inner` gcc/testsuite/ChangeLog: * rust/compile/multi_reference_type.rs: New test.
2023-04-06gccrs: Create and use CompilePatternLet visitor for compiling let statmentsOwen Avery3-28/+148
gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc (CompilePatternLet::visit): New function. * backend/rust-compile-stmt.cc (CompileStmt::visit): Likewise. * backend/rust-compile-pattern.h (class CompilePatternLet): New visitor. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: macro: Allow builtin `MacroInvocation`s within the ASTArthur Cohen3-56/+126
gcc/rust/ChangeLog: * ast/rust-macro.h (enum class): Add `BuiltinMacro` enum class. * expand/rust-attribute-visitor.cc (AttrVisitor::visit): Mention switching on `macro.kind` once builtin macro invocations are properly handled. * parse/rust-parse-impl.h (Parser::parse_macro_invocation): Switch to new MacroInvocation API. (Parser::parse_type): Likewise. (Parser::parse_type_no_bounds): Likewise.
2023-04-06gccrs: fixed indentations in AST pretty expanded dump of traitAbdul Rafey1-6/+1
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): removed extra indentations in trait ast dump Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
2023-04-06gccrs: fixed compiler error message on wildcard pattern within expressionAbdul Rafey2-0/+14
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::null_denotation): Add proper error when seeing wildcard var on right side of assignment. gcc/testsuite/ChangeLog: * rust/compile/issue-867.rs: New test. Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
2023-04-06gccrs: moved operator.h to util/rust-operators.hAbdul Rafey6-5/+5
gcc/rust/ChangeLog: * ast/rust-ast.cc: Fix include list. * ast/rust-expr.h: Likewise. * hir/tree/rust-hir-expr.h: Likewise. * rust-backend.h: Likewise. * util/rust-lang-item.h: Likewise. * operator.h: Moved to... * util/rust-operators.h: ...here. Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
2023-04-06gccrs: Rename file rust-ast-full-test.cc to rust-ast.ccParthib2-1/+1
gcc/rust/ChangeLog: * Make-lang.in: Rename object file. * ast/rust-ast-full-test.cc: Moved to... * ast/rust-ast.cc: ...here.
2023-04-06gccrs: Added missing GroupedPattern visitors for code generationOwen Avery2-2/+14
gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Add proper visitor. (CompilePatternBindings::visit): Likewise. * backend/rust-compile-pattern.h: Declare them. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: Add type resolution for grouped patternsOwen Avery1-3/+5
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Add proper visitor. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: Add get_item method for HIR::GroupedPatternOwen Avery1-0/+6
gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h: Add get_item method. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: Add HIR lowering for GroupedPatternOwen Avery2-0/+17
gcc/rust/ChangeLog: * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Add proper visitor. * hir/rust-ast-lower-pattern.h: Declare it. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: Do not crash on empty macros expand. Fixes #1712Lyra2-0/+9
This commit fixes a compiler crash when expanding an empty macro into an existing AST. gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (transcribe_expression): Fix ICE when expanding empty macros. gcc/testsuite/ChangeLog: * rust/compile/macro45.rs: New test. Signed-off-by: Lyra Karenai <teromene@teromene.fr>
2023-04-06gccrs: Support GroupedPattern during name resolutionOwen Avery1-0/+5
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-pattern.h: Support GroupedPattern properly. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: testsuite: Handle Windows carriage returns properlyArthur Cohen87-109/+104
In dg-output, check for \r* carriage returns to make sure execution tests pass on windows platforms gcc/testsuite/ChangeLog: * rust/execute/torture/builtin_macro_cfg.rs: Handle carriage returns properly. * rust/execute/torture/builtin_macro_concat.rs: Likewise. * rust/execute/torture/builtin_macro_env.rs: Likewise. * rust/execute/torture/builtin_macro_include_bytes.rs: Likewise. * rust/execute/torture/builtin_macro_include_str.rs: Likewise. * rust/execute/torture/builtin_macro_line.rs: Likewise. * rust/execute/torture/builtin_macros1.rs: Likewise. * rust/execute/torture/builtin_macros3.rs: Likewise. * rust/execute/torture/cfg1.rs: Likewise. * rust/execute/torture/cfg2.rs: Likewise. * rust/execute/torture/cfg3.rs: Likewise. * rust/execute/torture/cfg4.rs: Likewise. * rust/execute/torture/coercion1.rs: Likewise. * rust/execute/torture/coercion2.rs: Likewise. * rust/execute/torture/extern_mod4.rs: Likewise. * rust/execute/torture/helloworld1.rs: Likewise. * rust/execute/torture/helloworld2.rs: Likewise. * rust/execute/torture/issue-1198.rs: Likewise. * rust/execute/torture/issue-1231.rs: Likewise. * rust/execute/torture/issue-1232.rs: Likewise. * rust/execute/torture/issue-1249.rs: Likewise. * rust/execute/torture/issue-1436.rs: Likewise. * rust/execute/torture/issue-1496.rs: Likewise. * rust/execute/torture/issue-647.rs: Likewise. * rust/execute/torture/issue-845.rs: Likewise. * rust/execute/torture/issue-851.rs: Likewise. * rust/execute/torture/issue-858.rs: Likewise. * rust/execute/torture/issue-976.rs: Likewise. * rust/execute/torture/macros10.rs: Likewise. * rust/execute/torture/macros11.rs: Likewise. * rust/execute/torture/macros12.rs: Likewise. * rust/execute/torture/macros13.rs: Likewise. * rust/execute/torture/macros14.rs: Likewise. * rust/execute/torture/macros2.rs: Likewise. * rust/execute/torture/macros22.rs: Likewise. * rust/execute/torture/macros29.rs: Likewise. * rust/execute/torture/macros3.rs: Likewise. * rust/execute/torture/macros30.rs: Likewise. * rust/execute/torture/macros31.rs: Likewise. * rust/execute/torture/macros7.rs: Likewise. * rust/execute/torture/macros8.rs: Likewise. * rust/execute/torture/macros9.rs: Likewise. * rust/execute/torture/match1.rs: Likewise. * rust/execute/torture/match2.rs: Likewise. * rust/execute/torture/match3.rs: Likewise. * rust/execute/torture/match_bool1.rs: Likewise. * rust/execute/torture/match_byte1.rs: Likewise. * rust/execute/torture/match_char1.rs: Likewise. * rust/execute/torture/match_int1.rs: Likewise. * rust/execute/torture/match_loop1.rs: Likewise. * rust/execute/torture/match_range1.rs: Likewise. * rust/execute/torture/match_range2.rs: Likewise. * rust/execute/torture/match_tuple1.rs: Likewise. * rust/execute/torture/method1.rs: Likewise. * rust/execute/torture/method2.rs: Likewise. * rust/execute/torture/method3.rs: Likewise. * rust/execute/torture/method4.rs: Likewise. * rust/execute/torture/operator_overload_1.rs: Likewise. * rust/execute/torture/operator_overload_10.rs: Likewise. * rust/execute/torture/operator_overload_11.rs: Likewise. * rust/execute/torture/operator_overload_12.rs: Likewise. * rust/execute/torture/operator_overload_2.rs: Likewise. * rust/execute/torture/operator_overload_4.rs: Likewise. * rust/execute/torture/operator_overload_5.rs: Likewise. * rust/execute/torture/operator_overload_6.rs: Likewise. * rust/execute/torture/operator_overload_7.rs: Likewise. * rust/execute/torture/operator_overload_8.rs: Likewise. * rust/execute/torture/operator_overload_9.rs: Likewise. * rust/execute/torture/str-layout1.rs: Likewise. * rust/execute/torture/str-zero.rs: Likewise. * rust/execute/torture/trait1.rs: Likewise. * rust/execute/torture/trait10.rs: Likewise. * rust/execute/torture/trait11.rs: Likewise. * rust/execute/torture/trait12.rs: Likewise. * rust/execute/torture/trait13.rs: Likewise. * rust/execute/torture/trait2.rs: Likewise. * rust/execute/torture/trait3.rs: Likewise. * rust/execute/torture/trait4.rs: Likewise. * rust/execute/torture/trait5.rs: Likewise. * rust/execute/torture/trait6.rs: Likewise. * rust/execute/torture/trait7.rs: Likewise. * rust/execute/torture/trait8.rs: Likewise. * rust/execute/torture/trait9.rs: Likewise. * rust/execute/torture/closure2.rs: Likewise. * rust/execute/torture/closure3.rs: Likewise. * rust/execute/torture/loop-condition-eval.rs: Likewise. * rust/execute/torture/operator_overload_3.rs: Likewise.
2023-04-06gccrs: Change how CompileVarDecl outputs Bvariable'sOwen Avery2-14/+16
This allows patterns to declare multiple/no variables gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::compile_locals_for_block): Allow patterns to declare zero or multiple variables. * backend/rust-compile-var-decl.h: Change function declaration. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: diagnostics: Add underline for tokens in diagnostics.mxlol2332-0/+72
Currently, the diagnostics only point to the corresponding token's start position by carets, and lack of underlines for full token. This commit add support for such underlines in diagnostics by encoding range information in location_t. gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::build_token): Make location enclose entire token. (Lexer::parse_byte_char): Likewise. (Lexer::parse_byte_string): Likewise. (Lexer::parse_raw_byte_string): Likewise. (Lexer::parse_raw_identifier): Likewise. (Lexer::parse_string): Likewise. (Lexer::parse_identifier_or_keyword): Likewise. (Lexer::parse_raw_string): Likewise. (Lexer::parse_non_decimal_int_literal): Likewise. (Lexer::parse_decimal_int_or_float): Likewise. (Lexer::parse_char_or_lifetime): Likewise. gcc/testsuite/ChangeLog: * rust/compile/diagnostic_underline.rs: New test. Signed-off-by: Xiao Ma <mxlol233@outlook.com>
2023-04-06gccrs: Add get_locus function for abstract class MetaItemInner.mxlol2333-0/+22
This commit adds virtual function get_locus to base class MetaItemInner, which is helpful when we need to print diagnostics on some sub-classes of MetaItemInner. gcc/rust/ChangeLog: * ast/rust-ast.h: Add get_locus method. * ast/rust-expr.h: Likewise. * ast/rust-macro.h: Likewise. Signed-off-by: Xiao Ma <mxlol233@outlook.com>
2023-04-06gccrs: Reuse TypeCheckPattern on LetStmt'sOwen Avery1-8/+6
Update Rust type-checking to reuse TypeCheckPattern on HIR::LetStmt's. This will unify the paths and improve error handling. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Cleanup LetStmt type checking. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: Support associated type bound argumentsPhilip Herron9-38/+236
This patch adds support for the GenercArgsBinding type, where you can specify the associated types of a trait bound using `<Foo=i32>` style syntax. Note that the type-resolution relys on the i32 impl for Add as type resolution will resolve the `a+a` to the core::ops::Add method so code generation will require this to exist. I have ameded testsuite/rust/compile/bounds.rs as this code is wrongly creating an HIR::GenericArgs with a trait-object type and causing issues. the parsing is still correct but we dont have the mechanism to represent this in AST and HIR properly. I think we will need a new HIR::GenericArgs AssociatedTypeBindingBound or something similar. We are still lacking bounds checking during are type coercions and unifications so running this example using an f32 will wrongly pass type checking, this will need addressed next. Fixes #1720 gcc/rust/ChangeLog: * hir/tree/rust-hir-path.h: Add const get_identifier and get_type method. * typecheck/rust-hir-path-probe.h: Use new SubstitutionArgumentMappings constructor. * typecheck/rust-hir-trait-resolve.cc: Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound): Do not assert failure on size mismatch anymore. (TypeBoundPredicate::TypeBoundPredicate): Use new SubstitutionArgumentMappings constructor. (TypeBoundPredicate::operator=): Likewise. (TypeBoundPredicate::apply_generic_arguments): Likewise. (TypeBoundPredicateItem::get_tyty_for_receiver): Likewise. (TypeBoundPredicate::get_num_associated_bindings): Likewise. (TypeBoundPredicate::lookup_associated_type): Fix implementation for new system. (TypeBoundPredicate::get_associated_type_items): Likewise. * typecheck/rust-tyty.cc (SubstitutionRef::get_mappings_from_generic_args): Add new behavior. (SubstitutionRef::infer_substitions): Use new constructor and add comment. (SubstitutionRef::solve_missing_mappings_from_this): Use new constructor. * typecheck/rust-tyty.h: Define new constructors. gcc/testsuite/ChangeLog: * rust/compile/bounds.rs: change to use -fsyntax-only * rust/execute/torture/issue-1720.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2023-04-06gccrs: Add name resolution to generic argument associated item bindingsPhilip Herron1-0/+5
When specifying generic arguments to Traits we can also specify the associated types using `<BindingName=i32>` syntax we need to add name resolution to the type argument here and rely on the type resolution pass to ensure the associated type exists and to setup the associated types accordingly. Addresses #1720 gcc/rust/ChangeLog: * resolve/rust-ast-resolve-type.cc (ResolveGenericArgs::go): Add name resolution to Trait items. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2023-04-06gccrs: Implement declarative macro 2.0 parserRaiki Tamura19-80/+301
gcc/rust/ChangeLog: * ast/rust-ast-full-decls.h (class MacroItem): Remove forward declaration. * ast/rust-ast-full-test.cc (MacroRulesDefinition): Rework MacroRulesDefinition class * ast/rust-ast.h (class MacroItem): Remove abstract class. * ast/rust-item.h (class MacroItem): Remove forward declaration. * ast/rust-macro.h (class MacroItem): Likewise. (class MacroRulesDefinition): Add MacroKind enum. (class MacroInvocation): Fix inheritance. * lex/rust-token.h: Token "macro" is now used. * parse/rust-parse-impl.h (Parser::parse_item): Add handling for MACRO. (Parser::parse_vis_item): Call into parse_decl_macro_def. (Parser::parse_macro_item): Delete function. (Parser::parse_macro_rules_def): Return MBE macros only. (Parser::parse_decl_macro_def): New function. (Parser::parse_stmt): Handle MACRO token. (Parser::parse_stmt_or_expr_without_block): Call into parse_macro_rules_def. * parse/rust-parse.h: Declare new function. gcc/testsuite/ChangeLog: * rust/compile/decl_macro1.rs: New test. * rust/compile/decl_macro2.rs: New test. * rust/compile/decl_macro3.rs: New test. * rust/compile/decl_macro4.rs: New test. * rust/compile/decl_macro5.rs: New test. * rust/compile/decl_macro6.rs: New test. * rust/compile/decl_macro7.rs: New test. * rust/execute/torture/decl_macro1.rs: New test. * rust/execute/torture/decl_macro2.rs: New test. * rust/execute/torture/decl_macro3.rs: New test. * rust/execute/torture/decl_macro4.rs: New test. Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2023-04-06gccrs: rust: add bound parsing in parse_generic_arg.mxlol2332-0/+27
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_generic_arg): Add proper bound parsing. gcc/testsuite/ChangeLog: * rust/compile/bounds.rs: New test. Signed-off-by: Xiao Ma <mxlol233@outlook.com>
2023-04-06gccrs: Check for mutable references in const functionsDave2-2/+9
Use StackedContext instead. Fix error string Signed-off-by: Dave Evans <dave@dmetwo.org> (Squashed commits) Check for mutable references in const functions using StackedContext gcc/rust/ChangeLog: * checks/errors/rust-const-checker.cc (ConstChecker::visit): Use StackedContext class. gcc/testsuite/ChangeLog: * rust/compile/const10.rs: New test. Signed-off-by: Dave Evans <dave@dmetwo.org>
2023-04-06gccrs: unsafe: check use of `target_feature` attributePrajwal S N4-1/+44
The `target_feature` attribute is for conditional compilation and may or may not compile on all platforms. Using it requires an unsafe function or block. gcc/rust/ChangeLog: * checks/errors/rust-unsafe-checker.cc (check_target_attr): New function. (UnsafeChecker::check_function_attr): Call into `check_target_attr`. (UnsafeChecker::visit): Check for target_feature attributes. * checks/errors/rust-unsafe-checker.h: Add declarations. * util/rust-attributes.cc: Add attribute. gcc/testsuite/ChangeLog: * rust/compile/unsafe11.rs: New test. Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
2023-04-06gccrs: fatal_error_flag: Fix typo in error messageArthur Cohen1-1/+1
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Fix typo.
2023-04-06[testsuite] enable -maltivec like vect_int for signbit-2.cAlexandre Oliva1-0/+1
Explicitly enable altivec if it's supported. vect_int tests for powerpc_altivec_ok, but without the explicit option, if altivec is not enabled by default, we end up expecting vectorization that doesn't occur. for gcc/testsuite/ChangeLog * gcc.dg/signbit-2.c: Add -maltivec if supported.
2023-04-05Fix typo in -param=vect-induction-float= attributesAndrew Pinski1-1/+1
There was a typo in the attributes of the option -param=vect-induction-float= for IntegerRange. This fixes that typo. Committed as obvious after a build/test. gcc/ChangeLog: PR tree-optimization/109427 * params.opt (-param=vect-induction-float=): Fix option attribute typo for IntegerRange.
2023-04-05testsuite: fix proc unsupported overriding in modules.exp [PR108899]Alexandre Oliva1-9/+11
The overrider of proc unsupported in modules.exp had two problems reported by Thomas Schwinge, even after Jakub Jelínek's fix: - it remained in effect while running other dejagnu testsets - it didn't quote correctly the argument list passed to it, which caused test names to be surrounded by curly braces, as in: UNSUPPORTED: {...} This patch fixes both issues, obsoleting and reverting Jakub's change, by dropping the overrider and renaming the saved proc back, and by using uplevel's argument list splicing. Co-authored-by: Thomas Schwinge <thomas@codesourcery.com> for gcc/testsuite/ChangeLog PR testsuite/108899 * g++.dg/modules/modules.exp (unsupported): Drop renaming. Fix quoting.
2023-04-06Daily bump.GCC Administrator4-1/+85
2023-04-05PR modula2/109423 cc1gm2 ICE if an INCL or EXCL is performed on an unknown setGaius Mulley16-32/+27
This patch fixes an ICE if attempting to INCL or EXCL on an unknown set. The fix was to correct an error format string. Also included in the patch are patches to remove unused variables. The patch also marks a variable as written in BuildAdr. gcc/m2/ChangeLog: PR modula2/109423 * gm2-compiler/M2Base.def (Unbounded): Remove. * gm2-compiler/M2Error.def (ErrorAbort0): Add noreturn attribute. * gm2-compiler/M2Quads.mod (BuildInclProcedure): Correct error format string. (BuildExceptProcedure): Correct error format string. (BuildAdrFunction): Call PutWriteQuad when taking the address of a variable. * gm2-libs-ch/SysExceptions.c (_M2_SysExceptions_init): Add parameters. * gm2-libs-ch/wrapc.c (_M2_wrapc_init): Add parameters. * gm2-libs/DynamicStrings.mod (DumpStringInfo): Remove t. (PopAllocationExemption): Remove f. * gm2-libs/FIO.mod (BufferedWrite): Remove result. * gm2-libs/FormatStrings.mod (Copy): Remove endpos and afterperc. (HandlePercent): Remove result. * gm2-libs/Indexing.mod (RemoveIndiceFromIndex): Remove k. * gm2-libs/M2Dependent.mod (CreateModule): Remove p0 and p1. (DumpModuleData): Remove mptr. (ConstructModules): Remove nulp. * gm2-libs/RTExceptions.mod (PopHandler): Remove i. * gm2-libs/RTint.mod (Listen): Remove b4s, b4m, afs and afm. * gm2-libs/SFIO.mod (ReadS): Remove c. * gm2-libs/StringConvert.mod (doDecimalPlaces): Remove whole and fraction. gcc/testsuite/ChangeLog: * gm2/pim/fail/setunknown.mod: New test. PR modula2/109423 * gm2/pim/fail/setunknown2.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-04-05[RFA][Bug target/108892 ][13 regression] Force re-recognition after changing ↵Jeff Law2-0/+24
RTL structure of an insn So as mentioned in the PR the underlying issue here is combine changes the form of an existing insn, but fails to force re-recognition. As a result other parts of the compiler blow up. > /* Temporarily replace the set's source with the > contents of the REG_EQUAL note. The insn will > be deleted or recognized by try_combine. */ > rtx orig_src = SET_SRC (set); rtx orig_dest = SET_DEST (set); if (GET_CODE (SET_DEST (set)) == ZERO_EXTRACT) > SET_DEST (set) = XEXP (SET_DEST (set), 0); > SET_SRC (set) = note; > i2mod = temp; > i2mod_old_rhs = copy_rtx (orig_src); > i2mod_new_rhs = copy_rtx (note); > next = try_combine (insn, i2mod, NULL, NULL, > &new_direct_jump_p, last_combined_insn); > i2mod = NULL; > if (next) > { > statistics_counter_event (cfun, "insn-with-note combine", 1); > goto retry; > } SET_SRC (set) = orig_src; > SET_DEST (set) = orig_dest; This code replaces the SET_SRC of an insn in the RTL stream with the contents of a REG_EQUAL note. So given an insn like this: > (insn 122 117 127 2 (set (reg:DI 157 [ _46 ]) > (ior:DI (reg:DI 200) > (reg:DI 251))) "j.c":14:5 -1 > (expr_list:REG_EQUAL (const_int 25769803782 [0x600000006]) > (nil))) It replaces the (ior ...) with a (const_int ...). The resulting insn is passed to try_combine which will try to recognize it, then use it in a combination attempt. Recognition succeeds with the special define_insn_and_split pattern in the risc-v backend resulting in: > (insn 122 117 127 2 (set (reg:DI 157 [ _46 ]) > (const_int 25769803782 [0x600000006])) "j.c":14:5 177 {*mvconst_internal} > (expr_list:REG_EQUAL (const_int 25769803782 [0x600000006]) > (nil))) This is as-expected. Now assume we were unable to combine anything, so try_combine returns NULL_RTX. The quoted code above restores SET_SRC (and SET_DEST) resulting in: > (insn 122 117 127 2 (set (reg:DI 157 [ _46 ]) > (ior:DI (reg:DI 200) > (reg:DI 251))) "j.c":14:5 177 {*mvconst_internal} > (expr_list:REG_EQUAL (const_int 25769803782 [0x600000006]) > (nil))) But this doesn't get re-recognized and we ICE later in LRA. The fix is trivial, reset the INSN_CODE to force re-recognition in the case where try_combine fails. PR target/108892 gcc/ * combine.cc (combine_instructions): Force re-recognition when after restoring the body of an insn to its original form. gcc/testsuite/ * gcc.c-torture/compile/pr108892.c: New test.
2023-04-05ipa: Avoid another ICE when dealing with type-incompatibilities (PR 108959)Martin Jambor2-0/+88
PR 108959 shows one more example where undefined code with type incompatible accesses to stuff passed in parameters can cause an ICE because we try to create a VIEW_CONVERT_EXPR of mismatching sizes: 1. IPA-CP tries to push one type from above, 2. IPA-SRA (correctly) decides the parameter is useless because it is only used to construct an argument to another function which does not use it and so the formal parameter should be removed, 3. but the code reconciling IPA-CP and IPA-SRA transformations still wants to perform the IPA-CP and overrides the built-in DCE of useless statements and tries to stuff constants into them instead, constants of a type with mismatching type and size. This patch avoids the situation in IPA-SRA by purging the IPA-CP results from any "aggregate" constants that are passed in parameters which are detected to be useless. It also removes IPA value range and bits information associated with removed parameters stored in the same structure so that the useless information is not streamed later on. gcc/ChangeLog: 2023-03-22 Martin Jambor <mjambor@suse.cz> PR ipa/108959 * ipa-sra.cc (zap_useless_ipcp_results): New function. (process_isra_node_results): Call it. gcc/testsuite/ChangeLog: 2023-03-17 Martin Jambor <mjambor@suse.cz> PR ipa/108959 * gcc.dg/ipa/pr108959.c: New test.
2023-04-05[PATCH] RISC-V: Fix SEW64 of vrsub.vx runtime fail in RV32 systemJu-Zhe Zhong2-1/+436
It's quite obvious that the order of vrsub SEW64 is wrong. gcc/ChangeLog: * config/riscv/vector.md: Fix incorrect operand order. gcc/testsuite/ChangeLog: * g++.target/riscv/rvv/base/bug-23.C: New test.
2023-04-04[PATCH] RISC-V: Fix PR109399 VSETVL PASS bugJuzhe-Zhong2-1/+21
PR 109399 gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (pass_vsetvl::compute_local_backward_infos): Update user vsetvl in local demand fusion. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/vsetvl/pr109399.c: New test.
2023-04-04RISC-V: Fix typosLi Xu3-6/+5
gcc/ChangeLog: * config/riscv/riscv-vector-builtins.def: Fix typo. * config/riscv/riscv.cc (riscv_dwarf_poly_indeterminate_value): Ditto. * config/riscv/vector-iterators.md: Ditto.
2023-04-05Daily bump.GCC Administrator6-1/+147
2023-04-05doc: md.texi (Including Patterns): Fix page breakHans-Peter Nilsson1-2/+1
The line-break in the example looked odd, even more so with a page-break in the middle of it, due to recently added text in preceding pages. * doc/md.texi (Including Patterns): Fix page break.
2023-04-04Regenerate gcc.potJoseph Myers1-7630/+7764
* gcc.pot: Regenerate.