mirror of
https://git.savannah.gnu.org/git/make.git
synced 2025-01-27 09:43:41 +00:00
bf7f690202
Previously we used the fact that this line ending expanded to "$ " which would then expand to the empty string. This has problems if you enable warnings for undefined variables, so directly implement this special (but documented) trick in the GNU Make parser. As a side-effect this also removes all previous whitespace when in GNU Make mode (not in POSIX mode) just as it would without "$". * src/misc.c (collapse_continuations): Check for "$\" and remove it. * tests/scripts/variables/flavors: Add regression tests including with previous whitespace, and escaped/unescaped "$"
54 lines
1.3 KiB
Perl
54 lines
1.3 KiB
Perl
# -*-perl-*-
|
|
|
|
$description = "Run some negative tests (things that should fail).";
|
|
|
|
my $unterm = '*** unterminated variable reference. Stop.';
|
|
|
|
# TEST #0
|
|
# Check that non-terminated variable references are detected (and
|
|
# reported using the best filename/lineno info
|
|
run_make_test('
|
|
foo = bar
|
|
x = $(foo
|
|
y = $x
|
|
|
|
all: ; @echo $y
|
|
',
|
|
'', "#MAKEFILE#:3: $unterm",
|
|
512);
|
|
|
|
# TEST #1
|
|
# Bogus variable value passed on the command line.
|
|
run_make_test(undef, ['x=$(other'], "#MAKEFILE#:4: $unterm", 512);
|
|
|
|
# TEST #2
|
|
# Again, but this time while reading the makefile.
|
|
run_make_test('
|
|
foo = bar
|
|
x = $(foo
|
|
y = $x
|
|
|
|
z := $y
|
|
|
|
all: ; @echo $y
|
|
',
|
|
'', "#MAKEFILE#:3: $unterm", 512);
|
|
|
|
# TEST #3
|
|
# Bogus variable value passed on the command line.
|
|
run_make_test(undef, ['x=$(other'], "#MAKEFILE#:4: $unterm", 512);
|
|
|
|
my $nosep = '*** missing separator. Stop.';
|
|
|
|
# Whitespace not allowed in variable names
|
|
run_make_test('x y =', '', "#MAKEFILE#:1: $nosep", 512);
|
|
|
|
run_make_test('x y=', '', "#MAKEFILE#:1: $nosep", 512);
|
|
|
|
# In theory an empty variable should be ignored, but during parsing it's a
|
|
# real token and so this fails. I'm not 100% sure if this is right or not.
|
|
|
|
run_make_test('x $X=', '', "#MAKEFILE#:1: $nosep", 512);
|
|
|
|
|
|
1;
|