diff --git a/src/V3EmitCFunc.cpp b/src/V3EmitCFunc.cpp index 786b8368c..2aa4f2342 100644 --- a/src/V3EmitCFunc.cpp +++ b/src/V3EmitCFunc.cpp @@ -308,7 +308,8 @@ void EmitCFunc::displayArg(AstNode* dispp, AstNode** elistp, bool isScan, const } emitDispState.pushFormat(pfmt); if (!ignore) { - if (argp->dtypep()->basicp()->keyword() == VBasicDTypeKwd::STRING) { + if (argp->dtypep()->basicp() + && argp->dtypep()->basicp()->keyword() == VBasicDTypeKwd::STRING) { // string in SystemVerilog is std::string in C++ which is not POD emitDispState.pushArg(' ', nullptr, "-1"); } else { diff --git a/test_regress/t/t_with.v b/test_regress/t/t_with.v index 3a3da8ff2..64684e46c 100644 --- a/test_regress/t/t_with.v +++ b/test_regress/t/t_with.v @@ -6,40 +6,52 @@ // any use, without warranty, 2020 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 +`define stop $stop +`define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0); + module t (/*AUTOARG*/); initial begin int tofind; int aliases[$]; int found[$]; - int id; int i; aliases = '{ 1, 4, 6, 8}; tofind = 6; found = aliases.find with (item == 1); + `checkh(found.size, 1); found = aliases.find(j) with (j == tofind); + `checkh(found.size, 1); // And as function aliases.find(i) with (i == tofind); // No parenthesis - found = aliases.find with (item == i); - aliases.find with (item == i); + tofind = 0; + found = aliases.find with (item == tofind); + `checkh(found.size, 0); + aliases.find with (item == tofind); -`ifdef VERILATOR - // No expression (e.g. x.randomize() with {}) - // Hack until randomize() supported - found = aliases.sort() with {}; -`endif + // bug3387 + i = aliases.sum(); + `checkh(i, 'h13); + i = aliases.sum() with (2'(item)); + `checkh(i, 'h3); // Unique (array method) - id = 4; - found = aliases.find with (id); - found = aliases.find() with (item == id); - found = aliases.find(i) with (i == id); + tofind = 4; + found = aliases.find with (tofind); // "true" match + `checkh(found.size, 4); + found = aliases.find() with (item == tofind); + `checkh(found.size, 1); + found = aliases.find(i) with (i == tofind); + `checkh(found.size, 1); i = aliases.or(v) with (v); + `checkh(i, 'hf); i = aliases.and(v) with (v); + `checkh(i, 0); i = aliases.xor(v) with (v); + `checkh(i, 'hb); $write("*-* All Finished *-*\n"); $finish;