Skip to content

Commit

Permalink
Add missing hash specialization for new enums and avoid using non-p…
Browse files Browse the repository at this point in the history
…ortable `hasValue` on `optional`. (chapel-lang#23729)

Tests under GCC 5.4 failed because that version of GCC doesn't
auto-specialize hash for enums, and I added two enums in my `canPass` PR
(chapel-lang#23709). This PR adds the missing specializations. It also replaces a
call to `hasValue` (which doesn't work in all compile-time configs since
Chapel's optionals are either `std::optional` or `llvm::Optional`) with
a cast to bool, which works with both.

Reviewed by @riftEmber -- thanks!

## Testing
- [x] compiles with GCC 5.4
- [x] paratest
  • Loading branch information
DanilaFe authored Oct 28, 2023
2 parents 81ee17e + 29941be commit db99551
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/include/chpl/resolution/can-pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class CanPassResult {
bool passes() { return !failReason_; }

PassingFailureReason reason() {
CHPL_ASSERT(failReason_.hasValue());
CHPL_ASSERT((bool) failReason_);
return *failReason_;
}

Expand Down
13 changes: 13 additions & 0 deletions frontend/include/chpl/resolution/resolution-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,19 @@ template<> struct hash<chpl::resolution::TypedFnSignature::WhereClauseResult>
}
};

template<> struct hash<chpl::resolution::CandidateFailureReason>
{
size_t operator()(const chpl::resolution::CandidateFailureReason& key) const {
return (size_t) key;
}
};

template<> struct hash<chpl::resolution::PassingFailureReason>
{
size_t operator()(const chpl::resolution::PassingFailureReason& key) const {
return (size_t) key;
}
};


} // end namespace std
Expand Down

0 comments on commit db99551

Please sign in to comment.