Skip to content

Commit e24faec

Browse files
authored
Merge pull request #5642 from tautschnig/fix-error-message
Print meaningful error message when trying to use undeclared uninterpreted functions
2 parents 839f0f0 + 426a813 commit e24faec

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
uninterpreted.c
3+
4+
missing type information required to construct call to uninterpreted function
5+
^EXIT=70$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
^Invariant check failed$
10+
--
11+
Test to confirm that an actionable error message is provided.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <assert.h>
2+
3+
int main()
4+
{
5+
int x;
6+
assert(__CPROVER_uninterpreted_fn(x) == __CPROVER_uninterpreted_fn(x));
7+
return 0;
8+
}
9+
10+
int __CPROVER_uninterpreted_fn(int x);

src/goto-programs/builtin_functions.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,15 @@ void goto_convertt::do_function_call_symbol(
892892
if(lhs.is_nil())
893893
return;
894894

895+
if(function.type().get_bool(ID_C_incomplete))
896+
{
897+
error().source_location = function.find_source_location();
898+
error() << "'" << identifier << "' is not declared, "
899+
<< "missing type information required to construct call to "
900+
<< "uninterpreted function" << eom;
901+
throw 0;
902+
}
903+
895904
const code_typet &function_call_type = to_code_type(function.type());
896905
mathematical_function_typet::domaint domain;
897906
for(const auto &parameter : function_call_type.parameters())

0 commit comments

Comments
 (0)