[COMMITTED 13/32] gccrs: nr2.0: Remove duplicate self visit
From: Owen Avery gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Remove explicit visitation of a function's self parameter, as if it exists it'll be visited as one of the function parameters. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entry. Signed-off-by: Owen Avery --- gcc/rust/ast/rust-ast-visitor.cc | 2 -- gcc/testsuite/rust/compile/nr2/exclude | 1 - 2 files changed, 3 deletions(-) diff --git a/gcc/rust/ast/rust-ast-visitor.cc b/gcc/rust/ast/rust-ast-visitor.cc index ba5f87bc2eb..9a8c24f17d8 100644 --- a/gcc/rust/ast/rust-ast-visitor.cc +++ b/gcc/rust/ast/rust-ast-visitor.cc @@ -824,8 +824,6 @@ DefaultASTVisitor::visit (AST::Function &function) visit (function.get_qualifiers ()); for (auto &generic : function.get_generic_params ()) visit (generic); - if (function.has_self_param ()) -visit (function.get_self_param ()); for (auto ¶m : function.get_function_params ()) visit (param); if (function.has_return_type ()) diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index adc199e59e3..76ef39f982d 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -1,7 +1,6 @@ canonical_paths1.rs cfg1.rs generics9.rs -issue-2043.rs issue-2812.rs issue-3315-2.rs lookup_err1.rs -- 2.49.0
[COMMITTED 20/32] gccrs: Make loop label truly optional
From: Pierre-Emmanuel Patry A loop label error state was in use to represent missing loop label but this may be easily forgotten and the optional nature of the label was misrepresented. gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::block): Call with a nullopt instead of an error loop label. (WhileLetLoopExpr::as_string): Use getter function and adapt to newtype. * ast/rust-ast.cc (WhileLoopExpr::as_string): Likewise. (LoopExpr::as_string): Likewise. (BreakExpr::as_string): Likewise. (ForLoopExpr::as_string): Likewise. * ast/rust-expr.h (class BlockExpr): Make loop label optional. (class BreakExpr): Likewise. * expand/rust-derive-clone.cc (DeriveClone::clone_fn): Use nullopt. * expand/rust-derive-debug.cc (DeriveDebug::stub_debug_fn): Likewise. * expand/rust-derive-default.cc (DeriveDefault::default_fn): Likewise. * expand/rust-derive-eq.cc: Likewise. * parse/rust-parse-impl.h (Parser::parse_block_expr): Use optional for arguments. (Parser::parse_loop_expr): Likewise. (Parser::parse_while_loop_expr): Likewise. (Parser::parse_while_let_loop_expr): Likewise. (Parser::parse_for_loop_expr): Likewise. (Parser::parse_labelled_loop_expr): Likewise. (Parser::parse_loop_label): Return an optional. * parse/rust-parse.h: Update function prototype and use nullopt for default values. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/ast/rust-ast-builder.cc | 6 +- gcc/rust/ast/rust-ast.cc | 10 ++-- gcc/rust/ast/rust-expr.h | 35 +-- gcc/rust/expand/rust-derive-clone.cc | 3 +- gcc/rust/expand/rust-derive-debug.cc | 3 +- gcc/rust/expand/rust-derive-default.cc | 3 +- gcc/rust/expand/rust-derive-eq.cc | 3 +- gcc/rust/parse/rust-parse-impl.h | 80 +- gcc/rust/parse/rust-parse.h| 12 ++-- 9 files changed, 77 insertions(+), 78 deletions(-) diff --git a/gcc/rust/ast/rust-ast-builder.cc b/gcc/rust/ast/rust-ast-builder.cc index cdc6eec254b..5eea4693361 100644 --- a/gcc/rust/ast/rust-ast-builder.cc +++ b/gcc/rust/ast/rust-ast-builder.cc @@ -335,9 +335,9 @@ std::unique_ptr Builder::block (std::vector> &&stmts, std::unique_ptr &&tail_expr) const { - return std::unique_ptr ( -new BlockExpr (std::move (stmts), std::move (tail_expr), {}, {}, - LoopLabel::error (), loc, loc)); + return std::unique_ptr (new BlockExpr (std::move (stmts), + std::move (tail_expr), {}, + {}, tl::nullopt, loc, loc)); } std::unique_ptr diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc index e4a1b369970..c7e0397fca4 100644 --- a/gcc/rust/ast/rust-ast.cc +++ b/gcc/rust/ast/rust-ast.cc @@ -2095,7 +2095,7 @@ WhileLoopExpr::as_string () const if (!has_loop_label ()) str += "none"; else -str += loop_label.as_string (); +str += get_loop_label ().as_string (); str += "\n Conditional expr: " + condition->as_string (); @@ -2115,7 +2115,7 @@ WhileLetLoopExpr::as_string () const if (!has_loop_label ()) str += "none"; else -str += loop_label.as_string (); +str += get_loop_label ().as_string (); str += "\n Match arm patterns: "; if (match_arm_patterns.empty ()) @@ -2146,7 +2146,7 @@ LoopExpr::as_string () const if (!has_loop_label ()) str += "none"; else -str += loop_label.as_string (); +str += get_loop_label ().as_string (); str += "\n Loop block: " + loop_block->as_string (); @@ -2183,7 +2183,7 @@ BreakExpr::as_string () const std::string str ("break "); if (has_label ()) -str += label.as_string () + " "; +str += get_label ().as_string () + " "; if (has_break_expr ()) str += break_expr->as_string (); @@ -2545,7 +2545,7 @@ ForLoopExpr::as_string () const if (!has_loop_label ()) str += "none"; else -str += loop_label.as_string (); +str += get_loop_label ().as_string (); str += "\n Pattern: " + pattern->as_string (); diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index cff09fe17d7..3ce78c643c7 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -2590,7 +2590,7 @@ class BlockExpr : public ExprWithBlock std::vector inner_attrs; std::vector > statements; std::unique_ptr expr; - LoopLabel label; + tl::optional label; location_t start_locus; location_t end_locus; bool marked_for_strip = false; @@ -2607,8 +2607,9 @@ public: BlockExpr (std::vector > block_statements, std::unique_ptr block_expr, std::vector inner_attribs, -std::vector outer_attribs, LoopLabel label, -location_t start_locus, location_t end_locus) +std::vector outer_attribs, +tl::optional labe
☺ Buildbot (Sourceware): gccrust - build successful (master)
A restored build has been detected on builder gccrust-debian-i386 while building gccrust. Full details are available at: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845 Build state: build successful Revision: a179c05f228cace7bcaba8c550e0550993ff5a46 Worker: debian-i386 Build Reason: (unknown) Blamelist: Pierre-Emmanuel Patry Steps: - 0: worker_preparation ( success ) - 1: git checkout ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/1/logs/stdio - 2: rm -rf gccrs-build ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/2/logs/stdio - 3: configure ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/3/logs/stdio - config.log: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/3/logs/config_log - 4: make ( warnings ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/4/logs/stdio - warnings (100): https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/4/logs/warnings__100_ - 5: make check ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/5/logs/stdio - rust.sum: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/5/logs/rust_sum - rust.log: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/5/logs/rust_log - 6: grep FAIL or unexpected rust.sum ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/6/logs/stdio - 7: prep ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/7/logs/stdio - 8: build bunsen.cpio.gz ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/8/logs/stdio - 9: fetch bunsen.cpio.gz ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/9/logs/stdio - 10: unpack bunsen.cpio.gz ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/10/logs/stdio - 11: pass .bunsen.source.* ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/11/logs/stdio - 12: upload to bunsen ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/12/logs/stdio - 13: clean up ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/13/logs/stdio - 14: rm -rf gccrs-build_1 ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2845/steps/14/logs/stdio
[COMMITTED 25/32] gccrs: Resolve labels within break or continue expressions
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add call to label resolution if there is one label. (Late::resolve_label): Look for labels and emit an error message on failure. * resolve/rust-late-name-resolver-2.0.h: Add function prototypes. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove test. Signed-off-by: Pierre-Emmanuel Patry --- .../resolve/rust-late-name-resolver-2.0.cc| 36 +-- .../resolve/rust-late-name-resolver-2.0.h | 3 ++ gcc/testsuite/rust/compile/nr2/exclude| 1 - 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc index e0006fdea27..3e69d343673 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc @@ -187,6 +187,9 @@ Late::visit (AST::SelfParam ¶m) void Late::visit (AST::BreakExpr &expr) { + if (expr.has_label ()) +resolve_label (expr.get_label ().get_lifetime ()); + if (expr.has_break_expr ()) { auto &break_expr = expr.get_break_expr (); @@ -215,20 +218,33 @@ Late::visit (AST::BreakExpr &expr) void Late::visit (AST::LoopLabel &label) { - // Shall we move this to visit(AST::Lifetime) or do we need to - // keep the context ? - auto lifetime = label.get_lifetime (); + auto &lifetime = label.get_lifetime (); + ctx.labels.insert (Identifier (lifetime.as_string (), lifetime.get_locus ()), +lifetime.get_node_id ()); +} + +void +Late::resolve_label (AST::Lifetime &lifetime) +{ if (auto resolved = ctx.labels.get (lifetime.as_string ())) { - ctx.map_usage (Usage (lifetime.get_node_id ()), -Definition (resolved->get_node_id ())); + if (resolved->get_node_id () != lifetime.get_node_id ()) + ctx.map_usage (Usage (lifetime.get_node_id ()), + Definition (resolved->get_node_id ())); } else -{ - ctx.labels.insert (Identifier (lifetime.as_string (), -lifetime.get_locus ()), -lifetime.get_node_id ()); -} +rust_error_at (lifetime.get_locus (), ErrorCode::E0426, + "use of undeclared label %qs", + lifetime.as_string ().c_str ()); +} + +void +Late::visit (AST::ContinueExpr &expr) +{ + if (expr.has_label ()) +resolve_label (expr.get_label ()); + + DefaultResolver::visit (expr); } void diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.h b/gcc/rust/resolve/rust-late-name-resolver-2.0.h index e40141c9238..5703b152f7e 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.h +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.h @@ -48,6 +48,7 @@ public: void visit (AST::IdentifierExpr &) override; void visit (AST::StructExprFieldIdentifier &) override; void visit (AST::BreakExpr &) override; + void visit (AST::ContinueExpr &) override; void visit (AST::LoopLabel &) override; void visit (AST::PathInExpression &) override; void visit (AST::TypePath &) override; @@ -62,6 +63,8 @@ public: void visit (AST::ClosureExprInnerTyped &) override; private: + void resolve_label (AST::Lifetime &lifetime); + /* Setup Rust's builtin types (u8, i32, !...) in the resolver */ void setup_builtin_types (); diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index c688026a7b8..665e0cf4d99 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -12,7 +12,6 @@ privacy8.rs pub_restricted_1.rs pub_restricted_2.rs pub_restricted_3.rs -undeclared_label.rs use_1.rs issue-2905-2.rs derive_clone_enum3.rs -- 2.49.0
[COMMITTED 01/32] gccrs: Evaluate the enum's discriminant in a const context
From: Ryutaro Okada <1015ry...@gmail.com> gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc: Evaluate the enum's discriminant in a const context gcc/testsuite/ChangeLog: * rust/compile/enum_discriminant1.rs: New test. Signed-off-by: Ryutaro Okada <1015ry...@gmail.com> --- gcc/rust/backend/rust-compile-resolve-path.cc| 2 ++ gcc/testsuite/rust/compile/enum_discriminant1.rs | 7 +++ 2 files changed, 9 insertions(+) create mode 100644 gcc/testsuite/rust/compile/enum_discriminant1.rs diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index 115dd046465..3cb1eb6faa5 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -105,7 +105,9 @@ ResolvePathRef::attempt_constructor_expression_lookup ( // make the ctor for the union HIR::Expr &discrim_expr = variant->get_discriminant (); + ctx->push_const_context (); tree discrim_expr_node = CompileExpr::Compile (discrim_expr, ctx); + ctx->pop_const_context (); tree folded_discrim_expr = fold_expr (discrim_expr_node); tree qualifier = folded_discrim_expr; diff --git a/gcc/testsuite/rust/compile/enum_discriminant1.rs b/gcc/testsuite/rust/compile/enum_discriminant1.rs new file mode 100644 index 000..32092b2c2a5 --- /dev/null +++ b/gcc/testsuite/rust/compile/enum_discriminant1.rs @@ -0,0 +1,7 @@ +enum Foo { +Bar = 3 + 12, +} + +fn test() -> Foo { // { dg-warning "function is never used" } +return Foo::Bar; +} \ No newline at end of file -- 2.49.0
[Bug rust/119508] Hundreds of rust tests XPASS
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119508 --- Comment #9 from Sam James --- It is, as r15-9287-g89ca1e3cb697a8. -- You are receiving this mail because: You are on the CC list for the bug.
[COMMITTED 29/32] gccrs: Rename label getter to unchecked
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Update label getter call. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast.cc (BreakExpr::as_string): Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise. * ast/rust-expr.h: Add optional getter and rename label getter to get_label_unchecked. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/ast/rust-ast-collector.cc | 2 +- gcc/rust/ast/rust-ast-visitor.cc| 2 +- gcc/rust/ast/rust-ast.cc| 2 +- gcc/rust/ast/rust-expr.h| 7 +-- gcc/rust/hir/rust-ast-lower-expr.cc | 2 +- gcc/rust/resolve/rust-ast-resolve-expr.cc | 2 +- gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gcc/rust/ast/rust-ast-collector.cc b/gcc/rust/ast/rust-ast-collector.cc index 165b7617fe4..8ee63752f32 100644 --- a/gcc/rust/ast/rust-ast-collector.cc +++ b/gcc/rust/ast/rust-ast-collector.cc @@ -1287,7 +1287,7 @@ TokenCollector::visit (BreakExpr &expr) { push (Rust::Token::make (BREAK, expr.get_locus ())); if (expr.has_label ()) -visit (expr.get_label ()); +visit (expr.get_label_unchecked ()); if (expr.has_break_expr ()) visit (expr.get_break_expr ()); } diff --git a/gcc/rust/ast/rust-ast-visitor.cc b/gcc/rust/ast/rust-ast-visitor.cc index 702a176b266..9d524c3cc4c 100644 --- a/gcc/rust/ast/rust-ast-visitor.cc +++ b/gcc/rust/ast/rust-ast-visitor.cc @@ -486,7 +486,7 @@ DefaultASTVisitor::visit (AST::BreakExpr &expr) { visit_outer_attrs (expr); if (expr.has_label ()) -visit (expr.get_label ()); +visit (expr.get_label_unchecked ()); if (expr.has_break_expr ()) visit (expr.get_break_expr ()); diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc index 670e6d2413d..06e0e7b0fbc 100644 --- a/gcc/rust/ast/rust-ast.cc +++ b/gcc/rust/ast/rust-ast.cc @@ -2183,7 +2183,7 @@ BreakExpr::as_string () const std::string str ("break "); if (has_label ()) -str += get_label ().as_string () + " "; +str += get_label_unchecked ().as_string () + " "; if (has_break_expr ()) str += break_expr->as_string (); diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 4c832f9a06f..84cdfdb4678 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -2982,8 +2982,11 @@ public: outer_attrs = std::move (new_attrs); } - LoopLabel &get_label () { return label.value (); } - const LoopLabel &get_label () const { return label.value (); } + LoopLabel &get_label_unchecked () { return label.value (); } + const LoopLabel &get_label_unchecked () const { return label.value (); } + + tl::optional &get_label () { return label; } + const tl::optional &get_label () const { return label; } Expr::Kind get_expr_kind () const override { return Expr::Kind::Break; } diff --git a/gcc/rust/hir/rust-ast-lower-expr.cc b/gcc/rust/hir/rust-ast-lower-expr.cc index 944c0bbf4d1..3784e744f65 100644 --- a/gcc/rust/hir/rust-ast-lower-expr.cc +++ b/gcc/rust/hir/rust-ast-lower-expr.cc @@ -599,7 +599,7 @@ ASTLoweringExpr::visit (AST::BreakExpr &expr) { tl::optional break_label = tl::nullopt; if (expr.has_label ()) -break_label = lower_lifetime (expr.get_label ().get_lifetime ()); +break_label = lower_lifetime (expr.get_label_unchecked ().get_lifetime ()); HIR::Expr *break_expr = expr.has_break_expr () diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.cc b/gcc/rust/resolve/rust-ast-resolve-expr.cc index 54d92854128..8070fc1b07c 100644 --- a/gcc/rust/resolve/rust-ast-resolve-expr.cc +++ b/gcc/rust/resolve/rust-ast-resolve-expr.cc @@ -471,7 +471,7 @@ ResolveExpr::visit (AST::BreakExpr &expr) { if (expr.has_label ()) { - auto label = expr.get_label ().get_lifetime (); + auto label = expr.get_label_unchecked ().get_lifetime (); if (label.get_lifetime_type () != AST::Lifetime::LifetimeType::NAMED) { rust_error_at (label.get_locus (), diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc index b22be2a1a2d..f743e1e03f3 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc @@ -188,7 +188,7 @@ void Late::visit (AST::BreakExpr &expr) { if (expr.has_label ()) -resolve_label (expr.get_label ().get_lifetime ()); +resolve_label (expr.get_label_unchecked ().get_lifetime ()); if (expr.has_break_expr ()) { -- 2.49.0
☠ Buildbot (Sourceware): gccrust - failed '! grep ...' (failure) (master)
A new failure has been detected on builder gccrust-fedora-x86_64 while building gccrust. Full details are available at: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441 Build state: failed '! grep ...' (failure) Revision: 429897c851b460b9256d96e3e504dfe15342d125 Worker: bb1-1 Build Reason: (unknown) Blamelist: Pierre-Emmanuel Patry Steps: - 0: worker_preparation ( success ) - 1: git checkout ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/1/logs/stdio - 2: rm -rf gccrs-build ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/2/logs/stdio - 3: configure ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/3/logs/stdio - config.log: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/3/logs/config_log - 4: make ( warnings ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/4/logs/stdio - warnings (19): https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/4/logs/warnings__19_ - 5: make check ( warnings ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/5/logs/stdio - rust.sum: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/5/logs/rust_sum - rust.log: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/5/logs/rust_log - warnings (6): https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/5/logs/warnings__6_ - 6: grep FAIL or unexpected rust.sum ( failure ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/6/logs/stdio - 7: prep ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/7/logs/stdio - 8: build bunsen.cpio.gz ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/8/logs/stdio - 9: fetch bunsen.cpio.gz ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/9/logs/stdio - 10: unpack bunsen.cpio.gz ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/10/logs/stdio - 11: pass .bunsen.source.* ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/11/logs/stdio - 12: upload to bunsen ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/12/logs/stdio - 13: clean up ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/13/logs/stdio - 14: rm -rf gccrs-build_1 ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/16/builds/3441/steps/14/logs/stdio A new failure has been detected on builder gccrust-debian-i386 while building gccrust. Full details are available at: https://builder.sourceware.org/buildbot/#/builders/27/builds/2844 Build state: failed '! grep ...' (failure) Revision: 429897c851b460b9256d96e3e504dfe15342d125 Worker: debian-i386 Build Reason: (unknown) Blamelist: Pierre-Emmanuel Patry Steps: - 0: worker_preparation ( success ) - 1: git checkout ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2844/steps/1/logs/stdio - 2: rm -rf gccrs-build ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2844/steps/2/logs/stdio - 3: configure ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2844/steps/3/logs/stdio - config.log: https://builder.sourceware.org/buildbot/#/builders/27/builds/2844/steps/3/logs/config_log - 4: make ( warnings ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2844/steps/4/logs/stdio - warnings (100): https://builder.sourceware.org/buildbot/#/builders/27/builds/2844/steps/4/logs/warnings__100_ - 5: make check ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2844/steps/5/logs/stdio - rust.sum: https://builder.sourceware.org/buildbot/#/builders/27/builds/2844/steps/5/logs/rust_sum - rust.log: https://builder.sourceware.org/buildbot/#/builders/27/builds/2844/steps/5/logs/rust_log - 6: grep FAIL or unexpected rust.sum ( failure ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2844/steps/6/logs/stdio - 7: prep ( success ) Logs: - stdio: https://builder.sourceware.org/buildbot/#/builders/27/builds/2844/steps/7/logs/stdio - 8: build bunsen.cpio.gz ( success ) Logs: - stdio: https://bui
[COMMITTED 15/32] gccrs: refactoring rust_error_at "redefined multiple times"
From: Sri Ganesh Thota gcc/rust/ChangeLog: * resolve/rust-ast-resolve-base.h (redefined_error): created a function for rust_error_at for redefined at multiple times. * resolve/rust-ast-resolve-implitem.h: changed rust_error_at to redefined_error. * resolve/rust-ast-resolve-stmt.cc (ResolveStmt::visit): changed rust_error_at to redefined_error. * resolve/rust-ast-resolve-stmt.h: changed rust_error_at to redefined_error. * resolve/rust-ast-resolve-toplevel.h: changed rust_error_at to redefined_error. Signed-off-by: Sri Ganesh Thota --- gcc/rust/resolve/rust-ast-resolve-base.h | 5 +++ gcc/rust/resolve/rust-ast-resolve-implitem.h | 19 ++-- gcc/rust/resolve/rust-ast-resolve-stmt.cc| 2 +- gcc/rust/resolve/rust-ast-resolve-stmt.h | 20 ++-- gcc/rust/resolve/rust-ast-resolve-toplevel.h | 32 ++-- 5 files changed, 41 insertions(+), 37 deletions(-) diff --git a/gcc/rust/resolve/rust-ast-resolve-base.h b/gcc/rust/resolve/rust-ast-resolve-base.h index 0d497f81eac..ab74e84f079 100644 --- a/gcc/rust/resolve/rust-ast-resolve-base.h +++ b/gcc/rust/resolve/rust-ast-resolve-base.h @@ -27,6 +27,11 @@ namespace Rust { namespace Resolver { +inline void +redefined_error (const rich_location &loc) +{ + rust_error_at (loc, "redefined multiple times"); +} class ResolverBase : public AST::ASTVisitor { diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h index 971bf8faee2..2081697fe8f 100644 --- a/gcc/rust/resolve/rust-ast-resolve-implitem.h +++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h @@ -51,7 +51,7 @@ public: [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, type.get_locus ()); r.add_range (locus); - rust_error_at (r, "defined multiple times"); + redefined_error (r); }); } @@ -67,7 +67,7 @@ public: [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, constant.get_locus ()); r.add_range (locus); - rust_error_at (r, "defined multiple times"); + redefined_error (r); }); } @@ -84,7 +84,7 @@ public: [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, function.get_locus ()); r.add_range (locus); - rust_error_at (r, "defined multiple times"); + redefined_error (r); }); } @@ -124,7 +124,7 @@ public: [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, function.get_locus ()); r.add_range (locus); - rust_error_at (r, "defined multiple times"); + redefined_error (r); }); mappings.insert_canonical_path (function.get_node_id (), cpath); @@ -144,7 +144,7 @@ public: [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, constant.get_locus ()); r.add_range (locus); - rust_error_at (r, "defined multiple times"); + redefined_error (r); }); mappings.insert_canonical_path (constant.get_node_id (), cpath); @@ -162,7 +162,7 @@ public: [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, type.get_locus ()); r.add_range (locus); - rust_error_at (r, "defined multiple times"); + redefined_error (r); }); mappings.insert_canonical_path (type.get_node_id (), cpath); @@ -202,7 +202,7 @@ public: [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, function.get_locus ()); r.add_range (locus); - rust_error_at (r, "defined multiple times"); + redefined_error (r); }); NodeId current_module = resolver->peek_current_module_scope (); @@ -221,7 +221,7 @@ public: [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, item.get_locus ()); r.add_range (locus); - rust_error_at (r, "defined multiple times"); + redefined_error (r); }); NodeId current_module = resolver->peek_current_module_scope (); @@ -239,8 +239,7 @@ public: [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, type.get_locus ()); r.add_range (locus); - - rust_error_at (r, "defined multiple times"); + redefined_error (r); }); NodeId current_module = resolver->peek_current_module_scope (); diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.cc b/gcc/rust/resolve/rust-ast-resolve-stmt.cc index fefb522aec7..bfba302d29d 100644 --- a/gcc/rust/resolve/rust-ast-resolve-stmt.cc +++ b/gcc/rust/resolve/rust-ast-resolve-stmt.cc @@ -70,7 +70,7 @@ ResolveStmt::visit (AST::StaticItem &var) [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
[COMMITTED 30/32] gccrs: fix ICE segfault with empty feature gate
From: Matty Kuhn This patch fixes an issue where an empty feature gate would segfault, instead of reporting a syntax error to the user. gcc/rust/ChangeLog: * ast/rust-ast.h: (AST::Attribute): add empty_input function * checks/errors/rust-feature-gate.cc: (FeatureGate::visit): check for empty feature gate gcc/testsuite/ChangeLog: * rust/compile/feature.rs: add an invalid empty feature to produce an error Signed-off-by: Matty Kuhn --- gcc/rust/ast/rust-ast.h | 3 +++ gcc/rust/checks/errors/rust-feature-gate.cc | 7 +++ gcc/testsuite/rust/compile/feature.rs | 2 ++ 3 files changed, 12 insertions(+) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 1091ba0593e..09e0fce4f19 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -657,6 +657,9 @@ public: // Returns whether the attribute is considered an "empty" attribute. bool is_empty () const { return attr_input == nullptr && path.is_empty (); } + // Returns whether the attribute has no input + bool empty_input () const { return !attr_input; } + location_t get_locus () const { return locus; } AttrInput &get_attr_input () const { return *attr_input; } diff --git a/gcc/rust/checks/errors/rust-feature-gate.cc b/gcc/rust/checks/errors/rust-feature-gate.cc index f3daa61f170..44007f99e5c 100644 --- a/gcc/rust/checks/errors/rust-feature-gate.cc +++ b/gcc/rust/checks/errors/rust-feature-gate.cc @@ -40,6 +40,13 @@ FeatureGate::visit (AST::Crate &crate) { if (attr.get_path ().as_string () == "feature") { + // check for empty feature, such as `#![feature], this is an error + if (attr.empty_input ()) + { + rust_error_at (attr.get_locus (), ErrorCode::E0556, +"malformed % attribute input"); + continue; + } const auto &attr_input = attr.get_attr_input (); auto type = attr_input.get_attr_input_type (); if (type == AST::AttrInput::AttrInputType::TOKEN_TREE) diff --git a/gcc/testsuite/rust/compile/feature.rs b/gcc/testsuite/rust/compile/feature.rs index f743f9229b6..6f428f075a1 100644 --- a/gcc/testsuite/rust/compile/feature.rs +++ b/gcc/testsuite/rust/compile/feature.rs @@ -2,5 +2,7 @@ #![feature(AA)] //{ dg-error "unknown feature .AA." } #![feature(iamcrabby)] // { dg-error "unknown feature .iamcrabby." } #![feature(nonexistent_gccrs_feature)] // { dg-error "unknown feature .nonexistent_gccrs_feature." } +// ErrorCode - E0556 +#![feature] // { dg-error "malformed .feature. attribute input" } fn main() {} -- 2.49.0