xref: /illumos-gate/usr/src/tools/smatch/src/validation/div.c (revision 933ae53f0bf0708d7bf2756d3f21936a0d5fad82)
1 #define	INT_MIN		(-__INT_MAX__ - 1)
2 #define	LONG_MIN	(-__LONG_MAX__ - 1)
3 #define	LLONG_MIN	(-__LONG_LONG_MAX__ - 1)
4 
5 static int xd = 1 / 0;
6 static int xl = 1L / 0;
7 static int xll = 1LL / 0;
8 
9 static int yd = INT_MIN / -1;
10 static long yl = LONG_MIN / -1;
11 static long long yll = LLONG_MIN / -1;
12 
13 static int zd = INT_MIN % -1;
14 static long zl = LONG_MIN % -1;
15 static long long zll = LLONG_MIN % -1;
16 
17 /*
18  * check-name: division constants
19  *
20  * check-error-start
21 div.c:5:19: warning: division by zero
22 div.c:6:20: warning: division by zero
23 div.c:7:22: warning: division by zero
24 div.c:9:25: warning: constant integer operation overflow
25 div.c:10:27: warning: constant integer operation overflow
26 div.c:11:34: warning: constant integer operation overflow
27 div.c:13:25: warning: constant integer operation overflow
28 div.c:14:27: warning: constant integer operation overflow
29 div.c:15:34: warning: constant integer operation overflow
30  * check-error-end
31  */
32