From 5a9184ebfc08042a2d1e6d6970198f05f6f34ed7 Mon Sep 17 00:00:00 2001 From: "benjamin.franksen" <benjamin.franksen@helmholtz-berlin.de> Date: Fri, 4 Oct 2013 01:53:41 +0000 Subject: [PATCH] snc: new option +p, if not active, throw error if pv function is called with multi-PV array --- src/snc/gen_ss_code.c | 11 ++++++++++- src/snc/main.c | 3 +++ src/snc/types.h | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/snc/gen_ss_code.c b/src/snc/gen_ss_code.c index 1392f93d..eaba2db3 100644 --- a/src/snc/gen_ss_code.c +++ b/src/snc/gen_ss_code.c @@ -660,7 +660,6 @@ static void gen_pv_func( uint num_extra_parms = 0; ap = ep->func_args; - /* first parameter is always */ if (ap == 0) { error_at_expr(ep, @@ -671,6 +670,16 @@ static void gen_pv_func( if (ap->type == E_VAR) { vp = ap->extra.e_var; + if (vp->assign == M_MULTI && !global_options.newpv) + { + 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; + } } else if (ap->type == E_SUBSCR) { diff --git a/src/snc/main.c b/src/snc/main.c index e5cdb121..154c120d 100644 --- a/src/snc/main.c +++ b/src/snc/main.c @@ -182,6 +182,9 @@ static void parse_option(char *s) case 'm': options.main = opt_val; break; + case 'p': + options.newpv = opt_val; + break; case 's': options.safe = opt_val; break; diff --git a/src/snc/types.h b/src/snc/types.h index ed86ddbe..4ccf9427 100644 --- a/src/snc/types.h +++ b/src/snc/types.h @@ -70,9 +70,10 @@ struct options uint line:1; /* generate line markers */ uint warn:1; /* compiler warnings */ uint xwarn:1; /* extra compiler warnings */ + uint newpv:1; /* multi pv mode for builtin functions */ }; -#define DEFAULT_OPTIONS {0,1,0,0,0,1,0,1,1,0} +#define DEFAULT_OPTIONS {0,1,0,0,0,1,0,1,1,0,0} struct state_options /* run-time state options */ { -- GitLab