This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug in flex prevents fixing ISO C warnings in gengtype-lex.c


Now that the -Wtraditional check for ISO C function definitions is in,
I'm trying to cleanup the warnings from gengtype-lex.c but I'm running
into problems due to a bug in flex-2.5.4.

Is 2.5.4 the latest version?  Does anyone know where to send updates
for flex?  It doesn't look like its being maintained.

Anyway, the problem is that YY_USE_PROTOS determines that we use both
ISO C prototype declarations *and* ISO C function definitions.  We
only want the former.

I can insert an #undef YY_USE_PROTOS after the builtin prototypes
would appear in gengtype-lex.c but before the first function
definition so that we get the right output:

--- orig/egcc-CVS20020702/gcc/gengtype-lex.l	Sat Jun  8 22:37:45 2002
+++ egcc-CVS20020702/gcc/gengtype-lex.l	Wed Jul  3 00:19:07 2002
@@ -28,6 +28,7 @@ Software Foundation, 59 Temple Place - S
 #include "gengtype.h"
 #include "gengtype-yacc.h"
 
+#undef YY_USE_PROTOS
 static void update_lineno PARAMS ((const char *l, size_t len));
 
 struct fileloc lexer_line;


However we get hosed on one function:

 > gengtype-lex.c: In function `yy_fatal_error':
 > gengtype-lex.c:2925: error: argument `msg' doesn't match prototype
 > gengtype-lex.c:277: error: prototype declaration

This occurs because the declaration of yy_fatal_error is inconsistent
with the prototype in its const-ness. :-(  All other functions from
flex are correctly written.  Here's a fix to flex that would take care
of that:

--- orig/flex-2.5.4/skel.c	1996-09-10 20:00:38.000000000 -0400
+++ flex-2.5.4/skel.c	2002-07-03 12:29:16.163576000 -0400
@@ -1431,7 +1431,7 @@ const char *skel[] = {
   "static void yy_fatal_error( yyconst char msg[] )",
   "#else",
   "static void yy_fatal_error( msg )",
-  "char msg[];",
+  "yyconst char msg[];",
   "#endif",
   "	{",
   "	(void) fprintf( stderr, \"%s\\n\", msg );",


How should I address this?

1.  Require everyone to get a patched flex?  (Blah!)

2.  Install the flex output in CVS, this only requires people to patch
    their flex if they *change* the .l file, similar to how we used
    to handle gperf files before 2.7.2 came out.  (Still blah.)

3.  Compile gengtype-lex.c without -Wtraditional, but you'd lose
    warnings about any other ISO C'isms that might creep in. (Blah.)

4.  Add a one line sed command to the generation of gengtype-lex.c
    which has the same effect on the output as the patch to
    flex/skel.c above.


Can anyone think of anything else?  If not, I'd like to implement #4.

		--Kaveh
--
Kaveh R. Ghazi			Director of Systems Architecture
ghazi@caip.rutgers.edu		Qwest Solutions


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]