Skip to content

Commit dbb977a

Browse files
authored
Merge pull request #5288 from YosysHQ/emil/demote-verilog-parser-errors-again
verilog: demote some parser errors to warnings again
2 parents 8634d83 + 1603828 commit dbb977a

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

frontends/verilog/verilog_error.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,27 @@ static void verr_at(std::string filename, int begin_line, char const *fmt, va_li
4242
exit(1);
4343
}
4444

45+
static void vwarn_at(std::string filename, int begin_line, char const *fmt, va_list ap)
46+
{
47+
char buffer[1024];
48+
char *p = buffer;
49+
p += vsnprintf(p, buffer + sizeof(buffer) - p, fmt, ap);
50+
p += snprintf(p, buffer + sizeof(buffer) - p, "\n");
51+
YOSYS_NAMESPACE_PREFIX log_file_warning(filename, begin_line, "%s", buffer);
52+
}
53+
4554
[[noreturn]]
4655
void VERILOG_FRONTEND::err_at_loc(Location loc, char const *fmt, ...)
4756
{
4857
va_list args;
4958
va_start(args, fmt);
5059
verr_at(loc.begin.filename ? *(loc.begin.filename) : "UNKNOWN", loc.begin.line, fmt, args);
5160
}
61+
void VERILOG_FRONTEND::warn_at_loc(Location loc, char const *fmt, ...)
62+
{
63+
va_list args;
64+
va_start(args, fmt);
65+
vwarn_at(loc.begin.filename ? *(loc.begin.filename) : "UNKNOWN", loc.begin.line, fmt, args);
66+
va_end(args);
67+
}
5268

frontends/verilog/verilog_error.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace VERILOG_FRONTEND
1111
{
1212
[[noreturn]]
1313
void err_at_loc(Location loc, char const *fmt, ...);
14+
void warn_at_loc(Location loc, char const *fmt, ...);
1415
};
1516

1617
YOSYS_NAMESPACE_END

frontends/verilog/verilog_parser.y

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ specify_item:
13041304
specify_rise_fall_ptr_t timing = std::move($9);
13051305

13061306
if (specify_edge != 0 && target->dat == nullptr)
1307-
err_at_loc(@3, "Found specify edge but no data spec.\n");
1307+
err_at_loc(@3, "Found specify edge but no data spec.");
13081308

13091309
auto cell_owned = std::make_unique<AstNode>(@$, AST_CELL);
13101310
auto cell = cell_owned.get();
@@ -1379,7 +1379,7 @@ specify_item:
13791379
TOK_ID TOK_LPAREN specify_edge expr specify_condition TOK_COMMA specify_edge expr specify_condition TOK_COMMA specify_triple specify_opt_triple TOK_RPAREN TOK_SEMICOL {
13801380
if (*$1 != "$setup" && *$1 != "$hold" && *$1 != "$setuphold" && *$1 != "$removal" && *$1 != "$recovery" &&
13811381
*$1 != "$recrem" && *$1 != "$skew" && *$1 != "$timeskew" && *$1 != "$fullskew" && *$1 != "$nochange")
1382-
err_at_loc(@1, "Unsupported specify rule type: %s\n", $1->c_str());
1382+
err_at_loc(@1, "Unsupported specify rule type: %s", $1->c_str());
13831383

13841384
auto src_pen = AstNode::mkconst_int(@3, $3 != 0, false, 1);
13851385
auto src_pol = AstNode::mkconst_int(@3, $3 == 'p', false, 1);
@@ -1518,19 +1518,19 @@ specify_rise_fall:
15181518
$$ = std::make_unique<struct specify_rise_fall>();
15191519
$$->rise = std::move(*$2);
15201520
$$->fall = std::move(*$4);
1521-
err_at_loc(@$, "Path delay expressions beyond rise/fall not currently supported. Ignoring.\n");
1521+
warn_at_loc(@$, "Path delay expressions beyond rise/fall not currently supported. Ignoring.");
15221522
} |
15231523
TOK_LPAREN specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_RPAREN {
15241524
$$ = std::make_unique<struct specify_rise_fall>();
15251525
$$->rise = std::move(*$2);
15261526
$$->fall = std::move(*$4);
1527-
err_at_loc(@$, "Path delay expressions beyond rise/fall not currently supported. Ignoring.\n");
1527+
warn_at_loc(@$, "Path delay expressions beyond rise/fall not currently supported. Ignoring.");
15281528
} |
15291529
TOK_LPAREN specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_COMMA specify_triple TOK_RPAREN {
15301530
$$ = std::make_unique<struct specify_rise_fall>();
15311531
$$->rise = std::move(*$2);
15321532
$$->fall = std::move(*$4);
1533-
err_at_loc(@$, "Path delay expressions beyond rise/fall not currently supported. Ignoring.\n");
1533+
warn_at_loc(@$, "Path delay expressions beyond rise/fall not currently supported. Ignoring.");
15341534
}
15351535

15361536
specify_triple:
@@ -2585,7 +2585,7 @@ assert:
25852585
node->str = *$1;
25862586
}
25872587
if (!$3)
2588-
err_at_loc(@$, "SystemVerilog does not allow \"restrict\" without \"property\".\n");
2588+
warn_at_loc(@3, "SystemVerilog does not allow \"restrict\" without \"property\".");
25892589
} |
25902590
opt_sva_label TOK_RESTRICT opt_property TOK_LPAREN TOK_EVENTUALLY expr TOK_RPAREN TOK_SEMICOL {
25912591
if (mode->norestrict) {
@@ -2596,7 +2596,7 @@ assert:
25962596
node->str = *$1;
25972597
}
25982598
if (!$3)
2599-
err_at_loc(@$, "SystemVerilog does not allow \"restrict\" without \"property\".\n");
2599+
warn_at_loc(@3, "SystemVerilog does not allow \"restrict\" without \"property\".");
26002600
};
26012601

26022602
assert_property:

0 commit comments

Comments
 (0)