Paul Smith c59cc4f932 [SV 64185] Clarify handling of directive lines starting with TAB
It's clear that this change causes too many problems to be made
without warning.  Revert the change disallowing conditional lines to
start with TAB.

Instead, generate warnings whenever a directive line begins with a
TAB character.  Make this change for all directives, not just
conditional directives: define, undefine, export, unexport, vpath,
load, include, etc.

* NEWS: Update the backward-compatibility warning.
* src/read.c (eval): Track whether the line starts with a TAB.
If so then whenever we recognize a directive, emit a warning.
Revert the previous change for this bug.
(parse_var_assignment): Accept a file location if the line begins
with TAB; show a warning if we discover a directive.
(conditional_line): Warn about lines starting with TAB.
* tests/scripts/...: Add tests to verify warnings for initial TAB.
2025-08-26 08:13:55 -04:00

100 lines
1.4 KiB
Perl

# -*-perl-*-
$description = "Test variable undefine.";
$details = "";
# TEST 0: basic undefine functionality
run_make_test('
a = a
b := b
define c
c
endef
$(info $(flavor a) $(flavor b) $(flavor c))
n := b
undefine a
undefine $n
undefine c
$(info $(flavor a) $(flavor b) $(flavor c))
all: ;@:
',
'', "recursive simple recursive\nundefined undefined undefined");
# TEST 1: override
run_make_test('
undefine a
override undefine b
$(info $(flavor a) $(flavor b))
all: ;@:
',
'a=a b=b', "recursive undefined");
1;
# TEST 2: undefine in eval (make sure we undefine from the global var set)
run_make_test('
define undef
$(eval undefine $$1)
endef
a := a
$(call undef,a)
$(info $(flavor a))
all: ;@:
',
'', "undefined");
# TEST 3: Missing variable name
run_make_test('
a =
undefine $a
all: ;@echo ouch
',
'', "#MAKEFILE#:3: *** empty variable name. Stop.\n", 512);
# Ensure that define can be a target when not appearing in a variable
# definition context. See SV 59870
run_make_test(q!
undefine = undefine
$(undefine) : ;@echo $@
%:undefine
all: undefine foo
%.x : undefine
foo:;
!,
'', "undefine\n");
# Directive lines cannot begin with TAB
run_make_test(q!
#TAB#undefine FOO
all:;@echo hi
!,
'', "#MAKEFILE#:2: warning: directive lines cannot start with TAB\nhi");
1;