Check and document error format, #2191.

This commit is contained in:
Wilson Snyder 2020-03-14 21:48:26 -04:00
parent 0a755e6ecf
commit ee8dd32c04
5 changed files with 104 additions and 15 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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;

View File

@ -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)

View File

@ -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