minix/external/bsd/llvm/dist/clang/test/SemaCXX/warn-div-or-rem-by-zero.cpp
Lionel Sambuc f4a2713ac8 Importing netbsd clang -- pristine
Change-Id: Ia40e9ffdf29b5dab2f122f673ff6802a58bc690f
2014-07-28 17:05:57 +02:00

21 lines
1 KiB
C++

// RUN: %clang_cc1 -verify %s
// RUN: %clang_cc1 -std=c++11 -verify %s
// RUN: %clang_cc1 -std=c++1y -verify %s
void div() {
(void)(42 / 0); // expected-warning{{division by zero is undefined}}
(void)(42 / false); // expected-warning{{division by zero is undefined}}
(void)(42 / !1); // expected-warning{{division by zero is undefined}}
(void)(42 / (1 - 1)); // expected-warning{{division by zero is undefined}}
(void)(42 / !(1 + 1)); // expected-warning{{division by zero is undefined}}
(void)(42 / (int)(0.0)); // expected-warning{{division by zero is undefined}}
}
void rem() {
(void)(42 % 0); // expected-warning{{remainder by zero is undefined}}
(void)(42 % false); // expected-warning{{remainder by zero is undefined}}
(void)(42 % !1); // expected-warning{{remainder by zero is undefined}}
(void)(42 % (1 - 1)); // expected-warning{{remainder by zero is undefined}}
(void)(42 % !(1 + 1)); // expected-warning{{remainder by zero is undefined}}
(void)(42 % (int)(0.0)); // expected-warning{{remainder by zero is undefined}}
}