From be88e6fea24106ce5b29de782b6219df39be6563 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Wed, 6 Nov 2024 15:15:02 +0100 Subject: [PATCH 1/3] hir: Mark AttrVec::get_outer_attrs as override gcc/rust/ChangeLog: * hir/tree/rust-hir.h: Add override qualifier to overriden method. --- gcc/rust/hir/tree/rust-hir.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h index 784e12e57ab..38d35eea6e3 100644 --- a/gcc/rust/hir/tree/rust-hir.h +++ b/gcc/rust/hir/tree/rust-hir.h @@ -673,7 +673,7 @@ class LifetimeParam : public GenericParam // Returns whether the lifetime param has an outer attribute. bool has_outer_attribute () const override { return outer_attrs.size () > 1; } - AST::AttrVec &get_outer_attrs () { return outer_attrs; } + AST::AttrVec &get_outer_attrs () override { return outer_attrs; } // Returns whether the lifetime param is in an error state. bool is_error () const { return lifetime.is_error (); } From ab35fa6c06c3997243c72d718fd2e7dd9efa8b98 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Wed, 6 Nov 2024 15:19:10 +0100 Subject: [PATCH 2/3] typecheck: Remove unused parameter in TyTyCheckCallExpr gcc/rust/ChangeLog: * typecheck/rust-tyty-call.h: Remove unused context member. --- gcc/rust/typecheck/rust-tyty-call.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gcc/rust/typecheck/rust-tyty-call.h b/gcc/rust/typecheck/rust-tyty-call.h index 9d795524ba5..dc88620d105 100644 --- a/gcc/rust/typecheck/rust-tyty-call.h +++ b/gcc/rust/typecheck/rust-tyty-call.h @@ -73,14 +73,12 @@ class TypeCheckCallExpr : private TyVisitor TypeCheckCallExpr (HIR::CallExpr &c, TyTy::VariantDef &variant, Resolver::TypeCheckContext *context) : resolved (new TyTy::ErrorType (c.get_mappings ().get_hirid ())), call (c), - variant (variant), context (context), - mappings (Analysis::Mappings::get ()) + variant (variant), mappings (Analysis::Mappings::get ()) {} BaseType *resolved; HIR::CallExpr &call; TyTy::VariantDef &variant; - Resolver::TypeCheckContext *context; Analysis::Mappings &mappings; }; From dd24b0ddfedd78a1142aa29461813963f8da9e5e Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Wed, 6 Nov 2024 15:19:55 +0100 Subject: [PATCH 3/3] asm: Fix clang warnings Fixes a couple of warnings thrown by clang, with mismatched class/struct usages and unused members. gcc/rust/ChangeLog: * ast/rust-expr.h: Remove invalid usage of `struct`. * backend/rust-compile-asm.h: Remove unused `translated` member. * backend/rust-compile-asm.cc (CompileAsm::CompileAsm): Remove usage of `translated` member. * checks/errors/rust-unsafe-checker.h: Mark visitor as `override`. * hir/tree/rust-hir-expr.h (struct AnonConst): Remove unused `locus` member. --- gcc/rust/ast/rust-expr.h | 24 ++++++++++---------- gcc/rust/backend/rust-compile-asm.cc | 5 ++-- gcc/rust/backend/rust-compile-asm.h | 2 -- gcc/rust/checks/errors/rust-unsafe-checker.h | 2 +- gcc/rust/hir/tree/rust-hir-expr.h | 4 ++-- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 438d3d3b86e..483e599652b 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -4810,14 +4810,14 @@ class InlineAsmOperand rust_assert (this->expr != nullptr); } - In (const struct In &other) + In (const In &other) { reg = other.reg; expr = other.expr->clone_expr (); } - In operator= (const struct In &other) + In operator= (const In &other) { reg = other.reg; expr = other.expr->clone_expr (); @@ -4843,14 +4843,14 @@ class InlineAsmOperand rust_assert (this->expr != nullptr); } - Out (const struct Out &other) + Out (const Out &other) { reg = other.reg; late = other.late; expr = other.expr->clone_expr (); } - Out operator= (const struct Out &other) + Out operator= (const Out &other) { reg = other.reg; late = other.late; @@ -4876,14 +4876,14 @@ class InlineAsmOperand rust_assert (this->expr != nullptr); } - InOut (const struct InOut &other) + InOut (const InOut &other) { reg = other.reg; late = other.late; expr = other.expr->clone_expr (); } - InOut operator= (const struct InOut &other) + InOut operator= (const InOut &other) { reg = other.reg; late = other.late; @@ -4913,7 +4913,7 @@ class InlineAsmOperand rust_assert (this->out_expr != nullptr); } - SplitInOut (const struct SplitInOut &other) + SplitInOut (const SplitInOut &other) { reg = other.reg; late = other.late; @@ -4921,7 +4921,7 @@ class InlineAsmOperand out_expr = other.out_expr->clone_expr (); } - SplitInOut operator= (const struct SplitInOut &other) + SplitInOut operator= (const SplitInOut &other) { reg = other.reg; late = other.late; @@ -4953,12 +4953,12 @@ class InlineAsmOperand { rust_assert (this->expr != nullptr); } - Sym (const struct Sym &other) + Sym (const Sym &other) { expr = std::unique_ptr (other.expr->clone_expr ()); } - Sym operator= (const struct Sym &other) + Sym operator= (const Sym &other) { expr = std::unique_ptr (other.expr->clone_expr ()); return *this; @@ -4981,12 +4981,12 @@ class InlineAsmOperand if (label_name.has_value ()) this->label_name = label_name.value (); } - Label (const struct Label &other) + Label (const Label &other) { expr = std::unique_ptr (other.expr->clone_expr ()); } - Label operator= (const struct Label &other) + Label operator= (const Label &other) { expr = std::unique_ptr (other.expr->clone_expr ()); return *this; diff --git a/gcc/rust/backend/rust-compile-asm.cc b/gcc/rust/backend/rust-compile-asm.cc index 751d64ef9bd..87e4266133f 100644 --- a/gcc/rust/backend/rust-compile-asm.cc +++ b/gcc/rust/backend/rust-compile-asm.cc @@ -3,9 +3,8 @@ namespace Rust { namespace Compile { -CompileAsm::CompileAsm (Context *ctx) - : HIRCompileBase (ctx), translated (error_mark_node) -{} +CompileAsm::CompileAsm (Context *ctx) : HIRCompileBase (ctx) {} + tree CompileAsm::tree_codegen_asm (HIR::InlineAsm &expr) { diff --git a/gcc/rust/backend/rust-compile-asm.h b/gcc/rust/backend/rust-compile-asm.h index 402d950844c..4abd24eded4 100644 --- a/gcc/rust/backend/rust-compile-asm.h +++ b/gcc/rust/backend/rust-compile-asm.h @@ -28,8 +28,6 @@ namespace Compile { class CompileAsm : private HIRCompileBase { private: - tree translated; - // RELEVANT MEMBER FUNCTIONS // The limit is 5 because it stands for the 5 things that the C version of diff --git a/gcc/rust/checks/errors/rust-unsafe-checker.h b/gcc/rust/checks/errors/rust-unsafe-checker.h index bd88dc395ea..228f470854b 100644 --- a/gcc/rust/checks/errors/rust-unsafe-checker.h +++ b/gcc/rust/checks/errors/rust-unsafe-checker.h @@ -113,7 +113,7 @@ class UnsafeChecker : public HIRFullVisitor virtual void visit (MatchExpr &expr) override; virtual void visit (AwaitExpr &expr) override; virtual void visit (AsyncBlockExpr &expr) override; - virtual void visit (InlineAsm &expr); + virtual void visit (InlineAsm &expr) override; virtual void visit (TypeParam ¶m) override; virtual void visit (ConstGenericParam ¶m) override; virtual void visit (LifetimeWhereClauseItem &item) override; diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h index 99044905de3..cb699397447 100644 --- a/gcc/rust/hir/tree/rust-hir-expr.h +++ b/gcc/rust/hir/tree/rust-hir-expr.h @@ -3700,7 +3700,6 @@ struct AnonConst return *this; } }; -; class InlineAsmOperand { @@ -3888,7 +3887,6 @@ class InlineAsmOperand tl::optional cnst; tl::optional sym; tl::optional label; - location_t locus; public: InlineAsmOperand (const InlineAsmOperand &other) @@ -3931,6 +3929,7 @@ class InlineAsmOperand struct Sym get_sym () const { return sym.value (); } struct Label get_label () const { return label.value (); } }; + // Inline Assembly Node class InlineAsm : public ExprWithoutBlock { @@ -4009,6 +4008,7 @@ class InlineAsm : public ExprWithoutBlock {} }; + } // namespace HIR } // namespace Rust