diff --git a/bin/verilator b/bin/verilator index 79a9ffd59..15d399587 100755 --- a/bin/verilator +++ b/bin/verilator @@ -3914,7 +3914,19 @@ checking across the designs, and prevents other users from compiling your code without knowing the magic set of disables needed to successfully compile your design. -List of all warnings: +=head2 Error and Warning Format + +Warnings and errors printed by Verilator always match this regular +expression: + + %(Error|Warning)(-[A-Z0-9_]+)?: ((\S+):(\d+):((\d+):)?)? .* + +Errors and warning start with a percent sign (historical heritage from +Digital Equipment Corporation). Some errors or warning have a code +attached, with meanings described below. Some errors also have a filename, +line number and optional column number (starting at column 1 to match GCC). + +=head2 List of all warnings =over 4 diff --git a/src/V3FileLine.cpp b/src/V3FileLine.cpp index 7dad8ea66..ccf065b73 100644 --- a/src/V3FileLine.cpp +++ b/src/V3FileLine.cpp @@ -376,8 +376,11 @@ string FileLine::warnOther() const { string FileLine::source() const { if (VL_UNCOVERABLE(!m_contentp)) { - if (debug() || v3Global.opt.debugCheck()) return "%Error-internal-no-contents"; - else return ""; + if (debug() || v3Global.opt.debugCheck()) { + return "%Error: internal tracking of file contents failed"; + } else { + return ""; + } } return m_contentp->getLine(m_contentLineno); } diff --git a/test_regress/t/t_dist_error_format.pl b/test_regress/t/t_dist_error_format.pl new file mode 100755 index 000000000..af97e7be6 --- /dev/null +++ b/test_regress/t/t_dist_error_format.pl @@ -0,0 +1,74 @@ +#!/usr/bin/perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you can +# redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. + +use IO::File; + +scenarios(dist => 1); + +my $root = ".."; +my $Debug; + +if (!-r "$root/.git") { + skip("Not in a git repository"); +} else { + formats(); +} + +ok(1); + +# Check all error messages match our standard format +# This assumes .out files cover all important errors + +sub formats { + my $files = "../test_regress/t/*.out"; + my %warns; + my $lnmatch = 0; + foreach my $file (glob $files) { + my $wholefile = file_contents($file); + $file =~ s!.*/!!; + if ($wholefile =~ /Exiting due to/ + || $wholefile =~ /%(Error|Warning)/) { + my $lineno = 0; + foreach my $line (split /\n/, $wholefile) { + ++$lineno; + if ($line =~ /(Error|Warning)/) { + # These formats are documented in bin/verilator + # Error with fileline + # For testing only: we assume no : in filename + my $match = $line; + $match =~ s/^\[\d+\] //; # Simplify runtime errors + if ($match =~ /^%(Error|Warning)(-[A-Z0-9_]+)?: ([^:]+):(\d+):((\d+):)? /) { + ++$lnmatch; + print "ok-el $file $line\n" if $Self->{verbose}; + } + # Error no fileline + # For testing only: we assume any : is single quoted + elsif ($match =~ /^%(Error|Warning)(-[A-Z0-9_]+)?: [^:']+/) { + print "ok-en $file $line\n" if $Self->{verbose}; + } + else { + #print "FF $file $line\n"; + $warns{$file.":".$lineno} = + "Non-standard warning/error: $file:$lineno: $line"; + } + } + } + } + } + $lnmatch or error("Check line number regexp is correct, no matches"); + if (keys %warns) { + # First warning lists everything as that's shown in the driver summary + error($summary." ",join(' ',sort keys %warns)); + foreach my $file (sort keys %warns) { + error($warns{$file}); + } + } +} + +1; diff --git a/test_regress/t/t_interface_modport_dir_bad.out b/test_regress/t/t_interface_modport_dir_bad.out index 8ea68f01f..927f0c16e 100644 --- a/test_regress/t/t_interface_modport_dir_bad.out +++ b/test_regress/t/t_interface_modport_dir_bad.out @@ -1,12 +1,12 @@ -#Expecting something along the line of: +Expecting something along the line of: - %Error: t/t_interface_modport_dir_bad.v:36: Attempt to drive input-only modport: 'data' - : ... In instance t.source_i.source_i - ctrl.data <= ~ctrl.data; - ^~~~ - %Error: Exiting due to 1 error(s) - %Error: t/t_interface_modport_dir_bad.v:37: Attempt to drive input-only modport: 'valid' - : ... In instance t.source_i.source_i - ctrl.valid<= ~ctrl.valid; - ^~~~ - %Error: Exiting due to 1 error(s) +%Error: t/t_interface_modport_dir_bad.v:36: Attempt to drive input-only modport: 'data' +: ... In instance t.source_i.source_i +ctrl.data <= ~ctrl.data; +^~~~ +%Error: Exiting due to 1 error(s) +%Error: t/t_interface_modport_dir_bad.v:37: Attempt to drive input-only modport: 'valid' +: ... In instance t.source_i.source_i +ctrl.valid<= ~ctrl.valid; +^~~~ +%Error: Exiting due to 1 error(s) diff --git a/test_regress/t/t_pp_line_bad.out b/test_regress/t/t_pp_line_bad.out index 609b3befb..e88ab8e47 100644 --- a/test_regress/t/t_pp_line_bad.out +++ b/test_regress/t/t_pp_line_bad.out @@ -5,7 +5,7 @@ `line 100 ^ %Error: somefile:100: `line was not properly formed with '`line number "filename" level' -%Error-internal-no-contents +%Error: internal tracking of file contents failed ^ %Error: t/t_pp_line_bad.v:6: Define or directive not defined: '`line' `line