diff options
author | Philip Herron <herron.philip@googlemail.com> | 2023-02-26 22:36:20 +0000 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:18:59 +0100 |
commit | 4306bf12227d62ebcb8b2d9c3d570be8e4b767ff (patch) | |
tree | 4415a5abe4560b96f4cfe66aa0545ac4bde2aa86 /gcc | |
parent | d43bc24b0aed965d6c2c13b94f2e3414f2e88671 (diff) | |
download | gcc-4306bf12227d62ebcb8b2d9c3d570be8e4b767ff.zip gcc-4306bf12227d62ebcb8b2d9c3d570be8e4b767ff.tar.gz gcc-4306bf12227d62ebcb8b2d9c3d570be8e4b767ff.tar.bz2 |
gccrs: Fix ICE in ADTType::is_concrete
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty.cc (ADTType::is_concrete): need to consider if is a num_variant
* typecheck/rust-tyty.h: refactor to cc file
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.cc | 24 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.h | 18 |
2 files changed, 25 insertions, 17 deletions
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index a1f4911..dc7a08f 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -1111,6 +1111,30 @@ ADTType::as_string () const } bool +ADTType::is_concrete () const +{ + if (is_unit ()) + { + return !needs_substitution (); + } + + for (auto &variant : variants) + { + bool is_num_variant + = variant->get_variant_type () == VariantDef::VariantType::NUM; + if (is_num_variant) + continue; + + for (auto &field : variant->get_fields ()) + { + if (!field->is_concrete ()) + return false; + } + } + return true; +} + +bool ADTType::can_eq (const BaseType *other, bool emit_errors) const { ADTCmp r (this, emit_errors); diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index ddc3463..5516cd7 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -604,23 +604,7 @@ public: return identifier + subst_as_string (); } - bool is_concrete () const override final - { - if (is_unit ()) - { - return !needs_substitution (); - } - - for (auto &variant : variants) - { - for (auto &field : variant->get_fields ()) - { - if (!field->is_concrete ()) - return false; - } - } - return true; - } + bool is_concrete () const override final; BaseType *clone () const final override; BaseType *monomorphized_clone () const final override; |