+
+
+## -------------------------------------------------------------##
+## Missed %merge type warnings when LHS type is declared later. ##
+## -------------------------------------------------------------##
+
+AT_SETUP([Missed %merge type warnings when LHS type is declared later])
+AT_DATA_GRAMMAR([glr-regr18.y],
+[[%glr-parser
+
+%{
+ #include <stdlib.h>
+ static void yyerror (char const *);
+ static int yylex ();
+%}
+
+%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;
+
+%%
+
+static void
+yyerror (char const *msg)
+{
+ fprintf (stderr, "%s\n", msg);
+}
+
+static int
+yylex ()
+{
+ static int called;
+ if (called++)
+ abort ();
+ return 0;
+}
+
+int
+main (void)
+{
+ return yyparse ();
+}
+]])
+
+AT_CHECK([[bison -o glr-regr18.c glr-regr18.y]], 1, [],
+[glr-regr18.y:26.18-24: result type clash on merge function `merge': <type2> != <type1>
+glr-regr18.y:25.18-24: previous declaration
+glr-regr18.y:27.13-19: result type clash on merge function `merge': <type3> != <type2>
+glr-regr18.y:26.18-24: previous declaration
+])
+
+AT_CLEANUP