Loading clang/lib/AST/ByteCode/Interp.h +6 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,12 @@ bool CheckShift(InterpState &S, CodePtr OpPC, const LT &LHS, const RT &RHS, /// Checks if Div/Rem operation on LHS and RHS is valid. template <typename T> bool CheckDivRem(InterpState &S, CodePtr OpPC, const T &LHS, const T &RHS) { if constexpr (isIntegralOrPointer<T>()) { if (!LHS.isNumber() || !RHS.isNumber()) return false; } if (RHS.isZero()) { const auto *Op = cast<BinaryOperator>(S.Current->getExpr(OpPC)); if constexpr (std::is_same_v<T, Floating>) { Loading clang/test/AST/ByteCode/c.c +3 −0 Original line number Diff line number Diff line Loading @@ -455,3 +455,6 @@ float r = (float) (intptr_t) &r; // all-error {{initializer element is not a co void labelAndNull(void) { int bar = &*(void *)0 - &&baz; } // all-error {{use of undeclared label 'baz'}} \\ // pedantic-warning {{use of GNU address-of-label extension}} \ // pedantic-warning {{arithmetic on pointers to void is a GNU extension}} void nonNumberRem(void) { *((int *)0) = (long)foo % 42; } // all-warning {{indirection of non-volatile null pointer will be deleted, not trap}} \ // all-note {{consider using __builtin_trap() or qualifying pointer with 'volatile'}} Loading
clang/lib/AST/ByteCode/Interp.h +6 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,12 @@ bool CheckShift(InterpState &S, CodePtr OpPC, const LT &LHS, const RT &RHS, /// Checks if Div/Rem operation on LHS and RHS is valid. template <typename T> bool CheckDivRem(InterpState &S, CodePtr OpPC, const T &LHS, const T &RHS) { if constexpr (isIntegralOrPointer<T>()) { if (!LHS.isNumber() || !RHS.isNumber()) return false; } if (RHS.isZero()) { const auto *Op = cast<BinaryOperator>(S.Current->getExpr(OpPC)); if constexpr (std::is_same_v<T, Floating>) { Loading
clang/test/AST/ByteCode/c.c +3 −0 Original line number Diff line number Diff line Loading @@ -455,3 +455,6 @@ float r = (float) (intptr_t) &r; // all-error {{initializer element is not a co void labelAndNull(void) { int bar = &*(void *)0 - &&baz; } // all-error {{use of undeclared label 'baz'}} \\ // pedantic-warning {{use of GNU address-of-label extension}} \ // pedantic-warning {{arithmetic on pointers to void is a GNU extension}} void nonNumberRem(void) { *((int *)0) = (long)foo % 42; } // all-warning {{indirection of non-volatile null pointer will be deleted, not trap}} \ // all-note {{consider using __builtin_trap() or qualifying pointer with 'volatile'}}