CMake: Configure our .y files for different Bison/YACC flavors.
Bison 3.4 and later generate deprecation warnings for the "%pure-parser" directive. As https://git.savannah.gnu.org/cgit/bison.git/tree/NEWS says, ---- ** Deprecated features The %pure-parser directive is deprecated in favor of '%define api.pure' since Bison 2.3b (2008-05-27), but no warning was issued; there is one now. Note that since Bison 2.7 you are strongly encouraged to use '%define api.pure full' instead of '%define api.pure'. ---- Rename our .y files to .y.in, and modify FindYACC.cmake to detect newer versions of Bison and configure our .y files with "%pure-parser" or "%define api.pure" as needed. Squelches warnings from Bison in #16924.
This commit is contained in:
parent
0a219bf8b9
commit
1a244f9de5
|
@ -22,9 +22,24 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(YACC DEFAULT_MSG YACC_EXECUTABLE)
|
|||
|
||||
MARK_AS_ADVANCED(YACC_EXECUTABLE)
|
||||
|
||||
# Specifying "%pure-parser" will fail with a deprecation warning in
|
||||
# Bison 3.4 and later. Specifying "%define api.pure" doesn't work with
|
||||
# Berkeley YACC and older versions of Bison (such as 2.3, which ships
|
||||
# with macOS). If we're using Bison and it's new, configure our .y.in
|
||||
# files with "%define api.pure", otherwise use "%pure-parser".
|
||||
set(YACC_PURE_PARSER_DIRECTIVE "%pure-parser")
|
||||
if(YACC_EXECUTABLE)
|
||||
execute_process(COMMAND ${YACC_EXECUTABLE} -V OUTPUT_VARIABLE _yacc_full_version)
|
||||
string(REGEX MATCH "[1-9]+\.[0-9]+" _yacc_major_minor ${_yacc_full_version})
|
||||
if (_yacc_full_version MATCHES "GNU Bison" AND _yacc_major_minor VERSION_GREATER "2.6")
|
||||
set(YACC_PURE_PARSER_DIRECTIVE "%define api.pure")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
MACRO(ADD_YACC_FILES _source _generated)
|
||||
FOREACH (_current_FILE ${ARGN})
|
||||
GET_FILENAME_COMPONENT(_in ${_current_FILE} ABSOLUTE)
|
||||
configure_file(${_current_FILE}.in ${_current_FILE})
|
||||
GET_FILENAME_COMPONENT(_in ${CMAKE_CURRENT_BINARY_DIR}/${_current_FILE} ABSOLUTE)
|
||||
GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME_WE)
|
||||
|
||||
SET(_out ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.c)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*
|
||||
* We want a reentrant parser.
|
||||
* For now ignore the wdeprecated warning recommending
|
||||
* %define api.pure
|
||||
* https://code.wireshark.org/review/#/c/33771/
|
||||
* "This doesn't work with Berkeley YACC, and I'd *really* prefer not to require Bison."
|
||||
* Berkeley YACC and older versions of Bison use "%pure-parser" and newer
|
||||
* versions of Bison use "%define api.pure".
|
||||
* As https://code.wireshark.org/review/#/c/33771/
|
||||
* says, "This doesn't work with Berkeley YACC, and I'd *really* prefer not to require Bison."
|
||||
*/
|
||||
%pure-parser
|
||||
${YACC_PURE_PARSER_DIRECTIVE}
|
||||
|
||||
/*
|
||||
* We also want a reentrant scanner, so we have to pass the
|
|
@ -1,11 +1,11 @@
|
|||
/*
|
||||
* We want a reentrant parser.
|
||||
* For now ignore the wdeprecated warning recommending
|
||||
* %define api.pure
|
||||
* https://code.wireshark.org/review/#/c/33771/
|
||||
* "This doesn't work with Berkeley YACC, and I'd *really* prefer not to require Bison."
|
||||
* Berkeley YACC and older versions of Bison use "%pure-parser" and newer
|
||||
* versions of Bison use "%define api.pure".
|
||||
* As https://code.wireshark.org/review/#/c/33771/
|
||||
* says, "This doesn't work with Berkeley YACC, and I'd *really* prefer not to require Bison."
|
||||
*/
|
||||
%pure-parser
|
||||
${YACC_PURE_PARSER_DIRECTIVE}
|
||||
|
||||
/*
|
||||
* We also want a reentrant scanner, so we have to pass the
|
Loading…
Reference in New Issue