diff options
author | Marc Poulhiès <dkm@kataplop.net> | 2021-03-10 21:41:53 +0100 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-03-14 18:35:34 +0000 |
commit | 173bff7f12c2c19502825a11649ad54f612af04a (patch) | |
tree | 09e8eb459878a26068306952cb40110d120a38c5 /gcc/rust/backend | |
parent | b8549556123da80e60922eaa928cfd284f831303 (diff) | |
download | gcc-173bff7f12c2c19502825a11649ad54f612af04a.zip gcc-173bff7f12c2c19502825a11649ad54f612af04a.tar.gz gcc-173bff7f12c2c19502825a11649ad54f612af04a.tar.bz2 |
Fix Woverloaded-virtual warnings.
Fix warnings from -Woverloaded-virtual.
Fix #274
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-block.h | 20 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 62 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-fnparam.h | 4 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-implitem.h | 8 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-item.h | 10 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-resolve-path.h | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-stmt.h | 8 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-struct-field-expr.h | 8 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-var-decl.h | 6 |
9 files changed, 75 insertions, 53 deletions
diff --git a/gcc/rust/backend/rust-compile-block.h b/gcc/rust/backend/rust-compile-block.h index 879e32d..128a729 100644 --- a/gcc/rust/backend/rust-compile-block.h +++ b/gcc/rust/backend/rust-compile-block.h @@ -27,6 +27,8 @@ namespace Compile { class CompileBlock : public HIRCompileBase { + using Rust::Compile::HIRCompileBase::visit; + public: static Bblock *compile (HIR::BlockExpr *expr, Context *ctx, Bvariable *result) { @@ -35,7 +37,7 @@ public: return compiler.translated; } - void visit (HIR::BlockExpr &expr); + void visit (HIR::BlockExpr &expr) override; private: CompileBlock (Context *ctx, Bvariable *result) @@ -48,6 +50,8 @@ private: class CompileConditionalBlocks : public HIRCompileBase { + using Rust::Compile::HIRCompileBase::visit; + public: static Bstatement *compile (HIR::IfExpr *expr, Context *ctx, Bvariable *result) @@ -57,11 +61,11 @@ public: return resolver.translated; } - void visit (HIR::IfExpr &expr); + void visit (HIR::IfExpr &expr) override; - void visit (HIR::IfExprConseqElse &expr); + void visit (HIR::IfExprConseqElse &expr) override; - void visit (HIR::IfExprConseqIf &expr); + void visit (HIR::IfExprConseqIf &expr) override; private: CompileConditionalBlocks (Context *ctx, Bvariable *result) @@ -74,6 +78,8 @@ private: class CompileExprWithBlock : public HIRCompileBase { + using Rust::Compile::HIRCompileBase::visit; + public: static Bstatement *compile (HIR::ExprWithBlock *expr, Context *ctx, Bvariable *result) @@ -83,17 +89,17 @@ public: return resolver.translated; } - void visit (HIR::IfExpr &expr) + void visit (HIR::IfExpr &expr) override { translated = CompileConditionalBlocks::compile (&expr, ctx, result); } - void visit (HIR::IfExprConseqElse &expr) + void visit (HIR::IfExprConseqElse &expr) override { translated = CompileConditionalBlocks::compile (&expr, ctx, result); } - void visit (HIR::IfExprConseqIf &expr) + void visit (HIR::IfExprConseqIf &expr) override { translated = CompileConditionalBlocks::compile (&expr, ctx, result); } diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index b48d79e..f4353cd 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -30,6 +30,8 @@ namespace Compile { class CompileExpr : public HIRCompileBase { + using Rust::Compile::HIRCompileBase::visit; + public: static Bexpression *Compile (HIR::Expr *expr, Context *ctx) { @@ -38,7 +40,7 @@ public: return compiler.translated; } - void visit (HIR::TupleIndexExpr &expr) + void visit (HIR::TupleIndexExpr &expr) override { HIR::Expr *tuple_expr = expr.get_tuple_expr ().get (); TupleIndex index = expr.get_tuple_index (); @@ -49,7 +51,7 @@ public: expr.get_locus ()); } - void visit (HIR::TupleExpr &expr) + void visit (HIR::TupleExpr &expr) override { if (expr.is_unit ()) { @@ -82,7 +84,7 @@ public: expr.get_locus ()); } - void visit (HIR::ReturnExpr &expr) + void visit (HIR::ReturnExpr &expr) override { auto fncontext = ctx->peek_fn (); @@ -101,11 +103,11 @@ public: ctx->add_statement (s); } - void visit (HIR::CallExpr &expr); + void visit (HIR::CallExpr &expr) override; - void visit (HIR::MethodCallExpr &expr); + void visit (HIR::MethodCallExpr &expr) override; - void visit (HIR::IdentifierExpr &expr) + void visit (HIR::IdentifierExpr &expr) override { // need to look up the reference for this identifier NodeId ref_node_id; @@ -157,7 +159,7 @@ public: } } - void visit (HIR::LiteralExpr &expr) + void visit (HIR::LiteralExpr &expr) override { auto literal_value = expr.get_literal (); switch (expr.get_lit_type ()) @@ -241,7 +243,7 @@ public: gcc_unreachable (); } - void visit (HIR::AssignmentExpr &expr) + void visit (HIR::AssignmentExpr &expr) override { fncontext fn = ctx->peek_fn (); auto lhs = CompileExpr::Compile (expr.get_lhs (), ctx); @@ -253,7 +255,7 @@ public: ctx->add_statement (assignment); } - void visit (HIR::ArrayIndexExpr &expr) + void visit (HIR::ArrayIndexExpr &expr) override { Bexpression *array = CompileExpr::Compile (expr.get_array_expr (), ctx); Bexpression *index = CompileExpr::Compile (expr.get_index_expr (), ctx); @@ -262,7 +264,7 @@ public: expr.get_locus ()); } - void visit (HIR::ArrayExpr &expr) + void visit (HIR::ArrayExpr &expr) override { TyTy::BaseType *tyty = nullptr; if (!ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (), @@ -286,7 +288,7 @@ public: expr.get_locus ()); } - void visit (HIR::ArrayElemsValues &elems) + void visit (HIR::ArrayElemsValues &elems) override { elems.iterate ([&] (HIR::Expr *e) mutable -> bool { Bexpression *translated_expr = CompileExpr::Compile (e, ctx); @@ -295,7 +297,7 @@ public: }); } - void visit (HIR::ArrayElemsCopied &elems) + void visit (HIR::ArrayElemsCopied &elems) override { Bexpression *translated_expr = CompileExpr::Compile (elems.get_elem_to_copy (), ctx); @@ -304,7 +306,7 @@ public: constructor.push_back (translated_expr); } - void visit (HIR::ArithmeticOrLogicalExpr &expr) + void visit (HIR::ArithmeticOrLogicalExpr &expr) override { auto op = expr.get_expr_type (); auto lhs = CompileExpr::Compile (expr.get_lhs (), ctx); @@ -316,7 +318,7 @@ public: location); } - void visit (HIR::ComparisonExpr &expr) + void visit (HIR::ComparisonExpr &expr) override { auto op = expr.get_expr_type (); auto lhs = CompileExpr::Compile (expr.get_lhs (), ctx); @@ -327,7 +329,7 @@ public: = ctx->get_backend ()->comparison_expression (op, lhs, rhs, location); } - void visit (HIR::LazyBooleanExpr &expr) + void visit (HIR::LazyBooleanExpr &expr) override { auto op = expr.get_expr_type (); auto lhs = CompileExpr::Compile (expr.get_lhs (), ctx); @@ -338,7 +340,7 @@ public: = ctx->get_backend ()->lazy_boolean_expression (op, lhs, rhs, location); } - void visit (HIR::NegationExpr &expr) + void visit (HIR::NegationExpr &expr) override { auto op = expr.get_expr_type (); auto negated_expr = CompileExpr::Compile (expr.get_expr (), ctx); @@ -348,13 +350,13 @@ public: = ctx->get_backend ()->negation_expression (op, negated_expr, location); } - void visit (HIR::IfExpr &expr) + void visit (HIR::IfExpr &expr) override { auto stmt = CompileConditionalBlocks::compile (&expr, ctx, nullptr); ctx->add_statement (stmt); } - void visit (HIR::IfExprConseqElse &expr) + void visit (HIR::IfExprConseqElse &expr) override { TyTy::BaseType *if_type = nullptr; if (!ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (), @@ -391,7 +393,7 @@ public: } } - void visit (HIR::IfExprConseqIf &expr) + void visit (HIR::IfExprConseqIf &expr) override { TyTy::BaseType *if_type = nullptr; if (!ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (), @@ -428,7 +430,7 @@ public: } } - void visit (HIR::BlockExpr &expr) + void visit (HIR::BlockExpr &expr) override { TyTy::BaseType *block_tyty = nullptr; if (!ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (), @@ -465,7 +467,7 @@ public: } } - void visit (HIR::StructExprStructFields &struct_expr) + void visit (HIR::StructExprStructFields &struct_expr) override { TyTy::BaseType *tyty = nullptr; if (!ctx->get_tyctx ()->lookup_type ( @@ -492,12 +494,12 @@ public: struct_expr.get_locus ()); } - void visit (HIR::GroupedExpr &expr) + void visit (HIR::GroupedExpr &expr) override { translated = CompileExpr::Compile (expr.get_expr_in_parens ().get (), ctx); } - void visit (HIR::FieldAccessExpr &expr) + void visit (HIR::FieldAccessExpr &expr) override { // resolve the receiver back to ADT type TyTy::BaseType *receiver = nullptr; @@ -522,12 +524,12 @@ public: expr.get_locus ()); } - void visit (HIR::PathInExpression &expr) + void visit (HIR::PathInExpression &expr) override { translated = ResolvePathRef::Compile (&expr, ctx); } - void visit (HIR::LoopExpr &expr) + void visit (HIR::LoopExpr &expr) override { TyTy::BaseType *block_tyty = nullptr; if (!ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (), @@ -592,7 +594,7 @@ public: ctx->pop_loop_begin_label (); } - void visit (HIR::WhileLoopExpr &expr) + void visit (HIR::WhileLoopExpr &expr) override { fncontext fnctx = ctx->peek_fn (); if (expr.has_loop_label ()) @@ -650,7 +652,7 @@ public: ctx->add_statement (loop_stmt); } - void visit (HIR::BreakExpr &expr) + void visit (HIR::BreakExpr &expr) override { fncontext fnctx = ctx->peek_fn (); if (expr.has_break_expr ()) @@ -713,7 +715,7 @@ public: } } - void visit (HIR::ContinueExpr &expr) + void visit (HIR::ContinueExpr &expr) override { Blabel *label = ctx->peek_loop_begin_label (); if (expr.has_label ()) @@ -752,7 +754,7 @@ public: ctx->add_statement (goto_label); } - void visit (HIR::BorrowExpr &expr) + void visit (HIR::BorrowExpr &expr) override { Bexpression *main_expr = CompileExpr::Compile (expr.get_expr ().get (), ctx); @@ -761,7 +763,7 @@ public: = ctx->get_backend ()->address_expression (main_expr, expr.get_locus ()); } - void visit (HIR::DereferenceExpr &expr) + void visit (HIR::DereferenceExpr &expr) override { Bexpression *main_expr = CompileExpr::Compile (expr.get_expr ().get (), ctx); diff --git a/gcc/rust/backend/rust-compile-fnparam.h b/gcc/rust/backend/rust-compile-fnparam.h index 1ea0c9f..13bb74d 100644 --- a/gcc/rust/backend/rust-compile-fnparam.h +++ b/gcc/rust/backend/rust-compile-fnparam.h @@ -26,6 +26,8 @@ namespace Compile { class CompileFnParam : public HIRCompileBase { + using Rust::Compile::HIRCompileBase::visit; + public: static Bvariable *compile (Context *ctx, Bfunction *fndecl, HIR::FunctionParam *param, Btype *decl_type, @@ -36,7 +38,7 @@ public: return compiler.translated; } - void visit (HIR::IdentifierPattern &pattern) + void visit (HIR::IdentifierPattern &pattern) override { if (!pattern.is_mut) decl_type = ctx->get_backend ()->immutable_type (decl_type); diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h index 9370e9c..202b868 100644 --- a/gcc/rust/backend/rust-compile-implitem.h +++ b/gcc/rust/backend/rust-compile-implitem.h @@ -31,6 +31,8 @@ namespace Compile { class CompileInherentImplItem : public HIRCompileBase { + using Rust::Compile::HIRCompileBase::visit; + public: static void Compile (TyTy::BaseType *self, HIR::InherentImplItem *item, Context *ctx, bool compile_fns) @@ -39,7 +41,7 @@ public: item->accept_vis (compiler); } - void visit (HIR::ConstantItem &constant) + void visit (HIR::ConstantItem &constant) override { TyTy::BaseType *resolved_type = nullptr; bool ok @@ -58,7 +60,7 @@ public: ctx->insert_const_decl (constant.get_mappings ().get_hirid (), const_expr); } - void visit (HIR::Function &function) + void visit (HIR::Function &function) override { if (!compile_fns) return; @@ -223,7 +225,7 @@ public: ctx->push_function (fndecl); } - void visit (HIR::Method &method) + void visit (HIR::Method &method) override { if (!compile_fns) return; diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 384bf94..1d4fcda 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -32,6 +32,8 @@ namespace Compile { class CompileItem : public HIRCompileBase { + using Rust::Compile::HIRCompileBase::visit; + public: static void compile (HIR::Item *item, Context *ctx, bool compile_fns = true) { @@ -39,7 +41,7 @@ public: item->accept_vis (compiler); } - void visit (HIR::StaticItem &var) + void visit (HIR::StaticItem &var) override { TyTy::BaseType *resolved_type = nullptr; bool ok = ctx->get_tyctx ()->lookup_type (var.get_mappings ().get_hirid (), @@ -67,7 +69,7 @@ public: ctx->push_var (static_global); } - void visit (HIR::ConstantItem &constant) + void visit (HIR::ConstantItem &constant) override { TyTy::BaseType *resolved_type = nullptr; bool ok @@ -85,7 +87,7 @@ public: ctx->insert_const_decl (constant.get_mappings ().get_hirid (), const_expr); } - void visit (HIR::Function &function) + void visit (HIR::Function &function) override { if (!compile_fns) return; @@ -255,7 +257,7 @@ public: ctx->push_function (fndecl); } - void visit (HIR::InherentImpl &impl_block) + void visit (HIR::InherentImpl &impl_block) override { TyTy::BaseType *self_lookup = nullptr; if (!ctx->get_tyctx ()->lookup_type ( diff --git a/gcc/rust/backend/rust-compile-resolve-path.h b/gcc/rust/backend/rust-compile-resolve-path.h index ae469e6..da1d97e 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.h +++ b/gcc/rust/backend/rust-compile-resolve-path.h @@ -27,6 +27,8 @@ namespace Compile { class ResolvePathRef : public HIRCompileBase { + using Rust::Compile::HIRCompileBase::visit; + public: static Bexpression *Compile (HIR::Expr *expr, Context *ctx) { diff --git a/gcc/rust/backend/rust-compile-stmt.h b/gcc/rust/backend/rust-compile-stmt.h index b99b975..3c2916d 100644 --- a/gcc/rust/backend/rust-compile-stmt.h +++ b/gcc/rust/backend/rust-compile-stmt.h @@ -28,6 +28,8 @@ namespace Compile { class CompileStmt : public HIRCompileBase { + using Rust::Compile::HIRCompileBase::visit; + public: static Bexpression *Compile (HIR::Stmt *stmt, Context *ctx) { @@ -37,19 +39,19 @@ public: return compiler.translated; } - void visit (HIR::ExprStmtWithBlock &stmt) + void visit (HIR::ExprStmtWithBlock &stmt) override { ok = true; translated = CompileExpr::Compile (stmt.get_expr (), ctx); } - void visit (HIR::ExprStmtWithoutBlock &stmt) + void visit (HIR::ExprStmtWithoutBlock &stmt) override { ok = true; translated = CompileExpr::Compile (stmt.get_expr (), ctx); } - void visit (HIR::LetStmt &stmt) + void visit (HIR::LetStmt &stmt) override { // marks that the statement has been looked at ok = true; diff --git a/gcc/rust/backend/rust-compile-struct-field-expr.h b/gcc/rust/backend/rust-compile-struct-field-expr.h index 0a16f6a..e377524 100644 --- a/gcc/rust/backend/rust-compile-struct-field-expr.h +++ b/gcc/rust/backend/rust-compile-struct-field-expr.h @@ -27,6 +27,8 @@ namespace Compile { class CompileStructExprField : public HIRCompileBase { + using Rust::Compile::HIRCompileBase::visit; + public: static Bexpression *Compile (HIR::StructExprField *field, Context *ctx) { @@ -36,11 +38,11 @@ public: return compiler.translated; } - void visit (HIR::StructExprFieldIdentifierValue &field); + void visit (HIR::StructExprFieldIdentifierValue &field) override; - void visit (HIR::StructExprFieldIndexValue &field); + void visit (HIR::StructExprFieldIndexValue &field) override; - void visit (HIR::StructExprFieldIdentifier &field); + void visit (HIR::StructExprFieldIdentifier &field) override; private: CompileStructExprField (Context *ctx) diff --git a/gcc/rust/backend/rust-compile-var-decl.h b/gcc/rust/backend/rust-compile-var-decl.h index 7069d95..ee4e65b 100644 --- a/gcc/rust/backend/rust-compile-var-decl.h +++ b/gcc/rust/backend/rust-compile-var-decl.h @@ -26,6 +26,8 @@ namespace Compile { class CompileVarDecl : public HIRCompileBase { + using Rust::Compile::HIRCompileBase::visit; + public: static ::Bvariable *compile (::Bfunction *fndecl, HIR::Stmt *stmt, Context *ctx) @@ -38,7 +40,7 @@ public: return compiler.translated; } - void visit (HIR::LetStmt &stmt) + void visit (HIR::LetStmt &stmt) override { locus = stmt.get_locus (); TyTy::BaseType *resolved_type = nullptr; @@ -50,7 +52,7 @@ public: stmt.get_pattern ()->accept_vis (*this); } - void visit (HIR::IdentifierPattern &pattern) + void visit (HIR::IdentifierPattern &pattern) override { if (!pattern.is_mut) translated_type = ctx->get_backend ()->immutable_type (translated_type); |