Skip to content
Snippets Groups Projects
Commit c8239ee1 authored by benjamin.franksen's avatar benjamin.franksen
Browse files

snc: better error messages if pv functions called with multi-PV arrays

We give the hint to use option +p only if the function actually supports
multi-PV arrays. We know this by examining the add_length column in the
builtin function table (functions that support them must add the array
length as implicit argument to the call).
parent af0150cf
No related branches found
No related tags found
No related merge requests found
......@@ -670,15 +670,31 @@ static void gen_pv_func(
if (ap->type == E_VAR)
{
vp = ap->extra.e_var;
if (vp->assign == M_MULTI && !global_options.newpv)
assert(vp);
if (vp->assign == M_MULTI)
{
error_at_expr(ap,
"1st argument '%s' to function '%s' must not be a multi-PV array\n",
vp->name, func_name);
report_at_expr(ap, "Perhaps you meant %s[0]?\n", vp->name);
report_at_expr(ap, "Use option +p to allow this but then "
"pv functions operate on all contained PVs\n");
return;
if (!add_length)
{
error_at_expr(ap,
"passing multi-PV array '%s' to function '%s' is not "
"(yet?) allowed\n",
vp->name, func_name);
return;
}
if (!global_options.newpv)
{
error_at_expr(ap,
"passing multi-PV array '%s' to function '%s' is not "
"allowed in compatibility mode (option -p)\n",
vp->name, func_name);
report_at_expr(ap, "Perhaps you meant to pass '%s[0]'?\n", vp->name);
if (add_length)
{
report_at_expr(ap, "Use option +p to allow this but then "
"pv functions operate on all contained PVs\n");
}
return;
}
}
}
else if (ap->type == E_SUBSCR)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment