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