[antlr-interest] lots of warnings C runtime in antlr 3.0.1
Holger Schurig
hs4233 at mail.mn-solutions.de
Fri Aug 24 03:38:41 PDT 2007
Hi Jim !
Did you ever compile your code with -Wall -Wextra ? I get a huge
number of warnings in this case, some probably hinting to real
problems.
You can do this by calling make like this
$ make CFLAGS="-Wall -Wextra -O2"
After this, we'll see a ton of "warning: unused parameter 'recognizer'"
errors. A way to get rid of them would be to define
#define ANTLR3_UNUSED(var) (void)var;
in antrl3defs.h and then using ANTRL3_UNUSED(recognizer) in the bodies
of functions that don't use this variable. Of course you could also use
__attribute__((unused)) with GCC compilers ...
Another class of warnings are this:
src/antlr3baserecognizer.c: In function 'memoize':
src/antlr3baserecognizer.c:1592: warning: signed and unsigned type in conditional expression
src/antlr3baserecognizer.c:1392: warning: 'freeList' defined but not used
src/antlr3bitset.c: In function 'antlr3BitsetList':
src/antlr3bitset.c:190: warning: dereferencing type-punned pointer will break strict-aliasing rules
src/antlr3commontreenodestream.c:558: warning: 'rewindLast' defined but not used
src/antlr3cyclicdfa.c: In function 'antlr3dfapredict':
src/antlr3cyclicdfa.c:138: warning: comparison between signed and unsigned
src/antlr3filestream.c:38: warning: statement with no effect
src/antlr3inputstream.c:23: warning: 'antlr3InputFileName' declared 'static' but never defined
src/antlr3lexer.c:21: warning: 'matchs_ucase' declared 'static' but never defined
src/antlr3lexer.c:22: warning: 'matchc_ucase' declared 'static' but never defined
src/antlr3lexer.c:23: warning: 'setUpperCompare' declared 'static' but never defined
src/antlr3string.c:297: warning: 'stringInitUTF8' defined but not used
src/antlr3tokenstream.c:119: warning: 'freeEofTOken' defined but not used
src/antlr3treeparser.c:13: warning: 'displayRecognitionError' declared 'static' but never defined
src/antlr3treeparser.c:14: warning: 'recover' declared 'static' but never defined
src/antlr3rewritestreams.c:423: warning: suggest parentheses around && within ||
Also, antlr3-constructed code has warnings:
axelLexer.c: In function 'mCHAR_VALUE':
axelLexer.c:20634: warning: comparison of unsigned expression >= 0 is always true
axelLexer.c: In function 'mSTRING_VALUE':
axelLexer.c:20716: warning: comparison of unsigned expression >= 0 is always true
axelLexer.c: In function 'mEND_COMMENT':
axelLexer.c:21059: warning: comparison of unsigned expression >= 0 is always true
axelLexer.c: In function 'mLINE_COMMENT':
axelLexer.c:21150: warning: comparison of unsigned expression >= 0 is always true
At axelLexer.c, line 20634, antlr3 made this code:
// axel.g:453:8: (~ '\"' )
// axel.g:453:9: ~ '\"'
{
if ( ((LA(1) >= 0x0000) && (LA(1) <= '!')) || ((LA(1) >= '#') && (LA(1) <= 0xFFFE)) )
{
CONSUME();
}
axelParser.c:451: warning: missing initializer
axelParser.c:451: warning: (near initialization for 'FOLLOW_stmt_in_prog52.clone')
axelParser.c:454: warning: missing initializer
axelParser.c:454: warning: (near initialization for 'FOLLOW_LINE_COMMENT_in_prog59.clone')
axelParser.c:457: warning: missing initializer
axelParser.c:457: warning: (near initialization for 'FOLLOW_EOL_in_prog70.clone')
At axelParser.c, line 451, antrl3 made this code:
/** Bitset defining follow set for error recovery in rule state: FOLLOW_stmt_in_prog52 */
static ANTLR3_BITWORD FOLLOW_stmt_in_prog52_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000020) };
static ANTLR3_BITSET FOLLOW_stmt_in_prog52 = { FOLLOW_stmt_in_prog52_bits, 1 };
so I guess GCC 4.1.2 complains that not all fields of the bitset struct are set.
More information about the antlr-interest
mailing list