diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2021-08-07 09:30:24 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2021-08-07 12:53:19 +0200 |
commit | 80db1029e67e5d42fa6329489558b114fdfea880 (patch) | |
tree | 72f350019318187faa1d941c04eb79145cf996c0 /tests | |
parent | 6118406c3eac88a06a414edf4a50b175fa339916 (diff) | |
download | bison-80db1029e67e5d42fa6329489558b114fdfea880.tar.gz |
m4: catch suspicions of unevaluated macros
Check in m4's output if there are sequences such as m4_foo or b4_foo,
which are probably resulting from incorrect m4 processing.
It actually already is useful:
- it caught a leaking b4_lac_if leaking from glr.c, where LAC is not
supported, hence b4_lac_if is not defined.
- it also caught references to location.hh in position.hh when
location.hh does not exist.
- while making "Code injection" robust to these new warnings (it is
its very purpose to let b4_canary pass unevaluated), I saw that it
did not check lalr1.d, and when adding lalr1.d, it revealed it did
underquote ocurrences of token value types.
* src/scan-skel.l (macro): New abbreviation.
Use it.
* data/skeletons/glr.c: Don't use b4_lac_if, we don't have it.
* data/skeletons/location.cc: Don't generate position.hh when we don't
generate location.hh.
* data/skeletons/d.m4 (b4_basic_symbol_constructor_define): Fix
underquotation.
* data/skeletons/bison.m4 (b4_canary): New.
* tests/input.at (Code injection): Use it, and check lalr1.d too.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/input.at | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/tests/input.at b/tests/input.at index 5f298bc9..f41c3657 100644 --- a/tests/input.at +++ b/tests/input.at @@ -2889,26 +2889,26 @@ m4_pattern_allow([^m4_errprintn$]) # Try to have MACRO be run by bison. m4_pushdef([AT_TEST], [AT_DATA([[input.y]], -[[%type <$1(DEAD %type)> exp -%token <$1(DEAD %token)> a +[[%type <$1(%type)> exp +%token <$1(%token)> a %token b %initial-action { $$; - $<$1(DEAD %initial-action)>$ + $<$1(%initial-action)>$ }; %printer { $$ - $<$1(DEAD %printer)>$ + $<$1(%printer)>$ } <> <*>; %lex-param { - $1(DEAD %lex-param) + $1(%lex-param) }; %parse-param { - $1(DEAD %parse-param) + $1(%parse-param) }; %% exp: @@ -2916,25 +2916,24 @@ exp: { $$; $][1; - $<$1(DEAD action 1)>$ - $<$1(DEAD action 2)>1 - $<$1(DEAD action 3)>name - $<$1(DEAD action 4)>0 + $<$1(action 1)>$ + $<$1(action 2)>1 + $<$1(action 3)>name + $<$1(action 4)>0 ; }; ]]) -# FIXME: Provide a means to iterate over all the skeletons. -AT_BISON_CHECK([[-d input.y]]) -AT_BISON_CHECK([[-d -S glr.c input.y]]) -AT_BISON_CHECK([[-d -S lalr1.cc input.y]]) -AT_BISON_CHECK([[-d -S glr.cc input.y]]) -AT_BISON_CHECK([[-d -S glr2.cc input.y]]) -AT_BISON_CHECK([[ -S lalr1.java input.y]]) +# Disable -Wother to avoid the warnings about the suspicious presence +# of `b4_canary` in the output. +m4_foreach([b4_skel], + [[yacc.c], [glr.c], [lalr1.cc], [glr.cc], [glr2.cc], [lalr1.d], [lalr1.java]], +[AT_BISON_CHECK([[-Wno-other -S ]b4_skel[ ]m4_bmatch(b4_skel, [.*\.java$], [], [-d])[ input.y]]) +]) ]) -AT_TEST([m4_errprintn]) -AT_TEST([@:>@m4_errprintn]) +AT_TEST([b4_canary]) +AT_TEST([@:>@b4_canary]) m4_popdef([AT_TEST]) |