Skip to content

Commit 758d713

Browse files
authored
Merge pull request #5754 from tautschnig/fix-5542
Support c_bool in expr2bits/bits2expr
2 parents 6bc4e78 + 5c5322a commit 758d713

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

regression/cbmc/Bool5/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <assert.h>
2+
#include <string.h>
3+
4+
struct conft
5+
{
6+
_Bool red;
7+
int one;
8+
};
9+
10+
int main()
11+
{
12+
struct conft conf_init = {0, 1};
13+
struct conft my_conf;
14+
memcpy((char *)&my_conf, (char *)&conf_init, sizeof(struct conft));
15+
int num = my_conf.one;
16+
assert(num == 1);
17+
return 0;
18+
}

regression/cbmc/Bool5/test.desc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
4+
Generated 4 VCC\(s\), 0 remaining after simplification
5+
^VERIFICATION SUCCESSFUL$
6+
^EXIT=0$
7+
^SIGNAL=0$
8+
--
9+
^warning: ignoring

src/util/simplify_utils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ optionalt<exprt> bits2expr(
191191
type.id() == ID_unsignedbv || type.id() == ID_signedbv ||
192192
type.id() == ID_floatbv || type.id() == ID_fixedbv ||
193193
type.id() == ID_c_bit_field || type.id() == ID_pointer ||
194-
type.id() == ID_bv)
194+
type.id() == ID_bv || type.id() == ID_c_bool)
195195
{
196196
endianness_mapt map(type, little_endian, ns);
197197

@@ -385,7 +385,8 @@ expr2bits(const exprt &expr, bool little_endian, const namespacet &ns)
385385
if(
386386
type.id() == ID_unsignedbv || type.id() == ID_signedbv ||
387387
type.id() == ID_floatbv || type.id() == ID_fixedbv ||
388-
type.id() == ID_c_bit_field || type.id() == ID_bv)
388+
type.id() == ID_c_bit_field || type.id() == ID_bv ||
389+
type.id() == ID_c_bool)
389390
{
390391
const auto width = to_bitvector_type(type).get_width();
391392

0 commit comments

Comments
 (0)