111
|
1 #include "builtin-arith-overflow.h"
|
|
2
|
|
3 #define TESTS(type, min, max) \
|
|
4 T (100, signed type, unsigned type, unsigned type, -1, 0, 0, mul, 0) \
|
|
5 T (101, signed type, unsigned type, unsigned type, -1, 1, (unsigned type) -1, mul, 1) \
|
|
6 T (102, unsigned type, signed type, unsigned type, 12, -3, (unsigned type) -36, mul, 1) \
|
|
7 T (103, signed type, unsigned type, unsigned type, 3, 4, 12, mul, 0) \
|
|
8 T (104, unsigned type, signed type, unsigned type, (unsigned type) -1 / 12, 12, (unsigned type) -1 / 12 * 12, mul, 0) \
|
|
9 T (105, unsigned type, signed type, unsigned type, (unsigned type) -1 / 12, 13, (unsigned type) -1 / 12 * 13, mul, 1) \
|
|
10 T (106, unsigned type, unsigned type, signed type, 0, 0, 0, mul, 0) \
|
|
11 T (107, unsigned type, unsigned type, signed type, max / 31, 31, (signed type) ((unsigned type) max / 31 * 31), mul, 0) \
|
|
12 T (108, unsigned type, unsigned type, signed type, max / 31, 32, (signed type) ((unsigned type) max / 31 * 32), mul, 1) \
|
|
13 T (109, unsigned type, unsigned type, signed type, max / 31, 65, (signed type) ((unsigned type) max / 31 * 65), mul, 1) \
|
|
14 T (110, signed type, unsigned type, signed type, -1, 7, -7, mul, 0) \
|
|
15 T (111, unsigned type, signed type, signed type, 2, min / 2, min, mul, 0) \
|
|
16 T (112, signed type, unsigned type, signed type, max / 12, 13, (signed type) ((unsigned type) max / 12 * 13), mul, 1) \
|
|
17 T (113, unsigned type, signed type, signed type, (unsigned type) max + 19, 0, 0, mul, 0) \
|
|
18 T (114, signed type, unsigned type, signed type, 0, (unsigned type) max + 1, 0, mul, 0) \
|
|
19 T (115, unsigned type, signed type, signed type, (unsigned type) max + 1, -1, min, mul, 0) \
|
|
20 T (116, signed type, unsigned type, signed type, -1, (unsigned type) max + 2, max, mul, 1) \
|
|
21 T (117, signed type, signed type, unsigned type, min / 64, -64, (unsigned type) min, mul, 0) \
|
|
22 T (118, signed type, signed type, unsigned type, min / 32, -33, ((unsigned type) max + 1) / 32 * 33, mul, 0) \
|
|
23 T (119, signed type, signed type, unsigned type, min / 32, -65, ((unsigned type) max + 1) / 32 * 65, mul, 1) \
|
|
24 T (120, signed type, signed type, unsigned type, -1, -1, 1, mul, 0) \
|
|
25 T (121, signed type, signed type, unsigned type, 0, 0, 0, mul, 0) \
|
|
26 T (122, signed type, signed type, unsigned type, 0, -6, 0, mul, 0) \
|
|
27 T (123, signed type, signed type, unsigned type, -15, 0, 0, mul, 0) \
|
|
28 T (124, signed type, signed type, unsigned type, -1, 1, ~(unsigned type) 0, mul, 1) \
|
|
29 T (125, signed type, signed type, unsigned type, -17, 5, (unsigned type) -17 * 5, mul, 1) \
|
|
30 T (126, signed type, signed type, unsigned type, 7, max / 7, max / 7 * 7, mul, 0) \
|
|
31 T (127, signed type, signed type, unsigned type, max / 7, 8, (unsigned type) max / 7 * 8, mul, 0) \
|
|
32 T (128, signed type, signed type, unsigned type, 15, max / 7, (unsigned type) max / 7 * 15, mul, 1) \
|
|
33 T (129, signed type, unsigned type, signed type, min, 5, min + 5, add, 0) \
|
|
34 T (130, unsigned type, signed type, signed type, ~(unsigned type) 0, min, max, add, 0) \
|
|
35 T (131, signed type, unsigned type, signed type, max, 1, min, add, 1) \
|
|
36 T (132, unsigned type, signed type, signed type, max / 2, max / 2 + 1, max, add, 0) \
|
|
37 T (133, signed type, unsigned type, signed type, max / 2 + 1, max / 2 + 1, min, add, 1) \
|
|
38 T (134, signed type, unsigned type, unsigned type, min, ~(unsigned type) 0, max, add, 0) \
|
|
39 T (135, unsigned type, signed type, unsigned type, ~(unsigned type) 0, min + 1, (unsigned type) max + 1, add, 0) \
|
|
40 T (136, signed type, unsigned type, unsigned type, 1, ~(unsigned type) 0, 0, add, 1) \
|
|
41 T (137, unsigned type, signed type, unsigned type, 2, -3, ~(unsigned type) 0, add, 1) \
|
|
42 T (138, signed type, unsigned type, signed type, min, 1, max, sub, 1) \
|
|
43 T (139, signed type, unsigned type, signed type, min + 1, 1, min, sub, 0) \
|
|
44 T (140, signed type, unsigned type, signed type, max, (unsigned type) max + 1, -1, sub, 0) \
|
|
45 T (141, signed type, unsigned type, signed type, max, ~(unsigned type) 0, min, sub, 0) \
|
|
46 T (142, signed type, unsigned type, signed type, max - 1, ~(unsigned type) 0, max, sub, 1) \
|
|
47 T (143, signed type, unsigned type, unsigned type, -1, 0, ~(unsigned type) 0, sub, 1) \
|
|
48 T (144, signed type, unsigned type, unsigned type, -1, ~(unsigned type) 0, 0, sub, 1) \
|
|
49 T (145, signed type, unsigned type, unsigned type, min, 0, min, sub, 1) \
|
|
50 T (146, signed type, unsigned type, unsigned type, max, max, 0, sub, 0) \
|
|
51 T (147, signed type, unsigned type, unsigned type, max, (unsigned type) max + 1, -1, sub, 1) \
|
|
52 T (148, signed type, unsigned type, unsigned type, max - 1, max, -1, sub, 1) \
|
|
53 T (149, unsigned type, signed type, signed type, 0, max, -max, sub, 0) \
|
|
54 T (150, unsigned type, signed type, signed type, (unsigned type) max + 1, 0, min, sub, 1) \
|
|
55 T (151, unsigned type, signed type, signed type, (unsigned type) max + 1, 1, max, sub, 0) \
|
|
56 T (152, unsigned type, unsigned type, signed type, 0, (unsigned type) max + 1, min, add, 1) \
|
|
57 T (153, signed type, signed type, unsigned type, -1, 0, -1, add, 1) \
|
|
58 T (154, unsigned type, signed type, unsigned type, 5, 6, -1, sub, 1) \
|
|
59 T (155, unsigned type, signed type, unsigned type, ~(unsigned type) 0, max, (unsigned type) max + 1, sub, 0) \
|
|
60 T (156, unsigned type, signed type, unsigned type, (unsigned type) max + 1, min, 0, sub, 1) \
|
|
61 T (157, signed type, signed type, unsigned type, 3, -2, 1, add, 0) \
|
|
62 T (158, signed type, signed type, unsigned type, 3, -4, -1, add, 1) \
|
|
63 T (159, signed type, signed type, unsigned type, -3, -4, -7, add, 1) \
|
|
64 T (160, signed type, signed type, unsigned type, -5, 4, -1, add, 1) \
|
|
65 T (161, signed type, signed type, unsigned type, -5, 5, 0, add, 0) \
|
|
66 T (162, signed type, signed type, unsigned type, min, 1, min + 1, add, 1) \
|
|
67 T (163, unsigned type, unsigned type, signed type, max, 1, min, add, 1) \
|
|
68 T (164, unsigned type, unsigned type, signed type, max - 1, 1, max, add, 0) \
|
|
69 T (165, unsigned type, unsigned type, signed type, ~(unsigned type) 0, ~(unsigned type) 0, ~(unsigned type) 0 - 1, add, 1) \
|
|
70 T (166, unsigned type, unsigned type, signed type, (unsigned type) max + 3, 2, min, sub, 1) \
|
|
71 T (167, unsigned type, unsigned type, signed type, (unsigned type) max + 2, 2, max, sub, 0) \
|
|
72 T (168, unsigned type, unsigned type, signed type, (unsigned type) max + 2, (unsigned type) max + 3, -1, sub, 0) \
|
|
73 T (169, unsigned type, unsigned type, signed type, 0, (unsigned type) max + 1, min, sub, 0) \
|
|
74 T (170, unsigned type, unsigned type, signed type, 0, (unsigned type) max + 2, max, sub, 1) \
|
|
75 T (171, signed type, signed type, unsigned type, 3, 2, 1, sub, 0) \
|
|
76 T (172, signed type, signed type, unsigned type, 3, 4, -1, sub, 1) \
|
|
77 T (173, signed type, signed type, unsigned type, -3, 4, -7, sub, 1) \
|
|
78 T (174, signed type, signed type, unsigned type, -5, -4, -1, sub, 1) \
|
|
79 T (175, signed type, signed type, unsigned type, -5, -5, 0, sub, 0) \
|
|
80 T (176, signed type, signed type, unsigned type, min, -1, min + 1, sub, 1)
|