aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-02-26 22:36:20 +0000
committerPhilip Herron <philip.herron@embecosm.com>2023-02-28 20:38:35 +0000
commitfd849953da2d5a39aa311b5e298bb92cd4b25be4 (patch)
tree110d4162bb001b7e5f6ffc5d8b47f17852fca40d /gcc
parentb50b73e3922081d4896cd10216c4c8f89388828f (diff)
downloadgcc-fd849953da2d5a39aa311b5e298bb92cd4b25be4.zip
gcc-fd849953da2d5a39aa311b5e298bb92cd4b25be4.tar.gz
gcc-fd849953da2d5a39aa311b5e298bb92cd4b25be4.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.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 d0d36ac..28d03ce 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 64b9379..05cd3a7 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;