]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Fix ICE in ADTType::is_concrete
authorPhilip Herron <herron.philip@googlemail.com>
Sun, 26 Feb 2023 22:36:20 +0000 (22:36 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:18:59 +0000 (18:18 +0100)
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

gcc/rust/typecheck/rust-tyty.cc
gcc/rust/typecheck/rust-tyty.h

index a1f4911511a717e33e7938f99bdb30b584d7786a..dc7a08f47929f3d12aace2b709a54d3b5859fd17 100644 (file)
@@ -1110,6 +1110,30 @@ ADTType::as_string () const
   return identifier + subst_as_string () + "{" + variants_buffer + "}";
 }
 
+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
 {
index ddc34636ae7323f0c8b6eb47c465c1cc601023ac..5516cd703851999d77934f39640c2eab83b5237c 100644 (file)
@@ -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;