Hi Marko, > Le 27 oct. 2021 à 15:04, Marko Mäkelä <marko.mak...@iki.fi> a écrit : > > Hi, > > Bison 3.8.2 is issuing the following warning for a grammar whose semantic > action includes the variable name my_charset_utf8mb4_bin: > > yy_mariadb.cc:35834: warning: suspicious sequence in the output: b4_bin > [-Wother]
Bummer... > It seems to me that the regular expression in > http://git.savannah.gnu.org/cgit/bison.git/tree/src/scan-skel.l is too > greedy, or the check should be suppressed if the input contains such > identifiers. Let's start with "too greedy". Collecting all the identifiers in the input is too much effort for this warning. > A quick search of the Bison Texinfo for b4_ or m4_ did not find anything. > Because those are not documented as reserved words or sequences, I think that > identifiers like that should be allowed in semantic actions without Bison > reporting any warnings. The pattern was stupid and caught occurrences of b4_/m4_ anywhere. The point was to rather to catch \bb4_ and \bm4_. This is what the attached commit does. Yes, it does mean that if someone uses b4_foo or m4_foo, she'll get a spurious warning. If that's really a problem, I'll have to introduce a dedicated -W. But that would lessen the interest of the warning, if most people don't enable it. Hum... Actually "escaping" the user's input to avoid the warning would be a better option. I'll think about it. Cheers! commit c95d0dd5f54b98825e4cfe00a807db78a073e376 Author: Akim Demaille <akim.demai...@gmail.com> Date: Sat Nov 6 19:24:04 2021 +0100 warnings: be less picky about occurrences of m4_/b4_ in the output Reported by Marko Mäkelä. <https://lists.gnu.org/r/bug-bison/2021-10/msg00026.html> * src/scan-skel.l: It is ok to have foob4_ or foom4_. * tests/skeletons.at (Suspicious sequences): New. diff --git a/THANKS b/THANKS index be743a23..14e678c0 100644 --- a/THANKS +++ b/THANKS @@ -117,6 +117,7 @@ Marc Autret autre...@epita.fr Marc Mendiola mmend...@usc.edu Marc Schönefeld marc.schoenef...@gmx.org Mark Boyall wolfeinst...@gmail.com +Marko Mäkelä marko.mak...@iki.fi Martin Blais bl...@furius.ca Martin Jacobs martin.jac...@arcor.de Martin Mokrejs mmokr...@natur.cuni.cz diff --git a/src/scan-skel.l b/src/scan-skel.l index 60232a2e..5a93ce03 100644 --- a/src/scan-skel.l +++ b/src/scan-skel.l @@ -54,7 +54,9 @@ static void output_mapped_file (char const *name); %} /* Identifiers of our M4 macros. */ -macro [bm]4_[a-zA-Z_0-9]* +macro [bm]4_[a-zA-Z_0-9]* +/* Safe sequence of word-constituent characters. */ +identifier [A-Za-z_0-9]+ %x SC_AT_DIRECTIVE_ARGS %x SC_AT_DIRECTIVE_SKIP_WS @@ -90,7 +92,7 @@ macro [bm]4_[a-zA-Z_0-9]* /* This pattern must not match more than the previous @ patterns. */ @[^@{}''(\n]* fail_for_invalid_at (yytext); \n out_lineno++; ECHO; -[^bm@\n]+ ECHO; +[^a-z@\n]+ ECHO; /* If there are still identifiers that look like macros, such as b4_synbol, this probably an error, say a typo in M4, or @@ -104,6 +106,7 @@ macro [bm]4_[a-zA-Z_0-9]* "suspicious sequence in the output: %s", yytext); ECHO; } +{identifier} ECHO; . ECHO; <INITIAL><<EOF>> { diff --git a/tests/skeletons.at b/tests/skeletons.at index 0ed11027..30f25a61 100644 --- a/tests/skeletons.at +++ b/tests/skeletons.at @@ -324,3 +324,44 @@ AT_SETUP([[Fatal errors but M4 continues producing output]]) ]]) AT_CLEANUP + + +## ---------------------- ## +## Suspicious sequences. ## +## ---------------------- ## + +AT_SETUP([[Suspicious sequences]]) + +AT_DATA([[skel.c]], +[[m4@&t@_include(b4_skeletonsdir/[c.m4]) +m4@&t@_divert_push(0)d@&t@nl +@output(b4_parser_file_name@)d@&t@nl +]b4_user_pre_prologue[ +]b4_user_post_prologue[ +b4_unevaluated +m4@&t@_unevaluated +]b4_epilogue[ + +m4@&t@_divert_pop(0) +]]) + +AT_DATA([[input1.y]], +[[%skeleton "./skel.c" +%{ + myb4_unevaluated + mym4_unevaluated +%} +%% +start: ; +%% +myb4_unevaluated +mym4_unevaluated +]]) + +AT_BISON_CHECK([[input1.y]], [], [], +[[input1.tab.c:10: warning: suspicious sequence in the output: b4_unevaluated [-Wother] +input1.tab.c:11: warning: suspicious sequence in the output: m4@&t@_unevaluated [-Wother] +]]) + + +AT_CLEANUP