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

@@ -1301,16 +1301,16 @@ AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y], 0,,
[[input.y:33.3-23: warning: unset value: $$
input.y:30.3-35.37: warning: unused value: $3
input.y:32.3-23: warning: unused value: $3
]])
AT_BISON_CHECK([-fcaret -o input.c input.y], 0,,
[[input.y:33.3-23: warning: unset value: $$
{ @$ = 4; } // Only used.
^^^^^^^^^^^^^^^^^^^^^
input.y:30.3-35.37: warning: unused value: $3
{ @$ = 1; } // Not set or used.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:32.3-23: warning: unused value: $3
{ USE ($$); @$ = 3; } // Only set.
^^^^^^^^^^^^^^^^^^^^^
]])
AT_COMPILE([input])