]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Fix crash in privay reporter for placeholder types
authorPhilip Herron <herron.philip@googlemail.com>
Mon, 3 Feb 2025 15:14:48 +0000 (15:14 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Mar 2025 12:07:01 +0000 (13:07 +0100)
This guards against a crash but i think this should actually be treated
as if its a generic type like below. But for now this addresses a crash which can occur.

gcc/rust/ChangeLog:

* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_base_type_privacy):
Add guard for placeholder

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc

index dcc768ffff1a98973de8c846704c3ebc344bb505..896c1c449ab1c986bb95e1a2b8d002202c68b3ae 100644 (file)
@@ -243,10 +243,12 @@ PrivacyReporter::check_base_type_privacy (Analysis::NodeMapping &node_mappings,
           static_cast<const TyTy::TupleType *> (ty)->get_fields ())
        recursive_check (param.get_tyty ());
       return;
-    case TyTy::PLACEHOLDER:
-      return recursive_check (
-       // FIXME: Can we use `resolve` here? Is that what we should do?
-       static_cast<const TyTy::PlaceholderType *> (ty)->resolve ());
+      case TyTy::PLACEHOLDER: {
+       const auto p = static_cast<const TyTy::PlaceholderType *> (ty);
+       if (!p->can_resolve ())
+         return;
+       return recursive_check (p->resolve ());
+      }
     case TyTy::PROJECTION:
       return recursive_check (
        static_cast<const TyTy::ProjectionType *> (ty)->get ());