+AT_CLEANUP
+
+
+## ------------------------------------------------------------------------- ##
+## Uninitialized location when reporting ambiguity. ##
+## ------------------------------------------------------------------------- ##
+
+AT_SETUP([Uninitialized location when reporting ambiguity])
+
+AT_BISON_OPTION_PUSHDEFS([%glr-parser %locations %define api.pure])
+
+AT_DATA_GRAMMAR([glr-regr17.y],
+[[
+%glr-parser
+%locations
+%define api.pure
+%error-verbose
+
+%union { int dummy; }
+
+%{
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
+%}
+
+%%
+
+/* Tests the case of an empty RHS that has inherited the location of the
+ previous nonterminal, which is unresolved. That location is reported as the
+ last position of the ambiguity. */
+start: ambig1 empty1 | ambig2 empty2 ;
+
+/* Tests multiple levels of yyresolveLocations recursion. */
+ambig1: sub_ambig1 | sub_ambig2 ;
+ambig2: sub_ambig1 | sub_ambig2 ;
+
+/* Tests the case of a non-empty RHS as well as the case of an empty RHS that
+ has inherited the initial location. The empty RHS's location is reported as
+ the first position in the ambiguity. */
+sub_ambig1: empty1 'a' 'b' ;
+sub_ambig2: empty2 'a' 'b' ;
+empty1: ;
+empty2: ;
+
+%%
+# include <assert.h>
+
+]AT_YYERROR_DEFINE[
+static int
+yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
+{
+ static char const input[] = "ab";
+ static size_t toknum;
+ assert (toknum < sizeof input);
+ lvalp->dummy = 0;
+ llocp->first_line = llocp->last_line = 2;
+ llocp->first_column = toknum + 1;
+ llocp->last_column = llocp->first_column + 1;
+ return input[toknum++];
+}
+
+int
+main (void)
+{
+ return yyparse () != 1;
+}
+]])
+AT_BISON_OPTION_POPDEFS
+
+AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [],
+[[glr-regr17.y: warning: 3 reduce/reduce conflicts [-Wconflicts-rr]
+]])
+AT_COMPILE([glr-regr17])
+
+AT_PARSER_CHECK([[./glr-regr17]], 0, [],
+[1.1-2.2: syntax is ambiguous
+])
+
+AT_CLEANUP
+
+
+## -------------------------------------------------------------##
+## Missed %merge type warnings when LHS type is declared later. ##
+## -------------------------------------------------------------##
+
+AT_SETUP([Missed %merge type warnings when LHS type is declared later])
+
+AT_BISON_OPTION_PUSHDEFS
+AT_DATA_GRAMMAR([glr-regr18.y],
+[[%glr-parser
+
+%{
+ #include <stdlib.h>
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
+%}
+
+%union {
+ int type1;
+ int type2;
+ int type3;
+}
+
+%%
+
+sym1: sym2 %merge<merge> { $$ = $1; } ;
+sym2: sym3 %merge<merge> { $$ = $1; } ;
+sym3: %merge<merge> { $$ = 0; } ;
+
+%type <type1> sym1;
+%type <type2> sym2;
+%type <type3> sym3;
+
+%%
+]AT_YYERROR_DEFINE[
+]AT_YYLEX_DEFINE[
+int
+main (void)
+{
+ return yyparse ();
+}
+]])
+AT_BISON_OPTION_POPDEFS
+
+AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [],
+[[glr-regr18.y:26.18-24: error: result type clash on merge function 'merge': <type2> != <type1>
+glr-regr18.y:25.18-24: previous declaration
+glr-regr18.y:27.13-19: error: result type clash on merge function 'merge': <type3> != <type2>
+glr-regr18.y:26.18-24: previous declaration
+]])
+
+AT_CLEANUP
+
+
+## ------------------- ##
+## Ambiguity reports. ##
+## ------------------- ##
+
+AT_SETUP([Ambiguity reports])
+
+AT_BISON_OPTION_PUSHDEFS
+AT_DATA_GRAMMAR([input.y],
+[[
+%{
+ #include <stdio.h>
+ #include <stdlib.h>
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
+%}
+
+%debug
+%glr-parser
+
+%%
+start:
+ 'a' b 'c' d
+| 'a' b 'c' d
+;
+b: 'b';
+d: /* nada. */;
+%%
+]AT_YYLEX_DEFINE(["abc"])[
+]AT_YYERROR_DEFINE[
+int
+main (void)
+{
+ yydebug = 1;
+ return !!yyparse ();
+}
+]])
+AT_BISON_OPTION_POPDEFS
+
+AT_BISON_CHECK([[-o input.c input.y]], 0, [],
+[[input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
+]])
+AT_COMPILE([input])
+
+AT_PARSER_CHECK([[./input]], 1, [],
+[Starting parse
+Entering state 0
+Reading a token: Next token is token 'a' ()
+Shifting token 'a' ()
+Entering state 1
+Reading a token: Next token is token 'b' ()
+Shifting token 'b' ()
+Entering state 3
+Reducing stack 0 by rule 3 (line 25):
+ $1 = token 'b' ()
+-> $$ = nterm b ()
+Entering state 4
+Reading a token: Next token is token 'c' ()
+Shifting token 'c' ()
+Entering state 6
+Reducing stack 0 by rule 4 (line 26):
+-> $$ = nterm d ()
+Entering state 7
+Reading a token: Now at end of input.
+Stack 0 Entering state 7
+Now at end of input.
+Splitting off stack 1 from 0.
+Reduced stack 1 by rule #2; action deferred. Now in state 2.
+Stack 1 Entering state 2
+Now at end of input.
+Reduced stack 0 by rule #1; action deferred. Now in state 2.
+Merging stack 0 into stack 1.
+Stack 1 Entering state 2
+Now at end of input.
+Removing dead stacks.
+Rename stack 1 -> 0.
+On stack 0, shifting token $end ()
+Stack 0 now in state #5
+Ambiguity detected.
+Option 1,
+ start -> <Rule 1, tokens 1 .. 3>
+ 'a' <tokens 1 .. 1>
+ b <tokens 2 .. 2>
+ 'c' <tokens 3 .. 3>
+ d <empty>
+
+Option 2,
+ start -> <Rule 2, tokens 1 .. 3>
+ 'a' <tokens 1 .. 1>
+ b <tokens 2 .. 2>
+ 'c' <tokens 3 .. 3>
+ d <empty>
+
+syntax is ambiguous
+Cleanup: popping token $end ()
+Cleanup: popping unresolved nterm start ()
+Cleanup: popping nterm d ()
+Cleanup: popping token 'c' ()
+Cleanup: popping nterm b ()
+Cleanup: popping token 'a' ()