Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions clang/lib/AST/ByteCode/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1132,13 +1132,14 @@ bool CMP3(InterpState &S, CodePtr OpPC, const ComparisonCategoryInfo *CmpInfo) {
const Pointer &P = S.Stk.peek<Pointer>();

ComparisonCategoryResult CmpResult = LHS.compare(RHS);
if (CmpResult == ComparisonCategoryResult::Unordered) {
// This should only happen with pointers.
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
<< LHS.toDiagnosticString(S.getASTContext())
<< RHS.toDiagnosticString(S.getASTContext());
return false;
if constexpr (std::is_same_v<T, Pointer>) {
if (CmpResult == ComparisonCategoryResult::Unordered) {
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
<< LHS.toDiagnosticString(S.getASTContext())
<< RHS.toDiagnosticString(S.getASTContext());
return false;
}
}

assert(CmpInfo);
Expand Down
2 changes: 2 additions & 0 deletions clang/test/AST/ByteCode/cxx20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,8 @@ namespace ThreeWayCmp {
constexpr int k = (1 <=> 1, 0); // both-warning {{comparison result unused}}
static_assert(k== 0, "");

static_assert(__builtin_nanf("") <=> __builtin_nanf("") == -127, "");

/// Pointers.
constexpr int a[] = {1,2,3};
constexpr int b[] = {1,2,3};
Expand Down