[gnu.g++.bug] cplus-parse.y mentions yytname and yyrline even when YYDEBUG==0

eggert@twinsun.com (Paul Eggert) (03/02/90)

GNU C++ 1.37.0's cplus-parse.y refers to the variables yyrline and yytname
even when the YYDEBUG flag is zero.  In some versions of Bison, these
variables are not present unless YYDEBUG is nonzero, because the parser needs
them only when in debugging mode.  Here is a fix.

*** old/cplus-parse.y	The Mar  1 16:00:25 1990
--- new/cplus-parse.y	Thu Mar  1 16:00:12 1990
***************
*** 3087,3093 ****
  static int *token_count;
  
  #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
! #define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0]))
  
  int *
  init_parse ()
--- 3087,3093 ----
  static int *token_count;
  
  #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
! #define TOKEN_LENGTH (256 + YYNTBASE + 1)
  
  int *
  init_parse ()
***************
*** 3147,3154 ****
  	break;
        if (token_count[index] < token_count[-1])
  	break;
!       fprintf (stderr, "token %d, `%s', count = %d\n",
! 	       index, yytname[YYTRANSLATE (index)], token_count[index]);
      }
    fprintf (stderr, "\n");
    for (i = 0; i < REDUCE_LENGTH; i++)
--- 3147,3157 ----
  	break;
        if (token_count[index] < token_count[-1])
  	break;
!       fprintf (stderr, "token %d", index);
! #if YYDEBUG
!       fprintf (stderr, ", `%s'", yytname[YYTRANSLATE (index)]);
! #endif
!       fprintf (stderr, ", count = %d\n", token_count[index]);
      }
    fprintf (stderr, "\n");
    for (i = 0; i < REDUCE_LENGTH; i++)
***************
*** 3161,3168 ****
  	break;
        if (reduce_count[index] < reduce_count[-1])
  	break;
!       fprintf (stderr, "rule %d, line %d, count = %d\n",
! 	       index, yyrline[index], reduce_count[index]);
      }
    fprintf (stderr, "\n");
  }
--- 3164,3174 ----
  	break;
        if (reduce_count[index] < reduce_count[-1])
  	break;
!       fprintf (stderr, "rule %d", index);
! #if YYDEBUG
!       fprintf (stderr, ", line %d", yyrline[index]);
! #endif
!       fprintf (stderr, ", count = %d\n", reduce_count[index]);
      }
    fprintf (stderr, "\n");
  }