public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] gccrs: add helper to check for a const or static context
@ 2023-05-02 7:10 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-05-02 7:10 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c630493edcd2ccbef51a5893796f5deecd9d8a0b
commit c630493edcd2ccbef51a5893796f5deecd9d8a0b
Author: Philip Herron <herron.philip@googlemail.com>
Date: Mon Apr 17 22:04:11 2023 +0100
gccrs: add helper to check for a const or static context
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check.h: new helper
* typecheck/rust-typecheck-context.cc (TypeCheckContext::have_function_context):
implementation
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diff:
---
gcc/rust/typecheck/rust-hir-type-check.h | 1 +
gcc/rust/typecheck/rust-typecheck-context.cc | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/gcc/rust/typecheck/rust-hir-type-check.h b/gcc/rust/typecheck/rust-hir-type-check.h
index 538dcaefc12..74ab6c3cacf 100644
--- a/gcc/rust/typecheck/rust-hir-type-check.h
+++ b/gcc/rust/typecheck/rust-hir-type-check.h
@@ -91,6 +91,7 @@ public:
void insert_type_by_node_id (NodeId ref, HirId id);
bool lookup_type_by_node_id (NodeId ref, HirId *id);
+ bool have_function_context () const;
TyTy::BaseType *peek_return_type ();
TypeCheckContextItem peek_context ();
void push_return_type (TypeCheckContextItem item,
diff --git a/gcc/rust/typecheck/rust-typecheck-context.cc b/gcc/rust/typecheck/rust-typecheck-context.cc
index c041b153b4e..ffa49dc195b 100644
--- a/gcc/rust/typecheck/rust-typecheck-context.cc
+++ b/gcc/rust/typecheck/rust-typecheck-context.cc
@@ -136,6 +136,12 @@ TypeCheckContext::lookup_type_by_node_id (NodeId ref, HirId *id)
return true;
}
+bool
+TypeCheckContext::have_function_context () const
+{
+ return !return_type_stack.empty ();
+}
+
TyTy::BaseType *
TypeCheckContext::peek_return_type ()
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-02 7:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-02 7:10 [gcc/devel/rust/master] gccrs: add helper to check for a const or static context Thomas Schwinge
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).