From: Mark Wielaard <mark@klomp.org>
To: gcc-rust@gcc.gnu.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] Remove warnings from v0_mangle functions in rust-mangle.cc
Date: Tue, 21 Sep 2021 00:49:56 +0200 [thread overview]
Message-ID: <20210920224956.147676-1-mark@klomp.org> (raw)
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(-)
https://code.wildebeest.org/git/user/mjw/gccrs/commit/?h=rust-mangle-unreachable
diff --git a/gcc/rust/backend/rust-mangle.cc b/gcc/rust/backend/rust-mangle.cc
index 840acb992e0..0e6643c64ae 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 ();
}
--
2.32.0
next reply other threads:[~2021-09-20 22:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 22:49 Mark Wielaard [this message]
2021-09-21 11:58 ` cohenarthur.dev
2021-09-21 12:25 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210920224956.147676-1-mark@klomp.org \
--to=mark@klomp.org \
--cc=gcc-rust@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).