From tim@X2296  Fri Feb 21 14:02:38 1997
Received: from X2296 (ppp1576.on.sympatico.ca [206.172.249.40])
          by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id OAA26899
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 21 Feb 1997 14:02:36 -0800 (PST)
Received: (from tim@localhost) by X2296 (8.7.6/8.7.3) id RAA03075; Fri, 21 Feb 1997 17:02:16 -0500 (EST)
Message-Id: <199702212202.RAA03075@X2296>
Date: Fri, 21 Feb 1997 17:02:16 -0500 (EST)
From: <absent@X2296>
Reply-To: Tim Vanderhoek <ac199@freenet.hamilton.on.ca>
To: FreeBSD-gnats-submit@freebsd.org
Subject: yacc-generated parser compile-time warnings
X-Send-Pr-Version: 3.2

>Number:         2792
>Category:       bin
>Synopsis:       yacc-generated parser and (const)'s and cc warnings
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    steve
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 21 14:10:00 PST 1997
>Closed-Date:    Sun Apr 27 20:37:42 PDT 1997
>Last-Modified:  Sun Apr 27 20:39:00 PDT 1997
>Originator:     Tim Vanderhoek
>Release:        FreeBSD 2.2-961006-SNAP i386; yes, I know date==970221
>Organization:
Sympatico, Canada's largest Service Provider (I think)
>Environment:

Very very warm.  19C.

>Description:

Parsers generated by yacc and compiled with -Wwrite-strings and
-Wcast-qual generate a number of errors.  This is undesirable.

>How-To-Repeat:


>Fix:

The following two patches should do the trick.  They're relative to
-CURRENT as of 970227.  They also make another small change; full
explanation of all follows.

--
getenv() is declared in <stdlib.h>, which is included, so we 
don't need to redeclare it.

yylex() shouldn't really be declared in skeleton.c, since it
doesn't define it.

yygrowstack() is from lites.  It's defined in skeleton.c, so it
should be prototyped there, too.

in output.c, output_debug(), the yyrule[] was declared
(const char * const yyrule[]), but yyname[] was only
(char *yyname[]) causing many "assignment discards const" warnings.
Changed to be like yyrule.  I believe that this change was
supposed to have been done in version 1.3 of output.c but was
accidentally skipped.  Will phk verify this?

Above change requires yys to be (const char *), too.
--

*** old_skeleton.c	Fri Feb 21 14:48:08 1997
--- skeleton.c	Fri Feb 21 16:25:30 1997
***************
*** 68,86 ****
      "#define yyclearin (yychar=(YYEMPTY))",
      "#define yyerrok (yyerrflag=0)",
      "#define YYRECOVERING (yyerrflag!=0)",
!     "/* cfront 1.2 defines \"c_plusplus\" instead of \"__cplusplus\" */",
!     "#ifdef c_plusplus",
!     "#ifndef __cplusplus",
!     "#define __cplusplus",
!     "#endif",
!     "#endif",
!     "#ifdef __cplusplus",
!     "extern \"C\" { char *getenv(const char *); }",
!     "#else",
!     "extern char *getenv();",
!     "extern int yylex();",
!     "extern int yyparse();",
!     "#endif",
      0
  };
  
--- 68,75 ----
      "#define yyclearin (yychar=(YYEMPTY))",
      "#define yyerrok (yyerrflag=0)",
      "#define YYRECOVERING (yyerrflag!=0)",
!     "extern int yyparse(void);",
!     "static int yygrowstack(void);",
      0
  };
  
***************
*** 173,179 ****
      "{",
      "    register int yym, yyn, yystate;",
      "#if YYDEBUG",
!     "    register char *yys;",
      "",
      "    if ((yys = getenv(\"YYDEBUG\")))",
      "    {",
--- 162,168 ----
      "{",
      "    register int yym, yyn, yystate;",
      "#if YYDEBUG",
!     "    register const char *yys;",
      "",
      "    if ((yys = getenv(\"YYDEBUG\")))",
      "    {",


*** old_output.c	Fri Feb 21 15:27:32 1997
--- output.c	Fri Feb 21 16:13:53 1997
***************
*** 970,976 ****
      symnam[0] = "end-of-file";
  
      if (!rflag) ++outline;
!     fprintf(output_file, "#if YYDEBUG\nchar *%sname[] = {", symbol_prefix);
      j = 80;
      for (i = 0; i <= max; ++i)
      {
--- 970,977 ----
      symnam[0] = "end-of-file";
  
      if (!rflag) ++outline;
!     fprintf(output_file, "#if YYDEBUG\n"
!                          "const char * const %sname[] = {", symbol_prefix);
      j = 80;
      for (i = 0; i <= max; ++i)
      {
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->steve 
Responsible-Changed-By: mpp 
Responsible-Changed-When: Fri Feb 21 15:06:09 PST 1997 
Responsible-Changed-Why:  
Steve Price seems to have done the most recent work on yacc. 
State-Changed-From-To: open->closed 
State-Changed-By: steve 
State-Changed-When: Sun Apr 27 20:37:42 PDT 1997 
State-Changed-Why:  
Supplied patch applied, thanks. 
>Unformatted:
