Change metacomment extra underscore error to warning (#6968)

Used to throw a hard v3error on stray underscores in metacomments.
Issue a BADVLTPRAGMA that can be turned off instead.
This commit is contained in:
Geza Lore
2026-01-31 15:16:20 +00:00
committed by GitHub
parent b9ef4a6c48
commit f472c2da6e
7 changed files with 65 additions and 14 deletions
+9 -7
View File
@@ -481,17 +481,21 @@ void V3PreProcImp::comment(const string& text) {
if ((cp[0] == 'v' || cp[0] == 'V') && VString::startsWith(cp + 1, "erilator")) {
cp += std::strlen("verilator");
if (*cp == '_') {
fileline()->v3error("Extra underscore in meta-comment;"
" use /*verilator {...}*/ not /*verilator_{...}*/");
V3Control::applyIgnores(fileline());
fileline()->v3warn(BADVLTPRAGMA, "Extra underscore in meta-comment, ignoring comment;"
" use /*verilator {...}*/ not /*verilator_{...}*/");
return;
}
vlcomment = true;
} else if (VString::startsWith(cp, "synopsys")) {
cp += std::strlen("synopsys");
synth = true;
if (*cp == '_') {
fileline()->v3error("Extra underscore in meta-comment;"
" use /*synopsys {...}*/ not /*synopsys_{...}*/");
V3Control::applyIgnores(fileline());
fileline()->v3warn(BADVLTPRAGMA, "Extra underscore in meta-comment, ignoring comment;"
" use /*synopsys {...}*/ not /*synopsys_{...}*/");
return;
}
synth = true;
} else if (VString::startsWith(cp, "cadence")) {
cp += std::strlen("cadence");
synth = true;
@@ -505,8 +509,6 @@ void V3PreProcImp::comment(const string& text) {
return;
}
if (!vlcomment && !synth) return; // Short-circuit
while (std::isspace(*cp)) ++cp;
string cmd = commentCleanup(string{cp});
// cmd now is comment without extra spaces and "verilator" prefix