| 1 |
#include "builtin-arith-overflow.h" |
| 2 |
|
| 3 |
#define TESTS(type, min, max) \ |
| 4 |
ST (100, signed type, 2, 3, 5, U(s, add), 0) \ |
| 5 |
ST (101, signed type, max, -1, max - 1, U(s, add), 0) \ |
| 6 |
ST (102, signed type, max, 0, max, U(s, add), 0) \ |
| 7 |
ST (103, signed type, 1, max, min, U(s, add), 1) \ |
| 8 |
ST (104, signed type, 0, min, min, U(s, sub), 1) \ |
| 9 |
ST (110, signed type, 2, 3, -1, U(s, sub), 0) \ |
| 10 |
ST (111, signed type, max, -1, min, U(s, sub), 1) \ |
| 11 |
ST (112, signed type, max, 0, max, U(s, sub), 0) \ |
| 12 |
ST (113, signed type, 1, max, min + 2, U(s, sub), 0) \ |
| 13 |
ST (114, signed type, max, -1, min, U(s, sub), 1) \ |
| 14 |
ST (120, signed type, 2, 3, 6, U(s, mul), 0) \ |
| 15 |
ST (122, signed type, min, -1, min, U(s, mul), 1) \ |
| 16 |
ST (123, signed type, max, 0, 0, U(s, mul), 0) \ |
| 17 |
ST (124, signed type, 1, max, max, U(s, mul), 0) \ |
| 18 |
ST (125, signed type, max, 2, -2, U(s, mul), 1) \ |
| 19 |
ST (126, signed type, max / 25, 25, max / 25 * 25, U(s, mul), 0) \ |
| 20 |
ST (127, signed type, max / 25 + 1, 25, max / 25 * 25 + (unsigned type) 25, U(s, mul), 1) \ |
| 21 |
ST (150, unsigned type, 2, 3, 5, U(u, add), 0) \ |
| 22 |
ST (151, unsigned type, -1, -1, -2, U(u, add), 1) \ |
| 23 |
ST (152, unsigned type, -1, 0, -1, U(u, add), 0) \ |
| 24 |
ST (153, unsigned type, 1, -1, 0, U(u, add), 1) \ |
| 25 |
ST (154, unsigned type, 0, min, min, U(u, sub), 1) \ |
| 26 |
ST (160, unsigned type, 2, 3, -1, U(u, sub), 1) \ |
| 27 |
ST (161, unsigned type, -1, -1, 0, U(u, sub), 0) \ |
| 28 |
ST (162, unsigned type, -1, 0, -1, U(u, sub), 0) \ |
| 29 |
ST (163, unsigned type, 1, -1, 2, U(u, sub), 1) \ |
| 30 |
ST (164, unsigned type, 15, 14, 1, U(u, sub), 0) \ |
| 31 |
ST (170, unsigned type, 2, 3, 6, U(u, mul), 0) \ |
| 32 |
ST (171, unsigned type, max, 3, 3 * (unsigned type) max, U(u, mul), 1) \ |
| 33 |
ST (172, unsigned type, -1, 0, 0, U(u, mul), 0) \ |
| 34 |
ST (173, unsigned type, 1, -1, -1, U(u, mul), 0) \ |
| 35 |
ST (174, unsigned type, -1, 2, -2, U(u, mul), 1) \ |
| 36 |
ST (175, unsigned type, ((unsigned type) -1) / 25, 25, ((unsigned type) -1) / 25 * 25, U(u, mul), 0) \ |
| 37 |
ST (176, unsigned type, ((unsigned type) -1) / 25 + 1, 25, ((unsigned type) -1) / 25 * 25 + (unsigned type) 25, U(u, mul), 1) |