// Check for division by zero.
if (isDiv &&
rex->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull))
- Diag(Loc, diag::warn_division_by_zero) << rex->getSourceRange();
+ DiagRuntimeBehavior(Loc, PDiag(diag::warn_division_by_zero)
+ << rex->getSourceRange());
return compType;
}
// Check for remainder by zero.
if (rex->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull))
- Diag(Loc, diag::warn_remainder_by_zero) << rex->getSourceRange();
+ DiagRuntimeBehavior(Loc, PDiag(diag::warn_remainder_by_zero)
+ << rex->getSourceRange());
return compType;
}
x = x % 0; // expected-warning {{remainder by zero is undefined}}
x /= 0; // expected-warning {{division by zero is undefined}}
x %= 0; // expected-warning {{remainder by zero is undefined}}
+
+ x = sizeof(x/0); // no warning.
}
template<int I, int J>
struct BitfieldDivide {
int bitfield : I / J; // expected-error{{expression is not an integer constant expression}} \
- // expected-note{{division by zero}} \
- // expected-warning {{division by zero is undefined}}
+ // expected-note{{division by zero}}
};
void test_BitfieldDivide() {
template<typename T, T Divisor>
class X {
public:
- static const T value = 10 / Divisor; // expected-error{{in-class initializer is not an integral constant expression}} expected-warning {{division by zero is undefined}}
+ static const T value = 10 / Divisor; // expected-error{{in-class initializer is not an integral constant expression}}
};
int array1[X<int, 2>::value == 5? 1 : -1];