Skip to content

Commit caee97f

Browse files
committed
Print function & parameter in convert_function errors
1 parent ce2680b commit caee97f

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/goto-programs/goto_convert_functions.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,36 @@ void goto_convert_functionst::convert_function(
163163
symbol.is_compiled()) /* goto_inline may have removed the body */
164164
return;
165165

166+
const size_t ERROR_MSG_LEN = 512;
167+
char parameter_error_message[ERROR_MSG_LEN];
166168
// we have a body, make sure all parameter names are valid
167169
for(const auto &p : f.parameter_identifiers)
168170
{
169-
DATA_INVARIANT(!p.empty(), "parameter identifier should not be empty");
171+
if (p.empty())
172+
{
173+
snprintf(parameter_error_message,
174+
ERROR_MSG_LEN - 1,
175+
"parameter identifier should not be empty\n"
176+
"function: %s\n"
177+
"parameter: %s",
178+
identifier.c_str(),
179+
p.c_str());
180+
}
181+
DATA_INVARIANT(!p.empty(), parameter_error_message);
182+
183+
if (!symbol_table.has_symbol(p))
184+
{
185+
snprintf(parameter_error_message,
186+
ERROR_MSG_LEN - 1,
187+
"parameter identifier must be a known symbol\n"
188+
"function: %s\n"
189+
"parameter: %s",
190+
identifier.c_str(),
191+
p.c_str());
192+
}
170193
DATA_INVARIANT(
171194
symbol_table.has_symbol(p),
172-
"parameter identifier must be a known symbol");
195+
parameter_error_message);
173196
}
174197

175198
lifetimet parent_lifetime = lifetime;

0 commit comments

Comments
 (0)