Add better suggestions on some bad options.

This commit is contained in:
Wilson Snyder 2021-03-27 13:14:43 -04:00
parent d4d87ef300
commit 05db4e41cd
10 changed files with 104 additions and 13 deletions

View File

@ -1498,7 +1498,9 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
m_threadsDpiPure = true; m_threadsDpiPure = true;
m_threadsDpiUnpure = false; m_threadsDpiUnpure = false;
} else { } else {
fl->v3fatal("Unknown setting for --threads-dpi: " << valp); fl->v3fatal("Unknown setting for --threads-dpi: '"
<< valp << "'\n"
<< fl->warnMore() << "... Suggest 'all', 'none', or 'pure'");
} }
}); });
DECL_OPTION("-threads-max-mtasks", CbVal, [this, fl](const char* valp) { DECL_OPTION("-threads-max-mtasks", CbVal, [this, fl](const char* valp) {
@ -1636,7 +1638,9 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
} else if (!strcmp(valp, "unique")) { } else if (!strcmp(valp, "unique")) {
m_xAssign = "unique"; m_xAssign = "unique";
} else { } else {
fl->v3fatal("Unknown setting for --x-assign: " << valp); fl->v3fatal("Unknown setting for --x-assign: '"
<< valp << "'\n"
<< fl->warnMore() << "... Suggest '0', '1', 'fast', or 'unique'");
} }
}); });
DECL_OPTION("-x-initial", CbVal, [this, fl](const char* valp) { DECL_OPTION("-x-initial", CbVal, [this, fl](const char* valp) {
@ -1647,7 +1651,9 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
} else if (!strcmp(valp, "unique")) { } else if (!strcmp(valp, "unique")) {
m_xInitial = "unique"; m_xInitial = "unique";
} else { } else {
fl->v3fatal("Unknown setting for --x-initial: " << valp); fl->v3fatal("Unknown setting for --x-initial: '"
<< valp << "'\n"
<< fl->warnMore() << "... Suggest '0', 'fast', or 'unique'");
} }
}); });
DECL_OPTION("-x-initial-edge", OnOff, &m_xInitialEdge); DECL_OPTION("-x-initial-edge", OnOff, &m_xInitialEdge);

View File

@ -70,8 +70,6 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
// Parse parameters // Parse parameters
// Note argc and argv DO NOT INCLUDE the filename in [0]!!! // Note argc and argv DO NOT INCLUDE the filename in [0]!!!
// May be called recursively when there are -f files. // May be called recursively when there are -f files.
#define shift \
do { ++i; } while (false)
for (int i = 0; i < argc;) { for (int i = 0; i < argc;) {
UINFO(9, " Option: " << argv[i] << endl); UINFO(9, " Option: " << argv[i] << endl);
if (argv[i][0] == '-') { if (argv[i][0] == '-') {
@ -89,15 +87,15 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
} }
// Parameterized switches // Parameterized switches
else if (!strcmp(sw, "-annotate-min") && (i + 1) < argc) { else if (!strcmp(sw, "-annotate-min") && (i + 1) < argc) {
shift; ++i;
m_annotateMin = atoi(argv[i]); m_annotateMin = atoi(argv[i]);
} else if (!strcmp(sw, "-annotate") && (i + 1) < argc) { } else if (!strcmp(sw, "-annotate") && (i + 1) < argc) {
shift; ++i;
m_annotateOut = argv[i]; m_annotateOut = argv[i];
} else if (!strcmp(sw, "-debug")) { } else if (!strcmp(sw, "-debug")) {
V3Error::debugDefault(3); V3Error::debugDefault(3);
} else if (!strcmp(sw, "-debugi") && (i + 1) < argc) { } else if (!strcmp(sw, "-debugi") && (i + 1) < argc) {
shift; ++i;
V3Error::debugDefault(atoi(argv[i])); V3Error::debugDefault(atoi(argv[i]));
} else if (!strcmp(sw, "-V")) { } else if (!strcmp(sw, "-V")) {
showVersion(true); showVersion(true);
@ -106,22 +104,21 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
showVersion(false); showVersion(false);
std::exit(0); std::exit(0);
} else if (!strcmp(sw, "-write") && (i + 1) < argc) { } else if (!strcmp(sw, "-write") && (i + 1) < argc) {
shift; ++i;
m_writeFile = argv[i]; m_writeFile = argv[i];
} else if (!strcmp(sw, "-write-info") && (i + 1) < argc) { } else if (!strcmp(sw, "-write-info") && (i + 1) < argc) {
shift; ++i;
m_writeInfoFile = argv[i]; m_writeInfoFile = argv[i];
} else { } else {
v3fatal("Invalid option: " << argv[i]); v3fatal("Invalid option: " << argv[i]);
} }
shift; ++i;
} // - options } // - options
else { else {
addReadFile(argv[i]); addReadFile(argv[i]);
shift; ++i;
} }
} }
#undef shift
} }
void VlcOptions::showVersion(bool verbose) { void VlcOptions::showVersion(bool verbose) {

View File

@ -0,0 +1,2 @@
%Error: Unknown setting for --compiler: 'bad_one'
... Suggest 'clang', 'gcc', or 'msvc'

View File

@ -0,0 +1,20 @@
#!/usr/bin/env 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.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1);
lint(
verilator_flags2 => ["--compiler bad_one"],
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;

View File

@ -0,0 +1,2 @@
%Error: Unknown setting for --threads-dpi: 'bad_one'
... Suggest 'all', 'none', or 'pure'

View File

@ -0,0 +1,20 @@
#!/usr/bin/env 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.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1);
lint(
verilator_flags2 => ["--threads-dpi bad_one"],
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;

View File

@ -0,0 +1,2 @@
%Error: Unknown setting for --x-assign: 'bad_one'
... Suggest '0', '1', 'fast', or 'unique'

View File

@ -0,0 +1,20 @@
#!/usr/bin/env 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.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1);
lint(
verilator_flags2 => ["--x-assign bad_one"],
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;

View File

@ -0,0 +1,2 @@
%Error: Unknown setting for --x-initial: 'bad_one'
... Suggest '0', 'fast', or 'unique'

View File

@ -0,0 +1,20 @@
#!/usr/bin/env 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.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1);
lint(
verilator_flags2 => ["--x-initial bad_one"],
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;