From 7a92e0ca3c74c44e476157b82b517cac91b5f7a1 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 21 Sep 2021 00:10:28 +0200 Subject: Remove warnings from v0_mangle functions in rust-mangle.cc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There were two warnings in rust-mangle.cc rust-mangle.cc: In function ‘std::string Rust::Compile::v0_mangle_item (const Rust::TyTy::BaseType*, const Rust::Resolver::CanonicalPath&, const string&)’: rust-mangle.cc:198:1: warning: no return statement in function returning non-void rust-mangle.cc: At global scope: rust-mangle.cc:201:1: warning: ‘std::string Rust::Compile::v0_mangle_impl_item (const Rust::TyTy::BaseType*, const Rust::TyTy::BaseType*, const string&, const string&)’ declared ‘static’ but never defined [-Wunused-function] The first results in undefined behaviour, the second points out that the function isn't ever called/used. Fix the first by adding a gcc_unreachable () to turn the calling of the function into an abort (). Fix the second by adding the call in Mangler::mangle_impl_item. And add an implementation simply calling gcc-unreachable (). This turns the warnings and undefined behaviour into explicit runtime aborts when these functions are actually called. --- gcc/rust/backend/rust-mangle.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/backend/rust-mangle.cc b/gcc/rust/backend/rust-mangle.cc index 840acb9..0e6643c 100644 --- a/gcc/rust/backend/rust-mangle.cc +++ b/gcc/rust/backend/rust-mangle.cc @@ -195,11 +195,15 @@ v0_mangle_item (const TyTy::BaseType *ty, const Resolver::CanonicalPath &path, const std::string &crate_name) { auto ty_prefix = v0_type_prefix (ty); + gcc_unreachable (); } static std::string v0_mangle_impl_item (const TyTy::BaseType *self, const TyTy::BaseType *ty, - const std::string &name, const std::string &crate_name); + const std::string &name, const std::string &crate_name) +{ + gcc_unreachable (); +} std::string Mangler::mangle_item (const TyTy::BaseType *ty, @@ -227,7 +231,7 @@ Mangler::mangle_impl_item (const TyTy::BaseType *self, const TyTy::BaseType *ty, case Mangler::MangleVersion::LEGACY: return legacy_mangle_impl_item (self, ty, name, crate_name); case Mangler::MangleVersion::V0: - gcc_unreachable (); + return v0_mangle_impl_item (self, ty, name, crate_name); default: gcc_unreachable (); } -- cgit v1.1