From d5b9c1da5957eb3960fcefd6083d116b7a4086c0 Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Sat, 4 Nov 2023 11:36:08 -0400 Subject: [PATCH] visit function args in empty args conversion --- CHANGELOG.md | 1 + src/Convert/EmptyArgs.hs | 3 ++- test/core/empty_args.sv | 5 +++++ test/core/empty_args.v | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dcf1561..4eccf09e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ * Fixed failure to resolve typenames suffixed with dimensions in contexts permitting both types and expressions, e.g., `$bits(T[W-1:0])` * Fixed errant constant folding of shadowed non-trivial localparams +* Fixed conversion of function calls with no arguments passed to other functions * Fixed certain non-ANSI style port declarations being incorrectly reported as incompatible diff --git a/src/Convert/EmptyArgs.hs b/src/Convert/EmptyArgs.hs index 4290e61d..51d4e892 100644 --- a/src/Convert/EmptyArgs.hs +++ b/src/Convert/EmptyArgs.hs @@ -64,7 +64,8 @@ traverseStmt = traverseStmtExprsM traverseExpr traverseExpr :: Expr -> SC Expr traverseExpr (Call func (Args args [])) = do details <- lookupElemM $ Dot func dummyIdent - let args' = if details /= Nothing + args' <- mapM traverseExpr $ + if details /= Nothing then RawNum 0 : args else args return $ Call func (Args args' []) diff --git a/test/core/empty_args.sv b/test/core/empty_args.sv index 35bc3e16..32b0d33b 100644 --- a/test/core/empty_args.sv +++ b/test/core/empty_args.sv @@ -3,4 +3,9 @@ module top; return 32'h00000013; endfunction initial $display(nop()); + function automatic integer flip; + input integer inp; + return ~inp; + endfunction + initial $display(flip(nop())); endmodule diff --git a/test/core/empty_args.v b/test/core/empty_args.v index b7a22e0f..1adaec17 100644 --- a/test/core/empty_args.v +++ b/test/core/empty_args.v @@ -4,4 +4,9 @@ module top; nop = 32'h00000013; endfunction initial $display(nop(0)); + function automatic integer flip; + input integer inp; + flip = ~inp; + endfunction + initial $display(flip(nop(0))); endmodule