diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-02-03 15:14:48 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2025-02-03 20:35:50 +0000 |
commit | 842c1cf95d6e731e72449b36539d85624fa77161 (patch) | |
tree | c2c930aae1be2f48305201ee0e232f1ee09b2937 /gcc | |
parent | 12e9f5d02a0da7c98d8a5de9a2036b8930802e5e (diff) | |
download | gcc-842c1cf95d6e731e72449b36539d85624fa77161.zip gcc-842c1cf95d6e731e72449b36539d85624fa77161.tar.gz gcc-842c1cf95d6e731e72449b36539d85624fa77161.tar.bz2 |
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.philip@googlemail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc | 10 |
1 files 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 9c9f2cf..77b03f5 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 ()); |