From 05db4e41cd79baa5f947d63d51f5e86f76d54e47 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 27 Mar 2021 13:14:43 -0400 Subject: [PATCH] Add better suggestions on some bad options. --- src/V3Options.cpp | 12 +++++++++--- src/VlcMain.cpp | 17 +++++++---------- test_regress/t/t_flag_compiler_bad.out | 2 ++ test_regress/t/t_flag_compiler_bad.pl | 20 ++++++++++++++++++++ test_regress/t/t_flag_threads_dpi_bad.out | 2 ++ test_regress/t/t_flag_threads_dpi_bad.pl | 20 ++++++++++++++++++++ test_regress/t/t_flag_x_assign_bad.out | 2 ++ test_regress/t/t_flag_x_assign_bad.pl | 20 ++++++++++++++++++++ test_regress/t/t_flag_x_initial_bad.out | 2 ++ test_regress/t/t_flag_x_initial_bad.pl | 20 ++++++++++++++++++++ 10 files changed, 104 insertions(+), 13 deletions(-) create mode 100644 test_regress/t/t_flag_compiler_bad.out create mode 100755 test_regress/t/t_flag_compiler_bad.pl create mode 100644 test_regress/t/t_flag_threads_dpi_bad.out create mode 100755 test_regress/t/t_flag_threads_dpi_bad.pl create mode 100644 test_regress/t/t_flag_x_assign_bad.out create mode 100755 test_regress/t/t_flag_x_assign_bad.pl create mode 100644 test_regress/t/t_flag_x_initial_bad.out create mode 100755 test_regress/t/t_flag_x_initial_bad.pl diff --git a/src/V3Options.cpp b/src/V3Options.cpp index f2f4ae6f3..cbbc25cc9 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -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) { @@ -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) { @@ -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); diff --git a/src/VlcMain.cpp b/src/VlcMain.cpp index 84f6ea5fa..68e22cc70 100644 --- a/src/VlcMain.cpp +++ b/src/VlcMain.cpp @@ -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] == '-') { @@ -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); @@ -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) { diff --git a/test_regress/t/t_flag_compiler_bad.out b/test_regress/t/t_flag_compiler_bad.out new file mode 100644 index 000000000..db87cd4d0 --- /dev/null +++ b/test_regress/t/t_flag_compiler_bad.out @@ -0,0 +1,2 @@ +%Error: Unknown setting for --compiler: 'bad_one' + ... Suggest 'clang', 'gcc', or 'msvc' diff --git a/test_regress/t/t_flag_compiler_bad.pl b/test_regress/t/t_flag_compiler_bad.pl new file mode 100755 index 000000000..0bf39f727 --- /dev/null +++ b/test_regress/t/t_flag_compiler_bad.pl @@ -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; diff --git a/test_regress/t/t_flag_threads_dpi_bad.out b/test_regress/t/t_flag_threads_dpi_bad.out new file mode 100644 index 000000000..ca3423d51 --- /dev/null +++ b/test_regress/t/t_flag_threads_dpi_bad.out @@ -0,0 +1,2 @@ +%Error: Unknown setting for --threads-dpi: 'bad_one' + ... Suggest 'all', 'none', or 'pure' diff --git a/test_regress/t/t_flag_threads_dpi_bad.pl b/test_regress/t/t_flag_threads_dpi_bad.pl new file mode 100755 index 000000000..46cf0221c --- /dev/null +++ b/test_regress/t/t_flag_threads_dpi_bad.pl @@ -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; diff --git a/test_regress/t/t_flag_x_assign_bad.out b/test_regress/t/t_flag_x_assign_bad.out new file mode 100644 index 000000000..43929ec3c --- /dev/null +++ b/test_regress/t/t_flag_x_assign_bad.out @@ -0,0 +1,2 @@ +%Error: Unknown setting for --x-assign: 'bad_one' + ... Suggest '0', '1', 'fast', or 'unique' diff --git a/test_regress/t/t_flag_x_assign_bad.pl b/test_regress/t/t_flag_x_assign_bad.pl new file mode 100755 index 000000000..af3b0a78c --- /dev/null +++ b/test_regress/t/t_flag_x_assign_bad.pl @@ -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; diff --git a/test_regress/t/t_flag_x_initial_bad.out b/test_regress/t/t_flag_x_initial_bad.out new file mode 100644 index 000000000..8f511db51 --- /dev/null +++ b/test_regress/t/t_flag_x_initial_bad.out @@ -0,0 +1,2 @@ +%Error: Unknown setting for --x-initial: 'bad_one' + ... Suggest '0', 'fast', or 'unique' diff --git a/test_regress/t/t_flag_x_initial_bad.pl b/test_regress/t/t_flag_x_initial_bad.pl new file mode 100755 index 000000000..88423465e --- /dev/null +++ b/test_regress/t/t_flag_x_initial_bad.pl @@ -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;