Skip to content

Commit 6dc297f

Browse files
author
Daniel Kroening
committed
use __CPROVER_size_t and __CPROVER_ssize_t for __CPROVER_POINTER_OBJECT/OFFSET
1 parent bfe3d3d commit 6dc297f

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/ansi-c/ansi_c_internal_additions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Author: Daniel Kroening, kroening@kroening.com
88

99
#include "ansi_c_internal_additions.h"
1010

11+
#include <util/c_types.h>
1112
#include <util/config.h>
1213

1314
#include <linking/static_lifetime_init.h>
@@ -126,6 +127,8 @@ void ansi_c_internal_additions(std::string &code)
126127
code+=
127128
"# 1 \"<built-in-additions>\"\n"
128129
"typedef __typeof__(sizeof(int)) __CPROVER_size_t;\n"
130+
"typedef "+c_type_as_string(signed_size_type().get(ID_C_c_type))+
131+
" __CPROVER_ssize_t;\n"
129132
"const unsigned __CPROVER_constant_infinity_uint;\n"
130133
"typedef void __CPROVER_integer;\n"
131134
"typedef void __CPROVER_rational;\n"

src/ansi-c/cprover_builtin_headers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ void __CPROVER_fence(const char *kind, ...);
3333
void CBMC_trace(int lvl, const char *event, ...);
3434

3535
// pointers
36-
unsigned __CPROVER_POINTER_OBJECT(const void *p);
37-
signed __CPROVER_POINTER_OFFSET(const void *p);
38-
__CPROVER_bool __CPROVER_DYNAMIC_OBJECT(const void *p);
36+
__CPROVER_size_t __CPROVER_POINTER_OBJECT(const void *);
37+
__CPROVER_ssize_t __CPROVER_POINTER_OFFSET(const void *);
38+
__CPROVER_bool __CPROVER_DYNAMIC_OBJECT(const void *);
3939
void __CPROVER_allocated_memory(__CPROVER_size_t address, __CPROVER_size_t extent);
4040

4141
// float stuff

src/cpp/cpp_internal_additions.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Author: Daniel Kroening, kroening@kroening.com
1010

1111
#include <ostream>
1212

13+
#include <util/c_types.h>
1314
#include <util/config.h>
1415

1516
#include <ansi-c/ansi_c_internal_additions.h>
@@ -64,7 +65,11 @@ void cpp_internal_additions(std::ostream &out)
6465

6566
// types
6667
out << "typedef __typeof__(sizeof(int)) __CPROVER::size_t;" << '\n';
67-
out << "typedef __typeof__(sizeof(int)) __CPROVER_size_t;" << '\n';
68+
out << "typedef __CPROVER::size_t __CPROVER_size_t;" << '\n';
69+
out << "typedef "
70+
<< c_type_as_string(signed_size_type().get(ID_C_c_type))
71+
<< " __CPROVER::ssize_t;" << '\n';
72+
out << "typedef __CPROVER::ssize_t __CPROVER_ssize_t;" << '\n';
6873

6974
// assume/assert
7075
out << "extern \"C\" void assert(bool assertion);" << '\n';
@@ -85,8 +90,8 @@ void cpp_internal_additions(std::ostream &out)
8590
out << "extern \"C\" void __CPROVER::atomic_end();" << '\n';
8691

8792
// pointers
88-
out << "extern \"C\" unsigned __CPROVER_POINTER_OBJECT(const void *p);\n";
89-
out << "extern \"C\" signed __CPROVER_POINTER_OFFSET(const void *p);" << '\n';
93+
out << "extern \"C\" __CPROVER::size_t __CPROVER_POINTER_OBJECT(const void *);\n";
94+
out << "extern \"C\" __CPROVER::ssize_t __CPROVER_POINTER_OFFSET(const void *);" << '\n';
9095
out << "extern \"C\" bool __CPROVER_DYNAMIC_OBJECT(const void *p);" << '\n';
9196
// NOLINTNEXTLINE(whitespace/line_length)
9297
out << "extern \"C\" extern unsigned char __CPROVER_memory[__CPROVER::constant_infinity_uint];" << '\n';

0 commit comments

Comments
 (0)