From: Philip Herron Date: Mon, 3 Feb 2025 15:14:48 +0000 (+0000) Subject: gccrs: Fix crash in privay reporter for placeholder types X-Git-Tag: basepoints/gcc-16~774 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea913186d45967d6a4fa29c5b9a7833eeeee5770;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc index dcc768ffff1..896c1c449ab 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 (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 (ty)->resolve ()); + case TyTy::PLACEHOLDER: { + const auto p = static_cast (ty); + if (!p->can_resolve ()) + return; + return recursive_check (p->resolve ()); + } case TyTy::PROJECTION: return recursive_check ( static_cast (ty)->get ());