diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 409259a715d5882ad06bd5dfd9ee9aad92470334..984b94167bd6a18e28122e0f843a6e8ec263e1bd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2002-07-27  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+	* Makefile.in (gengtype-lex.c): Work around a bug in flex.
+	* gengtype-lex.l (YY_USE_PROTOS): Undef.
+	(YY_DECL): Define.
+
 2002-07-27  Roger Sayle  <roger@eyesopen.com>
 
 	* doc/invoke.texi: Document that both -fno-builtin-foo and
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index f878050a84d3ad2d251da6593c10b2ed46d3c9fa..912635cf20982bd5f6c92e8e92e3828d78778759 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2035,9 +2035,17 @@ gengtype-yacc.o : gengtype-yacc.c gengtype.h $(HCONFIG_H) $(SYSTEM_H)
 	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) \
 	  $(srcdir)/gengtype-yacc.c $(OUTPUT_OPTION)
 
+# The sed command works around a bug in flex-2.5.4.
 $(srcdir)/gengtype-lex.c : $(srcdir)/gengtype-lex.l
-	$(FLEX) $(FLEXFLAGS) -o$@ $(srcdir)/gengtype-lex.l \
-	 || ( rm -f $@ && false )
+	cd $(srcdir) && \
+	$(FLEX) $(FLEXFLAGS) -t -o$@ $(srcdir)/gengtype-lex.l | \
+	  sed 's/^\(char msg\[\];\)/yyconst \1/' > g-$$$$ ; \
+	if test $$? -eq 0 ; then \
+	  mv -f g-$$$$ gengtype-lex.c ; \
+	else \
+	  rm -f g-$$$$.* ; \
+	  false ; \
+	fi
 
 $(srcdir)/gengtype-yacc.c: $(srcdir)/gengtype-yacc.y
 	(cd $(srcdir) && \
diff --git a/gcc/gengtype-lex.l b/gcc/gengtype-lex.l
index 24e0ad4798121d9a5a48e5b0f5298420a0ae40d6..73167f5322b865a5aecc2fcd78a8f7b6bffa8faf 100644
--- a/gcc/gengtype-lex.l
+++ b/gcc/gengtype-lex.l
@@ -28,6 +28,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "gengtype.h"
 #include "gengtype-yacc.h"
 
+#undef YY_USE_PROTOS
+#define YY_DECL int yylex ()
+
 static void update_lineno PARAMS ((const char *l, size_t len));
 
 struct fileloc lexer_line;