diff --git a/Changes b/Changes index 4b4912616..f636b2e16 100644 --- a/Changes +++ b/Changes @@ -21,6 +21,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix genblk naming to match IEEE (#2686). [tinshark] +**** Fix error when dotted refers to missing module (#2095). [Stefan Wallentowitz] + * Verilator 4.106 2020-12-02 diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 7aa5f9933..abac07e4d 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -645,6 +645,10 @@ public: if (AstNodeModule* modp = cellp->modp()) { if (modp->hierBlock()) { refLocationp->v3error("Cannot access inside hierarchical block"); + } else if (VN_IS(modp, NotFoundModule)) { + refLocationp->v3error( + "Dotted reference to cell that refers to missing module: " + << modp->prettyNameQ()); } } } diff --git a/test_regress/t/t_inst_missing_dot_bad.out b/test_regress/t/t_inst_missing_dot_bad.out new file mode 100644 index 000000000..91c44c4e3 --- /dev/null +++ b/test_regress/t/t_inst_missing_dot_bad.out @@ -0,0 +1,7 @@ +%Error: t/t_inst_missing_dot_bad.v:9:22: Dotted reference to cell that refers to missing module: 'missing' + 9 | $display("a=", missing.a); + | ^~~~~~~ +%Error: t/t_inst_missing_dot_bad.v:9:30: Can't find definition of 'a' in dotted variable: 'missing.a' + 9 | $display("a=", missing.a); + | ^ +%Error: Exiting due to diff --git a/test_regress/t/t_inst_missing_dot_bad.pl b/test_regress/t/t_inst_missing_dot_bad.pl new file mode 100755 index 000000000..a60503a1f --- /dev/null +++ b/test_regress/t/t_inst_missing_dot_bad.pl @@ -0,0 +1,19 @@ +#!/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(linter => 1); + +lint( + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_inst_missing_dot_bad.v b/test_regress/t/t_inst_missing_dot_bad.v new file mode 100644 index 000000000..e2570bd5f --- /dev/null +++ b/test_regress/t/t_inst_missing_dot_bad.v @@ -0,0 +1,12 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2019 by Stefan Wallentowitz. +// SPDX-License-Identifier: CC0-1.0 + +module t; + initial begin + $display("a=", missing.a); + end + missing missing(); // Intentionally missing +endmodule