Commit 361e423e authored by Sean McBride's avatar Sean McBride

Suppress clang fallthrough warning in C file

Also updated some comments on using flex.
parent b0f9fb5a
Pipeline #149062 running with stage
......@@ -5,7 +5,7 @@ The contents of this directory are used to generate a C library called
vtkWrappingTools, which provides utility functions for parsing C++ header
files. The core of the wrapping tools is a parser that is built using
the classic compiler-generator tools lex and yacc. These tools are
available on OS X and on most linux systems.
available on macOS and on most linux systems.
LEX:
......@@ -17,30 +17,21 @@ included (i.e. as a C file) by the main parser file, vtkParse.tab.c.
To generate lex.yy.c from vtkParse.l, use the following steps:
1. Get a copy of flex, version 2.5.35 or later
2. Run flex --nodefault -olex.yy.c vtkParse.l
1. Get a copy of flex, version 2.6.4 or later
2. Run flex --nodefault --noline -olex.yy.c vtkParse.l
3. Edit the file lex.yy.c as follows, to eliminate compiler warnings and
to make it pass the git commit hook tests:
a) Convert tabs to 8 spaces, e.g. :%s/\t/ /g
a) Convert tabs to 2 spaces, e.g. :%s/\t/ /g
b) Remove extra whitespace from the ends of lines, e.g. :%s/ *$//
c) Remove blank lines at the beginning and end of the file
d) Replace "int yyl;" with "yy_size_t yyl;", e.g. :%s/int yyl;/yy_size_t yyl;/
e) Remove any instances of the "register" keyword.
Some known warnings with recent flex/gcc:
- Add the following code if not already present to avoid warnings about
isatty being used without a declaration:
#ifndef __cplusplus
extern int isatty(int);
#endif /* __cplusplus */
- Change 'int i;' to 'yy_size_t i;' in yy_scan_bytes (line ~3700).
- Add text after "@param line_number" (line ~3505) since doxygen
does not permit empty @param paragraphs (clang -Wdocumentation).
upstream bug: <https://sourceforge.net/p/flex/bugs/158/>
d) Remove the definition of "struct yy_trans_info", which is used nowhere
and will cause a compiler warning.
e) Add the following code (around line 24) to avoid warnings about
isatty() being used without a declaration:
Step "d" removes a potential signed/unsigned comparison compiler
warning. It might not be necessary in later versions of flex.
#ifndef __cplusplus
extern int isatty(int);
#endif /* __cplusplus */
YACC:
......
......@@ -1655,19 +1655,23 @@ char *yytext;
This file must be translated to C and modified to build everywhere.
Run flex like this:
See the adjacent README.txt file for instructions.
flex --nodefault --noline -olex.yy.c vtkParse.l
Modify lex.yy.c:
- convert tabs to spaces (2 spaces per tab)
- remove extra space from end of lines
- remove blank lines from end of file
- compile with gcc and "-Wsign-compare", there should be no warnings
- add a prototype for isatty
- remove unused struct yy_trans_info
*/
/* to workaround https://bugs.llvm.org/show_bug.cgi?id=43465 */
#if defined(__clang__)
#pragma clang diagnostic push
#if defined(__has_warning)
#if __has_warning("-Wimplicit-fallthrough")
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
#endif
#endif
#elif defined(__GNUC__) && (__GNUC__ >= 7)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#endif
/* We do not care of interactive mode */
#define YY_NEVER_INTERACTIVE 1
......
......@@ -5,19 +5,23 @@
This file must be translated to C and modified to build everywhere.
Run flex like this:
See the adjacent README.txt file for instructions.
flex --nodefault --noline -olex.yy.c vtkParse.l
Modify lex.yy.c:
- convert tabs to spaces (2 spaces per tab)
- remove extra space from end of lines
- remove blank lines from end of file
- compile with gcc and "-Wsign-compare", there should be no warnings
- add a prototype for isatty
- remove unused struct yy_trans_info
*/
/* to workaround https://bugs.llvm.org/show_bug.cgi?id=43465 */
#if defined(__clang__)
#pragma clang diagnostic push
#if defined(__has_warning)
#if __has_warning("-Wimplicit-fallthrough")
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
#endif
#endif
#elif defined(__GNUC__) && (__GNUC__ >= 7)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#endif
/* We do not care of interactive mode */
#define YY_NEVER_INTERACTIVE 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment