From e0abd238e30a1eea02a070e3f5caf4f63c6e7cb6 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 29 Apr 2008 14:14:20 +0000 Subject: [PATCH] Fix compiler warnings under GCC 4.2.1/ SuSE 10.3 git-svn-id: file://localhost/svn/verilator/trunk/verilator@1046 77ca24e4-aefa-0310-84f0-b9a241c72d87 --- Changes | 4 ++++ Makefile.in | 3 +++ src/Makefile_obj.in | 5 +++++ src/V3PreLex.l | 37 +++++++++++++++++++------------------ src/V3Read.cpp | 2 +- src/bisonfix | 28 ++++++++++++++++++++++++++++ src/verilog.l | 6 +++--- src/verilog.y | 2 +- 8 files changed, 64 insertions(+), 23 deletions(-) create mode 100755 src/bisonfix diff --git a/Changes b/Changes index 5ea9ce976..df3378fc0 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,10 @@ Revision history for Verilator The contributors that suggested a given feature are shown in []. [by ...] indicates the contributor was also the author of the fix; Thanks! +* Verilator 3.66*** + +**** Fix compiler warnings under GCC 4.2.1. + * Verilator 3.662 2008/04/25 *** Add Verilog 2005 $clog2() function. diff --git a/Makefile.in b/Makefile.in index 985650373..15f4efb78 100644 --- a/Makefile.in +++ b/Makefile.in @@ -81,6 +81,9 @@ infodir = @infodir@ # Generally ${prefix}/share/verilator pkgdatadir = @pkgdatadir@ +# Directory in which to install data across multiple architectures +datarootdir = @datarootdir@ + #### End of system configuration section. #### ###################################################################### diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index 40a1903d7..6b247917a 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -34,6 +34,9 @@ CFG_WITH_DEFENV = @CFG_WITH_DEFENV@ prefix = @prefix@ +# Directory in which to install data across multiple architectures +datarootdir = @datarootdir@ + # Directory in which to install package specific files # Generally ${prefix}/share/verilator pkgdatadir = @pkgdatadir@ @@ -250,6 +253,8 @@ V3Ast__gen_classes.h : $(ASTGEN) V3Ast.h V3AstNodes.h y.tab.c y.tab.h: verilog.y $(HEADERS) @echo "If you get errors from verilog.y below, try upgrading bison to version 1.875 or newer." ${YACC} ${YFLAGS} $< + mv y.tab.c y_pregen.tab.c && $(PERL) $(srcdir)/bisonfix < y_pregen.tab.c > y.tab.c + mv y.tab.h y_pregen.tab.h && $(PERL) $(srcdir)/bisonfix < y_pregen.tab.h > y.tab.h V3Lexer_pregen.yy.cpp: verilog.l y.tab.h $(HEADERS) ${LEX} ${LFLAGS} -o$@ $< diff --git a/src/V3PreLex.l b/src/V3PreLex.l index d72b9221a..7cec09e4a 100644 --- a/src/V3PreLex.l +++ b/src/V3PreLex.l @@ -36,6 +36,7 @@ static void linenoInc() {V3PreLex::s_currentLexp->incLineno();} static bool optPsl() { return V3PreProc::optPsl(); } static bool pedantic() { return V3PreLex::s_currentLexp->m_pedantic; } static void yyerror(char* msg) { V3PreLex::s_currentLexp->m_curFilelinep->v3error(msg); } +static void yyerrorf(const char* msg) { V3PreLex::s_currentLexp->m_curFilelinep->v3error(msg); } static void appendDefValue(char* t,int l) { V3PreLex::s_currentLexp->appendDefValue(t,l); } static int pslParenLevel() { return V3PreLex::s_currentLexp->m_pslParenLevel; } static void pslParenLevelInc() { V3PreLex::s_currentLexp->m_pslParenLevel++; } @@ -100,8 +101,8 @@ psl [p]sl /* Pass-through strings */ {quote} { yy_push_state(STRMODE); yymore(); } -<> { linenoInc(); yyerror("EOF in unterminated string"); yyleng=0; yyterminate(); } -{crnl} { linenoInc(); yyerror("Unterminated string"); BEGIN(INITIAL); } +<> { linenoInc(); yyerrorf("EOF in unterminated string"); yyleng=0; yyterminate(); } +{crnl} { linenoInc(); yyerrorf("Unterminated string"); BEGIN(INITIAL); } [^\"\\] { yymore(); } {backslash}. { yymore(); } {quote} { yy_pop_state(); @@ -110,14 +111,14 @@ psl [p]sl /* Protected blocks */ "`protected" { yy_push_state(PRTMODE); yymore(); } -<> { linenoInc(); yyerror("EOF in `protected"); yyleng=0; yyterminate(); } +<> { linenoInc(); yyerrorf("EOF in `protected"); yyleng=0; yyterminate(); } {crnl} { linenoInc(); yymore(); } . { yymore(); } "`endprotected" { yy_pop_state(); return (VP_TEXT); } /* Pass-through include <> filenames */ -<> { linenoInc(); yyerror("EOF in unterminated include filename"); yyleng=0; yyterminate(); } -{crnl} { linenoInc(); yyerror("Unterminated include filename"); BEGIN(INITIAL); } +<> { linenoInc(); yyerrorf("EOF in unterminated include filename"); yyleng=0; yyterminate(); } +{crnl} { linenoInc(); yyerrorf("Unterminated include filename"); BEGIN(INITIAL); } [^\>\\] { yymore(); } {backslash}. { yymore(); } [\>] { yy_pop_state(); return (VP_STRING); } @@ -126,9 +127,9 @@ psl [p]sl "/*" { yy_push_state(CMTMODE); yymore(); } "//"[^\n\r]* { return (VP_COMMENT);} {drop} { } -<> { linenoInc(); yy_pop_state(); yytext="\n"; yyleng=1; return (VP_DEFVALUE); } /* Technically illegal, but people complained */ -{crnl} { linenoInc(); yy_pop_state(); yytext="\n"; yyleng=1; return (VP_DEFVALUE); } -[\\]{crnl} { linenoInc(); appendDefValue("\n",1); } /* Include return so can maintain output line count */ +<> { linenoInc(); yy_pop_state(); yytext=(char*)"\n"; yyleng=1; return (VP_DEFVALUE); } /* Technically illegal, but people complained */ +{crnl} { linenoInc(); yy_pop_state(); yytext=(char*)"\n"; yyleng=1; return (VP_DEFVALUE); } +[\\]{crnl} { linenoInc(); appendDefValue((char*)"\n",1); } /* Include return so can maintain output line count */ [^\/\*\n\r\\]+ | [\\][^\n\r] | . { appendDefValue(yytext,yyleng); } @@ -137,8 +138,8 @@ psl [p]sl "/*" { yy_push_state(CMTMODE); yymore(); } "//"[^\n\r]* { return (VP_COMMENT);} {drop} { } -<> { yyerror("EOF in define argument list\n"); yyleng = 0; yyterminate(); } -{crnl} { linenoInc(); yytext="\n"; yyleng=1; return(VP_WHITE); } +<> { yyerrorf("EOF in define argument list\n"); yyleng = 0; yyterminate(); } +{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); } {quote} { yy_push_state(STRMODE); yymore(); } [(] { V3PreLex::s_currentLexp->m_parenLevel++; // Note paren level 0 means before "(" of starting args @@ -167,7 +168,7 @@ psl [p]sl /* One line comments. */ "//"{ws}*{psl} { if (optPsl()) { pslMoreNeeded(true); yy_push_state(PSLONEM); return(VP_PSL); } else { yy_push_state(CMTONEM); yymore(); } } -"//"{ws}*{crnl} { linenoInc(); yytext="\n"; yyleng=1; return (VP_WHITE); } +"//"{ws}*{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return (VP_WHITE); } "//" { if (pslMoreNeeded()) { pslMoreNeeded(true); yy_push_state(PSLONEM); return(VP_PSL); } else { yy_push_state(CMTONEM); yymore(); } } [^\n\r]* { yy_pop_state(); return (VP_COMMENT); } @@ -176,13 +177,13 @@ psl [p]sl [{(] { pslParenLevelInc(); return (VP_TEXT); } [})] { pslParenLevelDec(); return (VP_TEXT); } [;] { if (!pslParenLevel()) {BEGIN PSLONEE; pslMoreNeeded(false);} return (VP_TEXT); } -<> { yyerror("EOF in '/* ... */' psl comment\n"); yyleng=0; yyterminate(); } -{crnl} { linenoInc(); yy_pop_state(); yytext="\n"; yyleng=1; return(VP_WHITE); } +<> { yyerrorf("EOF in '/* ... */' psl comment\n"); yyleng=0; yyterminate(); } +{crnl} { linenoInc(); yy_pop_state(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); } /* Completed psl oneline comments */ -{crnl} { linenoInc(); yy_pop_state(); yytext="\n"; yyleng=1; return(VP_WHITE); } +{crnl} { linenoInc(); yy_pop_state(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); } {ws}+ { yymore(); } -. { yyerror("Unexpected text following psl assertion\n"); } +. { yyerrorf("Unexpected text following psl assertion\n"); } /* C-style comments. */ /* We distinguish between the start of a comment, and later, so we may find a "psl" prefix */ @@ -191,7 +192,7 @@ psl [p]sl {ws}+ { yymore(); } "*/" { yy_pop_state(); return(VP_COMMENT); } {crnl} { linenoInc(); yymore(); } -<> { yyerror("EOF in '/* ... */' block comment\n"); yyleng=0; yyterminate(); } +<> { yyerrorf("EOF in '/* ... */' block comment\n"); yyleng=0; yyterminate(); } . { BEGIN CMTMODE; yymore(); } /* Non 'psl' beginning in comment */ . { yymore(); } @@ -199,13 +200,13 @@ psl [p]sl .|{crnl} { yyless(0); BEGIN PSLMULM; return(VP_PSL); } "*/" { yy_pop_state(); return(VP_COMMENT); } "//"[^\n\r]* { return (VP_COMMENT); } /* Comments inside block comments get literal inclusion (later removal) */ -<> { yyerror("EOF in '/* ... */' psl comment\n"); yyleng=0; yyterminate(); } +<> { yyerrorf("EOF in '/* ... */' psl comment\n"); yyleng=0; yyterminate(); } /* Define calls */ "`"{symb} { return (VP_DEFREF); } /* Generics */ -{crnl} { linenoInc(); yytext="\n"; yyleng=1; return(VP_WHITE); } +{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); } {symb} { return (VP_SYMBOL); } {wsn}+ { return (VP_WHITE); } {drop} { } diff --git a/src/V3Read.cpp b/src/V3Read.cpp index 6df1a2fd8..28dfd5c49 100644 --- a/src/V3Read.cpp +++ b/src/V3Read.cpp @@ -61,7 +61,7 @@ public: ~V3Lexer() {} // METHODS void stateExitPsl() { - if (YY_START != PSL) yyerror("Internal error: Exiting PSL state when not in PSL state"); + if (YY_START != PSL) yyerrorf("Internal error: Exiting PSL state when not in PSL state"); yy_pop_state(); } void statePushVlg() { diff --git a/src/bisonfix b/src/bisonfix new file mode 100755 index 000000000..81eaf5b89 --- /dev/null +++ b/src/bisonfix @@ -0,0 +1,28 @@ +#!/usr/bin/perl -w +#$Id$ +###################################################################### +# +# Copyright 2008-2008 by Wilson Snyder. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either the GNU General Public License or the +# Perl Artistic License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the Perl Artistic License +# along with this module; see the file COPYING. If not, see +# www.cpan.org +# +###################################################################### + +# DESCRIPTION: Edits bison output to get around various issues. + +foreach my $line () { + # Fix bison 2.3 and GCC 4.2.1 + $line =~ s!\(YY_\("!(YY_((char*)"!g; + print "$line"; +} diff --git a/src/verilog.l b/src/verilog.l index 8ff976e3b..970119866 100644 --- a/src/verilog.l +++ b/src/verilog.l @@ -63,7 +63,7 @@ void V3Read::verilatorCmtLintSave() { } void V3Read::verilatorCmtLintRestore() { if (s_readp->m_lintState.empty()) { - yyerror("/*verilator lint_restore*/ without matching save."); + yyerrorf("/*verilator lint_restore*/ without matching save."); return; } V3Read::fileline()->warnStateFrom(s_readp->m_lintState.back()); @@ -687,7 +687,7 @@ escid \\[^ \t\f\r\n]+ /************************************************************************/ /* STRINGS */ -\n { yyerror("Unterminated string\n"); } +\n { yyerrorf("Unterminated string\n"); } \r ; [^\"\\]* { yymore(); } \\. { yymore(); } @@ -700,7 +700,7 @@ escid \\[^ \t\f\r\n]+ \n { yymore(); NEXTLINE(); } "*)" { yy_pop_state(); } . { yymore(); } -<> { yyerror("EOF in (*"); +<> { yyerrorf("EOF in (*"); yyleng = 0; yy_pop_state(); } /************************************************************************/ diff --git a/src/verilog.y b/src/verilog.y index 7b6ffda05..2336dd809 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -35,7 +35,7 @@ // Pick up new lexer #define yylex V3Read::yylex -#define PSLUNSUP(what) NULL; yyerror("Unsupported: PSL language feature not implemented"); +#define PSLUNSUP(what) NULL; yyerrorf("Unsupported: PSL language feature not implemented"); extern void yyerror(char* errmsg); extern void yyerrorf(const char* format, ...);