From c8239ee18fb2f62fc93d86c7cca22e2c0c26f986 Mon Sep 17 00:00:00 2001 From: "benjamin.franksen" <benjamin.franksen@helmholtz-berlin.de> Date: Mon, 7 Oct 2013 14:50:01 +0000 Subject: [PATCH] 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). --- src/snc/gen_ss_code.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/snc/gen_ss_code.c b/src/snc/gen_ss_code.c index eaba2db3..243d50ca 100644 --- a/src/snc/gen_ss_code.c +++ b/src/snc/gen_ss_code.c @@ -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) -- GitLab