Mesa (glsl2): glcpp: Avoid warnings in generated flex code.

Ian Romanick idr at kemper.freedesktop.org
Wed Jul 21 00:07:47 UTC 2010


Module: Mesa
Branch: glsl2
Commit: fb90560744864e44730330e4c801ac47c4ece0e1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb90560744864e44730330e4c801ac47c4ece0e1

Author: Carl Worth <cworth at cworth.org>
Date:   Tue Jul 20 15:53:14 2010 -0700

glcpp: Avoid warnings in generated flex code.

We define the YY_NO_INPUT macro to avoid one needless function being
generated.

for the other needless functions, (yyunput and yy_top_state), we add a
new UNREACHABLE start condition and call these functions from an
action there. This doesn't change functionality at all, (since we
never enter the UNREACHABLE start condition), but makes the compiler
stop complaining about these two functions being defined but not used.

---

 src/glsl/glcpp/glcpp-lex.l |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index 29b2769..a4c891b 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -34,6 +34,8 @@
 int glcpp_get_column  (yyscan_t yyscanner);
 void glcpp_set_column (int  column_no , yyscan_t yyscanner);
 
+#define YY_NO_INPUT
+
 #define YY_USER_ACTION                                          \
    do {                                                         \
       yylloc->source = 0;                                       \
@@ -49,7 +51,7 @@ void glcpp_set_column (int  column_no , yyscan_t yyscanner);
 %option prefix="glcpp_"
 %option stack
 
-%x DONE COMMENT
+%x DONE COMMENT UNREACHABLE
 
 SPACE		[[:space:]]
 NONSPACE	[^[:space:]]
@@ -264,6 +266,15 @@ HEXADECIMAL_INTEGER	0[xX][0-9a-fA-F]+[uU]?
 	return NEWLINE;
 }
 
+	/* We don't actually use the UNREACHABLE start condition. We
+	only have this action here so that we can pretend to call some
+	generated functions, (to avoid "defined but not used"
+	warnings. */
+<UNREACHABLE>. {
+	unput('.');
+	yy_top_state(yyextra);
+}
+
 %%
 
 void




More information about the mesa-commit mailing list