public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Add an assertion to avoid peeking when the stack is empty Date: Wed, 8 Jun 2022 12:40:30 +0000 (GMT) [thread overview] Message-ID: <20220608124030.69294381ECBE@sourceware.org> (raw) https://gcc.gnu.org/g:7fe6bc1ba1a8d296262e1e06ac067190c8ab3ebb commit 7fe6bc1ba1a8d296262e1e06ac067190c8ab3ebb Author: Philip Herron <philip.herron@embecosm.com> Date: Thu Apr 28 14:42:15 2022 +0100 Add an assertion to avoid peeking when the stack is empty Diff: --- gcc/rust/backend/rust-compile-context.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index de9d03f6d9d..d17034b51df 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -254,7 +254,11 @@ public: bool in_fn () { return fn_stack.size () != 0; } // Note: it is undefined behavior to call peek_fn () if fn_stack is empty. - fncontext peek_fn () { return fn_stack.back (); } + fncontext peek_fn () + { + rust_assert (!fn_stack.empty ()); + return fn_stack.back (); + } void push_type (tree t) { type_decls.push_back (t); } void push_var (::Bvariable *v) { var_decls.push_back (v); }
reply other threads:[~2022-06-08 12:40 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220608124030.69294381ECBE@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).