[clang][bytecode] Diagnose comparisons of unrelated zero-sized pointers (#140695)
This commit is contained in:
parent
f62c379f71
commit
67440f0b83
@ -1135,6 +1135,14 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
|
||||
}
|
||||
}
|
||||
|
||||
if (LHS.isUnknownSizeArray() && RHS.isUnknownSizeArray()) {
|
||||
const SourceInfo &Loc = S.Current->getSource(OpPC);
|
||||
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_zero_sized)
|
||||
<< LHS.toDiagnosticString(S.getASTContext())
|
||||
<< RHS.toDiagnosticString(S.getASTContext());
|
||||
return false;
|
||||
}
|
||||
|
||||
S.Stk.push<BoolT>(BoolT::from(Fn(ComparisonCategoryResult::Unordered)));
|
||||
return true;
|
||||
}
|
||||
|
@ -243,3 +243,10 @@ namespace Volatile {
|
||||
// both-note {{in call to 'f(0)'}}
|
||||
};
|
||||
}
|
||||
|
||||
namespace ZeroSizeCmp {
|
||||
extern void (*start[])();
|
||||
extern void (*end[])();
|
||||
static_assert(&start != &end, ""); // both-error {{constant expression}} \
|
||||
// both-note {{comparison of pointers '&start' and '&end' to unrelated zero-sized objects}}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user