Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions regression/ansi-c/gcc_builtins_address_of/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifdef __GNUC__

int main()
{
void (*f)(int) = __builtin_exit;
int (*g)(float) = __builtin_isnanf;
int (*h)(int) = __builtin_ffs;
void *(*m)(__SIZE_TYPE__) = __builtin_malloc;
void *(*c)(void *, const void *, __SIZE_TYPE__) = __builtin_memcpy;
(void)g(3.14f);
(void)h(42);
f(1);
return 0;
}

#else

int main()
{
}

#endif
8 changes: 8 additions & 0 deletions regression/ansi-c/gcc_builtins_address_of/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE gcc-only
main.c

^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
^CONVERSION ERROR$
Comment on lines +6 to +8
8 changes: 8 additions & 0 deletions regression/cbmc-library/__builtin_exit/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <assert.h>

int main()
{
__builtin_exit(0);
assert(0);
return 0;
}
8 changes: 8 additions & 0 deletions regression/cbmc-library/__builtin_exit/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE gcc-only
main.c
--pointer-check --bounds-check
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
11 changes: 11 additions & 0 deletions regression/cbmc/gcc_builtins_address_of/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <assert.h>

int main()
{
void (*f)(int) = __builtin_exit;
int (*g)(float) = __builtin_isnanf;
assert(!g(3.14f));
f(1);
assert(0);
return 0;
}
9 changes: 9 additions & 0 deletions regression/cbmc/gcc_builtins_address_of/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE gcc-only
main.c
--pointer-check
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
^CONVERSION ERROR$
Comment on lines +7 to +9
12 changes: 9 additions & 3 deletions src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,9 +884,15 @@ void c_typecheck_baset::typecheck_expr_symbol(exprt &expr)
const symbolt *symbol_ptr;
if(lookup(identifier, symbol_ptr))
{
error().source_location = expr.source_location();
error() << "failed to find symbol '" << identifier << "'" << eom;
throw 0;
// If this is a built-in, try to add it to the symbol table on the fly,
// just like we do for function calls (see
// typecheck_side_effect_function_call).
if(builtin_factory(identifier) || lookup(identifier, symbol_ptr))
{
error().source_location = expr.source_location();
error() << "failed to find symbol '" << identifier << "'" << eom;
throw 0;
}
}

const symbolt &symbol=*symbol_ptr;
Expand Down
8 changes: 8 additions & 0 deletions src/ansi-c/library/stdlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ void exit(int status)
#endif
}

/* FUNCTION: __builtin_exit */

void __builtin_exit(int status)
{
(void)status;
__CPROVER_assume(0);
}
Comment on lines +113 to +117

/* FUNCTION: _Exit */

#undef _Exit
Expand Down
Loading