From 7c3048ab9c90cb3f01964ed6f8d0ae19a8b0b51c Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 24 Mar 2010 22:08:59 -0400 Subject: [PATCH] Report errors when extra underscores used in meta-comments. --- Changes | 2 ++ src/V3PreProc.cpp | 2 ++ test_regress/t/t_pp_underline_bad.pl | 22 ++++++++++++++++++++++ test_regress/t/t_pp_underline_bad.v | 9 +++++++++ 4 files changed, 35 insertions(+) create mode 100755 test_regress/t/t_pp_underline_bad.pl create mode 100644 test_regress/t/t_pp_underline_bad.v diff --git a/Changes b/Changes index f581a6e8b..9857e2d32 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Improve error handling on slices of arrays, bug226. [by Bryon Bradley] +**** Report errors when extra underscores used in meta-comments. + **** Fix "make install" with configure outside srcdir. [Stefan Wallentowitz] **** Fix trace files with empty modules crashing some viewers. diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index 12a0ee97c..5197b27e9 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -323,9 +323,11 @@ void V3PreProcImp::comment(const string& text) { if ((cp[0]=='v' || cp[0]=='V') && 0==(strncmp(cp+1,"erilator",8))) { cp+=strlen("verilator"); + if (*cp == '_') fileline()->v3error("Extra underscore in meta-comment; use /*verilator {...}*/ not /*verilator_{...}*/"); } else if (0==(strncmp(cp,"synopsys",strlen("synopsys")))) { cp+=strlen("synopsys"); synth = true; + if (*cp == '_') fileline()->v3error("Extra underscore in meta-comment; use /*synopsys {...}*/ not /*synopsys_{...}*/"); } else if (0==(strncmp(cp,"cadence",strlen("cadence")))) { cp+=strlen("cadence"); synth = true; diff --git a/test_regress/t/t_pp_underline_bad.pl b/test_regress/t/t_pp_underline_bad.pl new file mode 100755 index 000000000..863ab4c5c --- /dev/null +++ b/test_regress/t/t_pp_underline_bad.pl @@ -0,0 +1,22 @@ +#!/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. + +$Self->{vlt} or $Self->skip("Verilator only test"); + +compile ( + verilator_flags2 => ["--lint-only"], + fails=>1, + expect=> +'%Error: t/t_pp_underline_bad.v:\d+: Extra underscore in meta-comment.* +%Error: Exiting due to.*', + ); + +ok(1); +1; + diff --git a/test_regress/t/t_pp_underline_bad.v b/test_regress/t/t_pp_underline_bad.v new file mode 100644 index 000000000..28e1b26f4 --- /dev/null +++ b/test_regress/t/t_pp_underline_bad.v @@ -0,0 +1,9 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2004 by Wilson Snyder. + +module t; + // verilator_no_inline_module + initial $stop; // Should have failed +endmodule