aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-02-26 22:36:20 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:18:59 +0100
commit4306bf12227d62ebcb8b2d9c3d570be8e4b767ff (patch)
tree4415a5abe4560b96f4cfe66aa0545ac4bde2aa86
parentd43bc24b0aed965d6c2c13b94f2e3414f2e88671 (diff)
downloadgcc-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
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc24
-rw-r--r--gcc/rust/typecheck/rust-tyty.h18
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;