[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Lexer sed post-processing instead of pragmas

From: Grégoire Sutre
Subject: [PATCH] Lexer sed post-processing instead of pragmas
Date: Tue, 16 Mar 2010 15:45:11 +0100
User-agent: Thunderbird (X11/20091027)


The lexer code in script/yylex.l uses pragmas that are not supported by
gcc < 4.2.  However, without these pragmas, the build fails because of
warnings in the lexer code generated by flex (recall that some targets
are built with -Werror by default).

I've discussed this issue with sethmeisterg on irc.  Of course, dropping
compatibility with gcc 4.1.3 is a possible solution, but we believe that
a better alternative would be to modify the generated lexer so that it
does not trigger any warning.

There are already some sed commands in conf/common.rmk that remove
#includes from the generated lexer.  The attached patch extends the sed
post-processing of the lexer to get rid of the warnings, and removes the
pragmas.  This way, grub can still be compiled with gcc 4.1.3 (which is
the current required version in INSTALL).

The patch also replaces the non-portable -i sed option with temporary

Thanks for your comments,


=== modified file 'conf/common.rmk'
--- conf/common.rmk     2010-03-14 16:50:55 +0000
+++ conf/common.rmk     2010-03-16 14:13:32 +0000
@@ -95,10 +95,21 @@
 grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
 # For the lexer.
+lex_fix_includes = 
+lex_fix_h  = 
+lex_fix_c1 = 
+lex_fix_c2 = 
+lex_fix_c3 = 
+s/yyscanner/yyscanner __attribute__ ((unused))/;\
 grub_script.yy.c grub_script.yy.h: script/yylex.l
        $(LEX) -o grub_script.yy.c --header-file=grub_script.yy.h 
-       sed -i 
-       sed -i 
+       mv grub_script.yy.h grub_script.yy.h.tmp
+       mv grub_script.yy.c grub_script.yy.c.tmp
+       sed -r -e $(lex_fix_includes) -e $(lex_fix_h) grub_script.yy.h.tmp > 
+       sed -r -e $(lex_fix_includes) -e $(lex_fix_c1) -e $(lex_fix_c2) -e 
$(lex_fix_c3) grub_script.yy.c.tmp > grub_script.yy.c
+       rm grub_script.yy.h.tmp grub_script.yy.c.tmp
 DISTCLEANFILES += grub_script.yy.c grub_script.yy.h
 # For grub-script-check.

=== modified file 'script/yylex.l'
--- script/yylex.l      2010-01-25 16:31:14 +0000
+++ script/yylex.l      2010-03-16 14:11:34 +0000
@@ -94,12 +94,6 @@
 #define fprintf(...) 0
 #define exit(...)
-#pragma GCC diagnostic warning "-Wunused-variable"
-#pragma GCC diagnostic warning "-Wunused-function"
-#pragma GCC diagnostic warning "-Wunused-parameter"
-#pragma GCC diagnostic warning "-Wstrict-prototypes"
-#pragma GCC diagnostic warning "-Wmissing-prototypes"
 %option ecs

reply via email to

[Prev in Thread] Current Thread [Next in Thread]