Merge pull request #1575 from antmicro/msrs/fix-kdpiexportitem
Add a size check before merging leaves in kDPIImportItem/kDPIExportItem
diff --git a/verilog/formatting/formatter_test.cc b/verilog/formatting/formatter_test.cc
index 411e583..bf0d06b 100644
--- a/verilog/formatting/formatter_test.cc
+++ b/verilog/formatting/formatter_test.cc
@@ -3425,6 +3425,7 @@
" // c3+\n"
" input bit second\n"
");\n"},
+ {"export \"\" t;\n", "export \"\" t;\n"},
{"import \"DPI-C\" context function void func(input bit impl_i,"
"input bit op_i,"
"input bit [5:0] mode_i,"
diff --git a/verilog/formatting/tree_unwrapper.cc b/verilog/formatting/tree_unwrapper.cc
index 5bd857a..d353806 100644
--- a/verilog/formatting/tree_unwrapper.cc
+++ b/verilog/formatting/tree_unwrapper.cc
@@ -2598,8 +2598,10 @@
// [function ... ] (task header/prototype)
// Push the "import..." down.
{
- verible::MergeLeafIntoNextLeaf(&partition.Children().front());
- AttachTrailingSemicolonToPreviousPartition(&partition);
+ if (partition.Children().size() > 1) {
+ verible::MergeLeafIntoNextLeaf(&partition.Children().front());
+ AttachTrailingSemicolonToPreviousPartition(&partition);
+ }
break;
}
case NodeEnum::kBindDirective: {