Date: Fri, 21 Feb 1997 17:02:16 -0500 (EST) From: <absent@X2296> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/2792: yacc-generated parser compile-time warnings Message-ID: <199702212202.RAA03075@X2296> Resent-Message-ID: <199702212210.OAA27554@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 2792 >Category: bin >Synopsis: yacc-generated parser and (const)'s and cc warnings >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Feb 21 14:10:00 PST 1997 >Last-Modified: >Originator: Tim Vanderhoek >Organization: Sympatico, Canada's largest Service Provider (I think) >Release: FreeBSD 2.2-961006-SNAP i386; yes, I know date==970221 >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) { >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702212202.RAA03075>