mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 05:13:04 +00:00
fixits: suggest running --update if there are fixits
* src/fixits.h, src/fixits.c (fixits_empty): New. * src/complain.c (deprecated_directive): Register the Wdeprecated fixits only if -Wdeprecated was enabled, so that we don't apply updates if the user didn't ask for them. * src/main.c (main): If there were fixits, issue a warning suggesting running with --update. Free uniqstrs after the fixits, since the latter use the former. * tests/headers.at, tests/input.at: Update expectations.
This commit is contained in:
@@ -394,7 +394,9 @@ deprecated_directive (location const *loc, char const *old, char const *upd)
|
||||
complain (loc, Wdeprecated,
|
||||
_("deprecated directive: %s, use %s"),
|
||||
quote (old), quote_n (1, upd));
|
||||
fixits_register (loc, upd);
|
||||
/* Register updates only if -Wdeprecated is enabled. */
|
||||
if (warnings_flag[warning_deprecated] != severity_disabled)
|
||||
fixits_register (loc, upd);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -91,6 +91,13 @@ fixits_register (location const *loc, char const* fix)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
fixits_empty (void)
|
||||
{
|
||||
return !fixits;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fixits_run (void)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,9 @@ void fixits_register (location const *loc, char const* update);
|
||||
/* Apply the fixits: update the source file. */
|
||||
void fixits_run (void);
|
||||
|
||||
/* Whether there are no fixits. */
|
||||
bool fixits_empty (void);
|
||||
|
||||
/* Free the registered fixits. */
|
||||
void fixits_free (void);
|
||||
|
||||
|
||||
20
src/main.c
20
src/main.c
@@ -103,12 +103,6 @@ main (int argc, char *argv[])
|
||||
reader ();
|
||||
timevar_pop (tv_reader);
|
||||
|
||||
/* Fix input file now, even if there are errors: that's less
|
||||
warnings in the following runs. */
|
||||
if (update_flag)
|
||||
fixits_run ();
|
||||
fixits_free ();
|
||||
|
||||
if (complaint_status == status_complaint)
|
||||
goto finish;
|
||||
|
||||
@@ -217,7 +211,6 @@ main (int argc, char *argv[])
|
||||
contains things such as user actions, prologue, epilogue etc. */
|
||||
gram_scanner_free ();
|
||||
muscle_free ();
|
||||
uniqstrs_free ();
|
||||
code_scanner_free ();
|
||||
skel_scanner_free ();
|
||||
quotearg_free ();
|
||||
@@ -234,5 +227,18 @@ main (int argc, char *argv[])
|
||||
|
||||
cleanup_caret ();
|
||||
|
||||
/* Fix input file now, even if there are errors: that's less
|
||||
warnings in the following runs. */
|
||||
if (!fixits_empty ())
|
||||
{
|
||||
if (update_flag)
|
||||
fixits_run ();
|
||||
else
|
||||
complain (NULL, Wother,
|
||||
_("fix-its can be applied. Rerun with option '--update'."));
|
||||
fixits_free ();
|
||||
}
|
||||
uniqstrs_free ();
|
||||
|
||||
return complaint_status ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user