Allow %0s $display format specifier
authorZachary Snow <zach@zachjs.com>
Sun, 9 Aug 2020 15:31:57 +0000 (09:31 -0600)
committerZachary Snow <zach@zachjs.com>
Sun, 9 Aug 2020 21:19:49 +0000 (17:19 -0400)
frontends/ast/simplify.cc
tests/simple/string_format.v [new file with mode: 0644]

index 66f22e1135ebc4469f43389371b03dbf6c295061..3a652d6cd8a53994c94de8229e06bf31fac82184 100644 (file)
@@ -89,7 +89,7 @@ std::string AstNode::process_format_str(const std::string &sformat, int next_arg
                                case 'S':
                                case 'd':
                                case 'D':
-                                       if (got_len)
+                                       if (got_len && len_value != 0)
                                                goto unsupported_format;
                                        YS_FALLTHROUGH
                                case 'x':
diff --git a/tests/simple/string_format.v b/tests/simple/string_format.v
new file mode 100644 (file)
index 0000000..ce45ca1
--- /dev/null
@@ -0,0 +1,7 @@
+module top;
+       parameter STR = "something interesting";
+       initial begin
+               $display("A: %s", STR);
+               $display("B: %0s", STR);
+       end
+endmodule