Skip to content

Commit

Permalink
Add better suggestions on some bad options.
Browse files Browse the repository at this point in the history
  • Loading branch information
wsnyder committed Mar 27, 2021
1 parent d4d87ef commit 05db4e4
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 13 deletions.
12 changes: 9 additions & 3 deletions src/V3Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,9 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
m_threadsDpiPure = true;
m_threadsDpiUnpure = false;
} 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) {
Expand Down Expand Up @@ -1636,7 +1638,9 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
} else if (!strcmp(valp, "unique")) {
m_xAssign = "unique";
} 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) {
Expand All @@ -1647,7 +1651,9 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
} else if (!strcmp(valp, "unique")) {
m_xInitial = "unique";
} 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);
Expand Down
17 changes: 7 additions & 10 deletions src/VlcMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
// Parse parameters
// Note argc and argv DO NOT INCLUDE the filename in [0]!!!
// May be called recursively when there are -f files.
#define shift \
do { ++i; } while (false)
for (int i = 0; i < argc;) {
UINFO(9, " Option: " << argv[i] << endl);
if (argv[i][0] == '-') {
Expand All @@ -89,15 +87,15 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
}
// Parameterized switches
else if (!strcmp(sw, "-annotate-min") && (i + 1) < argc) {
shift;
++i;
m_annotateMin = atoi(argv[i]);
} else if (!strcmp(sw, "-annotate") && (i + 1) < argc) {
shift;
++i;
m_annotateOut = argv[i];
} else if (!strcmp(sw, "-debug")) {
V3Error::debugDefault(3);
} else if (!strcmp(sw, "-debugi") && (i + 1) < argc) {
shift;
++i;
V3Error::debugDefault(atoi(argv[i]));
} else if (!strcmp(sw, "-V")) {
showVersion(true);
Expand All @@ -106,22 +104,21 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
showVersion(false);
std::exit(0);
} else if (!strcmp(sw, "-write") && (i + 1) < argc) {
shift;
++i;
m_writeFile = argv[i];
} else if (!strcmp(sw, "-write-info") && (i + 1) < argc) {
shift;
++i;
m_writeInfoFile = argv[i];
} else {
v3fatal("Invalid option: " << argv[i]);
}
shift;
++i;
} // - options
else {
addReadFile(argv[i]);
shift;
++i;
}
}
#undef shift
}

void VlcOptions::showVersion(bool verbose) {
Expand Down
2 changes: 2 additions & 0 deletions test_regress/t/t_flag_compiler_bad.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%Error: Unknown setting for --compiler: 'bad_one'
... Suggest 'clang', 'gcc', or 'msvc'
20 changes: 20 additions & 0 deletions test_regress/t/t_flag_compiler_bad.pl
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions test_regress/t/t_flag_threads_dpi_bad.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%Error: Unknown setting for --threads-dpi: 'bad_one'
... Suggest 'all', 'none', or 'pure'
20 changes: 20 additions & 0 deletions test_regress/t/t_flag_threads_dpi_bad.pl
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions test_regress/t/t_flag_x_assign_bad.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%Error: Unknown setting for --x-assign: 'bad_one'
... Suggest '0', '1', 'fast', or 'unique'
20 changes: 20 additions & 0 deletions test_regress/t/t_flag_x_assign_bad.pl
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions test_regress/t/t_flag_x_initial_bad.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%Error: Unknown setting for --x-initial: 'bad_one'
... Suggest '0', 'fast', or 'unique'
20 changes: 20 additions & 0 deletions test_regress/t/t_flag_x_initial_bad.pl
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 05db4e4

Please sign in to comment.