]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: add helper to check for a const or static context
authorPhilip Herron <herron.philip@googlemail.com>
Mon, 17 Apr 2023 21:04:11 +0000 (22:04 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:34:12 +0000 (18:34 +0100)
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>
gcc/rust/typecheck/rust-hir-type-check.h
gcc/rust/typecheck/rust-typecheck-context.cc

index 3f43bc89d6fdf3e001362f06a1079e4229390488..6fa75ecdc335798d3f73155ba85db8be33dee30c 100644 (file)
@@ -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,
index 7c0dc06372d040145741011255cd08c5c348376c..5d050218dc7b8f84bd198bd6dcdbf4dbdbdb8b0e 100644 (file)
@@ -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 ()
 {