error: use better locations for unused midrule values

On

  %%
  exp: {;} {$$;} { $$ = $1; }

instead of reporting (with -fcaret -Wmidrule-value)

  midrule.y:2.6-8: warning: unset value: $$ [-Wmidrule-values]
   exp: {;} {$$;} { $$ = $1; }
        ^^^
  midrule.y:2.6-27: warning: unused value: $2 [-Wmidrule-values]
   exp: {;} {$$;} { $$ = $1; }
        ^^^^^^^^^^^^^^^^^^^^^^

report

  midrule.y:2.6-8: warning: unset value: $$
   exp: {;} {$$;} { $$ = $1; }
        ^^^
  midrule.y:2.10-14: warning: unused value: $2
   exp: {;} {$$;} { $$ = $1; }
            ^^^^^

* src/reader.c (grammar_rule_check): When warning about the value of a
midrule action, use the location of the midrule action instead of the
location of the rule.
the location of the part of the rule.
* tests/actions.at (Default %printer and %destructor for mid-rule values):
Adjust expectations
* tests/input.at (Unused values with default %destructor): Ditto.
(AT_CHECK_UNUSED_VALUES): Ditto.
And use -fcaret.
This commit is contained in:
Akim Demaille
2012-12-09 12:06:21 +01:00
parent c949ada3da
commit 235892350f
3 changed files with 111 additions and 44 deletions

View File

@@ -325,9 +325,9 @@ grammar_rule_check (const symbol_list *r)
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);
warn_at_ptr (l->location, _("unused value: $%d"), n);
else
warn_at_ptr (r->location, _("unset value: $$"));
warn_at_ptr (l->location, _("unset value: $$"));
}
}
}