https://gcc.gnu.org/g:ea913186d45967d6a4fa29c5b9a7833eeeee5770

commit r15-8779-gea913186d45967d6a4fa29c5b9a7833eeeee5770
Author: Philip Herron <herron.phi...@googlemail.com>
Date:   Mon Feb 3 15:14:48 2025 +0000

    gccrs: Fix crash in privay reporter for placeholder types
    
    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.phi...@googlemail.com>

Diff:
---
 gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc 
b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc
index dcc768ffff1a..896c1c449ab1 100644
--- a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc
+++ b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc
@@ -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 ());

Reply via email to