File tree Expand file tree Collapse file tree 2 files changed +67
-0
lines changed
tests/regression/82-bitfield Expand file tree Collapse file tree 2 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -79,5 +79,9 @@ int main() {
7979 __goblint_check (0 ); // NOWARN (unreachable)
8080 }
8181
82+ // Check power of two formula
83+ int a = 16 ;
84+ __goblint_assert ((a & (a - 1 )) == 0 ); // SUCCESS
85+
8286 return 0 ;
8387}
Original file line number Diff line number Diff line change 1+ // PARAM: --disable ana.int.interval --disable ana.int.def_exc --enable ana.int.bitfield
2+ #include <goblint.h>
3+
4+ void basic_join () {
5+ int a = 8 ;
6+ int b = 10 ;
7+
8+ int c ;
9+ if (rand ()) {
10+ c = a ;
11+ } else {
12+ c = b ;
13+ }
14+ // c should be 0b0000.0000.0000.0000.0000.0000.0000.010?0
15+
16+ int definite_ones = 8 ; // 0b0000.0000.0000.0000.0000.0000.0000.1000
17+ int definite_zeros = -11 ; // 0b1111.1111.1111.1111.1111.1111.1111.0101
18+
19+ __goblint_assert ((c & definite_ones ) == definite_ones ); // SUCCESS
20+ __goblint_assert ((~c & definite_zeros ) == definite_zeros ); // SUCCESS
21+ }
22+
23+ void join_with_cast () {
24+ int a = 511 ;
25+ char b = 10 ;
26+
27+ unsigned char c ;
28+ if (rand ()) {
29+ c = a ;
30+ } else {
31+ c = b ;
32+ }
33+ // c should be 0b????.1?1?
34+
35+ char definite_ones = 10 ; // 0b0000.1010
36+ char definite_zeros = 0 ; // 0b0000.0000
37+
38+ __goblint_assert ((c & definite_ones ) == definite_ones ); // SUCCESS
39+ __goblint_assert ((~c & definite_zeros ) == definite_zeros ); // SUCCESS
40+ }
41+
42+ void join_loop () {
43+ unsigned char a = 16 ;
44+
45+ while (a < 128 ) {
46+ a *= 2 ;
47+ }
48+ // a should be 0b????.0000
49+
50+ char definite_ones = 0 ; // 0b0000.0000
51+ char definite_zeros = 15 ; // 0b0000.1111
52+
53+ __goblint_assert ((a & definite_ones ) == definite_ones ); // SUCCESS
54+ __goblint_assert ((~a & definite_zeros ) == definite_zeros ); // SUCCESS
55+ }
56+
57+ int main () {
58+ basic_join ();
59+ join_with_cast ();
60+ join_loop ();
61+
62+ return 0 ;
63+ }
You can’t perform that action at this time.
0 commit comments