[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] Do not depend on YYLTYPE_IS_TRIVIAL unless locations are req
From: |
Jonathan Nieder |
Subject: |
[PATCH 2/2] Do not depend on YYLTYPE_IS_TRIVIAL unless locations are requested |
Date: |
Sat, 12 Dec 2009 15:44:46 -0600 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Also check if YYLTYPE_IS_TRIVIAL is defined when using its value,
to avoid warnings if it is not defined.
---
I could not tell from the documentation whether YY_LOCATION_PRINT
needs to be defined when locations are disabled. This patches
leaves it in to be safe.
data/glr.c | 2 +-
data/yacc.c | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/data/glr.c b/data/glr.c
index 89bbd6f..e73b251 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -2264,7 +2264,7 @@ yyrecoverSyntaxError (yyGLRStack*
yystackp]b4_user_formals[)
yychar = YYEMPTY;
yylval = yyval_default;
]b4_locations_if([
-#if YYLTYPE_IS_TRIVIAL
+#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
#endif
diff --git a/data/yacc.c b/data/yacc.c
index af38314..0d171a7 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -668,7 +668,7 @@ while (YYID (0))
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
-# if YYLTYPE_IS_TRIVIAL
+]b4_locations_if([[# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
@@ -676,7 +676,9 @@ while (YYID (0))
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
-#endif
+]], [[ /* This macro is maintained here in case user code is relying on it. */
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+]])[#endif
/* YYLEX -- calling `yylex' with the right arguments. */
@@ -1192,7 +1194,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
yyvsp = yyvs;]b4_locations_if([[
yylsp = yyls;
-#if YYLTYPE_IS_TRIVIAL
+#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
--
1.6.5.4
- [PATCH 0/2] avoid some warnings from gcc -c -Wall -W y.tab.c, Jonathan Nieder, 2009/12/12
- [PATCH 1/2] Check if YYENABLE_NLS is defined before checking its value, Jonathan Nieder, 2009/12/12
- [PATCH 3/2] Regenerate src/parse-gram.c, Jonathan Nieder, 2009/12/12
- [PATCH 2/2] Do not depend on YYLTYPE_IS_TRIVIAL unless locations are requested,
Jonathan Nieder <=
- Re: several messages, Joel E. Denny, 2009/12/15
- Re: several messages, Jonathan Nieder, 2009/12/15
- Re: several messages, Joel E. Denny, 2009/12/15
- Re: several messages, Jonathan Nieder, 2009/12/15
- Re: several messages, Joel E. Denny, 2009/12/15
- Re: several messages, Jonathan Nieder, 2009/12/15
- Re: several messages, Joel E. Denny, 2009/12/15
- Re: several messages, Joel E. Denny, 2009/12/16
- Re: several messages, Joel E. Denny, 2009/12/16
- [PATCH v2] Avoid warnings from gcc -Wunused y.tab.c, Jonathan Nieder, 2009/12/15