[clang][bytecode] Reject float-to-int casts on non-numbers (#193968)
This commit is contained in:
@@ -2785,6 +2785,12 @@ template <PrimType Name, class T = typename PrimConv<Name>::T>
|
||||
bool CastIntegralFloating(InterpState &S, CodePtr OpPC,
|
||||
const llvm::fltSemantics *Sem, uint32_t FPOI) {
|
||||
const T &From = S.Stk.pop<T>();
|
||||
|
||||
if constexpr (isIntegralOrPointer<T>()) {
|
||||
if (!From.isNumber())
|
||||
return false;
|
||||
}
|
||||
|
||||
APSInt FromAP = From.toAPSInt();
|
||||
|
||||
FPOptions FPO = FPOptions::getFromOpaqueInt(FPOI);
|
||||
|
||||
@@ -449,3 +449,5 @@ void strcpyDouble(void) {
|
||||
|
||||
int *iptr;
|
||||
void ignoredConditional(void) { *iptr = (((_Complex double)1.0 ? 2 : 3), a); } // all-warning {{left operand of comma operator has no effect}}
|
||||
|
||||
float r = (float) (intptr_t) &r; // all-error {{initializer element is not a compile-time constant}}
|
||||
|
||||
Reference in New Issue
Block a user