diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-11-03 14:37:52 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-11-05 11:12:15 +0000 |
commit | c6dc53f9e2e95295936c970019c8cbd573a8e4f6 (patch) | |
tree | 6ddc9739c3a057e8d89d335c9e4a3588ed89d294 /gcc/rust/backend/rust-compile-context.h | |
parent | 41d0e2fa96183425eb23d8c5669e3a216d0cea66 (diff) | |
download | gcc-c6dc53f9e2e95295936c970019c8cbd573a8e4f6.zip gcc-c6dc53f9e2e95295936c970019c8cbd573a8e4f6.tar.gz gcc-c6dc53f9e2e95295936c970019c8cbd573a8e4f6.tar.bz2 |
Add a recursion-limit when resolving Parameter Types
This limit is likely way too low but its ok for now to get decent
backtraces for the test-cases we are working with right now.
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 551e041..396cb10 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -367,6 +367,9 @@ public: void visit (const TyTy::ParamType ¶m) override { + recursion_count++; + rust_assert (recursion_count < kDefaultRecusionLimit); + param.resolve ()->accept_vis (*this); } @@ -670,12 +673,16 @@ public: private: TyTyResolveCompile (Context *ctx, bool trait_object_mode) - : ctx (ctx), trait_object_mode (trait_object_mode), translated (nullptr) + : ctx (ctx), trait_object_mode (trait_object_mode), translated (nullptr), + recursion_count (0) {} Context *ctx; bool trait_object_mode; ::Btype *translated; + size_t recursion_count; + + static const size_t kDefaultRecusionLimit = 5; }; } // namespace Compile |