- if (! (l->action_props.is_value_used
- || !symbol_should_be_used (l)
- /* The default action, $$ = $1, `uses' both. */
- || (!r->action_props.code && (n == 0 || n == 1))))
- {
- if (n)
- warn_at (r->location, _("unused value: $%d"), n);
- else
- warn_at (r->location, _("unset value: $$"));
- }
+ {
+ bool midrule_warning = false;
+ if (!l->action_props.is_value_used
+ && symbol_should_be_used (l, &midrule_warning)
+ /* The default action, $$ = $1, `uses' both. */
+ && (r->action_props.code || (n != 0 && n != 1)))
+ {
+ void (*warn_at_ptr)(location, char const*, ...) =
+ midrule_warning ? midrule_value_at : warn_at;
+ if (n)
+ warn_at_ptr (r->location, _("unused value: $%d"), n);
+ else
+ warn_at_ptr (r->location, _("unset value: $$"));
+ }
+ }