diff options
author | Philip Herron <herron.philip@googlemail.com> | 2023-04-17 22:04:11 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:34:12 +0100 |
commit | 0c6338ddb64b8a3fc24470b3040e09ade2f772d8 (patch) | |
tree | 1f66c71c6ee82a439c7c53ca764982cc37a8d6f5 | |
parent | e3a2f3b1931b10afb43893b476e7e27b8ade007e (diff) | |
download | gcc-0c6338ddb64b8a3fc24470b3040e09ade2f772d8.zip gcc-0c6338ddb64b8a3fc24470b3040e09ade2f772d8.tar.gz gcc-0c6338ddb64b8a3fc24470b3040e09ade2f772d8.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>
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check.h | 1 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-typecheck-context.cc | 6 |
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 3f43bc8..6fa75ec 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 7c0dc06..5d05021 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 () { |