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

snc: new option +p, if not active, throw error if pv function is called with multi-PV array

parent 4573cd05
No related branches found
No related tags found
No related merge requests found
...@@ -660,7 +660,6 @@ static void gen_pv_func( ...@@ -660,7 +660,6 @@ static void gen_pv_func(
uint num_extra_parms = 0; uint num_extra_parms = 0;
ap = ep->func_args; ap = ep->func_args;
/* first parameter is always */
if (ap == 0) if (ap == 0)
{ {
error_at_expr(ep, error_at_expr(ep,
...@@ -671,6 +670,16 @@ static void gen_pv_func( ...@@ -671,6 +670,16 @@ static void gen_pv_func(
if (ap->type == E_VAR) if (ap->type == E_VAR)
{ {
vp = ap->extra.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) else if (ap->type == E_SUBSCR)
{ {
......
...@@ -182,6 +182,9 @@ static void parse_option(char *s) ...@@ -182,6 +182,9 @@ static void parse_option(char *s)
case 'm': case 'm':
options.main = opt_val; options.main = opt_val;
break; break;
case 'p':
options.newpv = opt_val;
break;
case 's': case 's':
options.safe = opt_val; options.safe = opt_val;
break; break;
......
...@@ -70,9 +70,10 @@ struct options ...@@ -70,9 +70,10 @@ struct options
uint line:1; /* generate line markers */ uint line:1; /* generate line markers */
uint warn:1; /* compiler warnings */ uint warn:1; /* compiler warnings */
uint xwarn:1; /* extra 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 */ struct state_options /* run-time state options */
{ {
......
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