aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-04-17 22:04:11 +0100
committerPhilip Herron <philip.herron@embecosm.com>2023-04-26 15:02:40 +0000
commitc630493edcd2ccbef51a5893796f5deecd9d8a0b (patch)
tree5c54eb0a2192305e911f5b6f26e83df164dff68f /gcc
parentaa67a856e7ed69d595f7cd8dc7a747ec69db6712 (diff)
downloadgcc-c630493edcd2ccbef51a5893796f5deecd9d8a0b.zip
gcc-c630493edcd2ccbef51a5893796f5deecd9d8a0b.tar.gz
gcc-c630493edcd2ccbef51a5893796f5deecd9d8a0b.tar.bz2
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check.h1
-rw-r--r--gcc/rust/typecheck/rust-typecheck-context.cc6
2 files changed, 7 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check.h b/gcc/rust/typecheck/rust-hir-type-check.h
index 538dcae..74ab6c3 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 c041b15..ffa49dc 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 ()
{