Skip to content

Commit c506da5

Browse files
author
Daniel Kroening
committed
pointer types now have width
1 parent 8400c8f commit c506da5

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/ansi-c/ansi_c_convert_type.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ void ansi_c_convert_typet::read_rec(const typet &type)
216216
{
217217
c_storage_spec.alias=type.subtype().get(ID_value);
218218
}
219+
else if(type.id()==ID_pointer)
220+
{
221+
// pointers have a width, much like integers
222+
pointer_typet tmp=to_pointer_type(type);
223+
tmp.set_width(config.ansi_c.pointer_width);
224+
other.push_back(tmp);
225+
}
219226
else
220227
other.push_back(type);
221228
}

src/ansi-c/c_typecheck_type.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ void c_typecheck_baset::typecheck_type(typet &type)
7676
else if(type.id()==ID_array)
7777
typecheck_array_type(to_array_type(type));
7878
else if(type.id()==ID_pointer)
79+
{
7980
typecheck_type(type.subtype());
81+
INVARIANT(!type.get(ID_width).empty(), "pointers must have width");
82+
}
8083
else if(type.id()==ID_struct ||
8184
type.id()==ID_union)
8285
typecheck_compound_type(to_struct_union_type(type));

src/util/c_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,12 @@ signedbv_typet pointer_diff_type()
295295

296296
pointer_typet pointer_type(const typet &subtype)
297297
{
298-
return pointer_typet(subtype);
298+
return pointer_typet(subtype, config.ansi_c.pointer_width);
299299
}
300300

301301
reference_typet reference_type(const typet &subtype)
302302
{
303-
return reference_typet(subtype);
303+
return reference_typet(subtype, config.ansi_c.pointer_width);
304304
}
305305

306306
typet void_type()

0 commit comments

Comments
 (0)