From 03ecd94488b85adc38746ec3e7c2a297a522598e Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 26 Feb 2023 18:24:30 -0500 Subject: Add new warnings invalid-var and invalid-ref The "invalid-var" warning triggers if the makefile attempts to assign a value to an invalid variable name (a name containing whitespace). The "invalid-ref" warning triggers if the makefile attempts to reference an invalid variable name. Both new warnings have a default action of "warn". * NEWS: Add these new warnings. * doc/make.1: Document them in the man page. * doc/make.texi (Warnings): Document them in the user's manual. * src/warning.h: Add enum values for the new warning types. * src/main.c (initialize_warnings): Initialize the new warnings. * src/variable.h (undefine_variable_in_set, undefine_variable_global): Ask callers to provide a struct floc specifying where the variable is undefined. * src/read.c (do_undefine): Pass floc when undefining. * src/variable.c (check_valid_name): If invalid-var is enabled, check the variable name. (define_variable_in_set): Call it. (undefine_variable_in_set): Ditto. (check_variable_reference): If invalid-ref is enabled, check the variable reference. (lookup_variable): Call it. (lookup_variable_in_set): Ditto. * tests/scripts/options/warn: Add tests for the new warning types. --- NEWS | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index ad56d660..98fa7647 100644 --- a/NEWS +++ b/NEWS @@ -22,10 +22,11 @@ https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=111&se * New feature: Makefile warning reporting control A new option "--warn" controls reporting of warnings for makefiles. Actions - can be set to "ignore", "warn", or "error". The existing warning for - undefined variables is implemented and defaults to "ignore". - "--warn-undefined-variables" is deprecated, and is translated to - "--warn=undefined-vars" internally. + can be set to "ignore", "warn", or "error". Two new warnings are reported: + assigning to invalid variable names, and referencing invalid variable names + (both set to "warn" by default), in addition to the existing warning for + undefined variables (defaults to "ignore"). "--warn-undefined-variables" is + deprecated, and is translated to "--warn=undefined-vars" internally. Version 4.4.1 (26 Feb 2023) -- cgit v1.2.1