Skip to content

Commit 2419eeb

Browse files
committed
Make CPROVER intrinsics proper prototypes
Forward declarations without arguments are deprecated in C. Polymorphic built-ins now have dummy declarations that are only in effect when running library checks. Our own C front-end will type check them properly and won't rely on forward declarations.
1 parent 01ac963 commit 2419eeb

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

src/ansi-c/cprover_builtin_headers.h

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,26 @@ void __CPROVER_precondition(__CPROVER_bool precondition, const char *description
66
void __CPROVER_postcondition(__CPROVER_bool assertion, const char *description);
77
void __CPROVER_havoc_object(void *);
88
void __CPROVER_havoc_slice(void *, __CPROVER_size_t);
9-
__CPROVER_bool __CPROVER_equal();
9+
#ifdef LIBRARY_CHECK
10+
// __CPROVER_equal expects two arguments of the same type -- any type is
11+
// permitted, unsigned long long is just used for the benefit of running syntax
12+
// checks using system compilers
13+
__CPROVER_bool __CPROVER_equal(unsigned long long, unsigned long long);
14+
#endif
1015
__CPROVER_bool __CPROVER_same_object(const void *, const void *);
1116
__CPROVER_bool __CPROVER_is_invalid_pointer(const void *);
1217
_Bool __CPROVER_is_zero_string(const void *);
1318
__CPROVER_size_t __CPROVER_zero_string_length(const void *);
1419
__CPROVER_size_t __CPROVER_buffer_size(const void *);
15-
__CPROVER_bool __CPROVER_r_ok();
16-
__CPROVER_bool __CPROVER_w_ok();
17-
__CPROVER_bool __CPROVER_rw_ok();
20+
__CPROVER_bool __CPROVER_r_ok(void *, __CPROVER_size_t);
21+
__CPROVER_bool __CPROVER_w_ok(void *, __CPROVER_size_t);
22+
__CPROVER_bool __CPROVER_rw_ok(void *, __CPROVER_size_t);
1823

1924
// experimental features for CHC encodings -- do not use
20-
__CPROVER_bool __CPROVER_is_list(); // a singly-linked null-terminated dynamically-allocated list
21-
__CPROVER_bool __CPROVER_is_dll();
22-
__CPROVER_bool __CPROVER_is_cyclic_dll();
23-
__CPROVER_bool __CPROVER_is_sentinel_dll();
25+
__CPROVER_bool __CPROVER_is_list(void *); // a singly-linked null-terminated dynamically-allocated list
26+
__CPROVER_bool __CPROVER_is_dll(void *);
27+
__CPROVER_bool __CPROVER_is_cyclic_dll(void *);
28+
__CPROVER_bool __CPROVER_is_sentinel_dll(void *);
2429
__CPROVER_bool __CPROVER_is_cstring(const char *);
2530
__CPROVER_size_t __CPROVER_cstrlen(const char *);
2631
__CPROVER_bool __CPROVER_separate(const void *, const void *, ...);
@@ -41,8 +46,8 @@ void __CPROVER_output(const char *id, ...);
4146
void __CPROVER_cover(__CPROVER_bool condition);
4247

4348
// concurrency-related
44-
void __CPROVER_atomic_begin();
45-
void __CPROVER_atomic_end();
49+
void __CPROVER_atomic_begin(void);
50+
void __CPROVER_atomic_end(void);
4651
void __CPROVER_fence(const char *kind, ...);
4752

4853
// contract-related functions
@@ -130,15 +135,23 @@ void __CPROVER_k_induction_hint(unsigned min, unsigned max,
130135
// format string-related
131136
int __CPROVER_scanf(const char *, ...);
132137

138+
#ifdef LIBRARY_CHECK
139+
// The following built-ins are type checked by our C front-end and do not
140+
// require declarations. They work with any types as described below. unsigned
141+
// long long is just used to enable checks using system compilers.
133142
// detect overflow
134-
__CPROVER_bool __CPROVER_overflow_minus();
135-
__CPROVER_bool __CPROVER_overflow_mult();
136-
__CPROVER_bool __CPROVER_overflow_plus();
137-
__CPROVER_bool __CPROVER_overflow_shl();
138-
__CPROVER_bool __CPROVER_overflow_unary_minus();
143+
// the following expect two numeric arguments
144+
__CPROVER_bool __CPROVER_overflow_minus(unsigned long long, unsigned long long);
145+
__CPROVER_bool __CPROVER_overflow_mult(unsigned long long, unsigned long long);
146+
__CPROVER_bool __CPROVER_overflow_plus(unsigned long long, unsigned long long);
147+
__CPROVER_bool __CPROVER_overflow_shl(unsigned long long, unsigned long long);
148+
// expects one numeric argument
149+
__CPROVER_bool __CPROVER_overflow_unary_minus(unsigned long long);
139150

140151
// enumerations
141-
__CPROVER_bool __CPROVER_enum_is_in_range();
152+
// expects one enum-typed argument
153+
__CPROVER_bool __CPROVER_enum_is_in_range(unsigned long long);
154+
#endif
142155

143156
// contracts
144157
void __CPROVER_assignable(void *ptr, __CPROVER_size_t size,

0 commit comments

Comments
 (0)