Skip to content

Commit

Permalink
Fix another regression when functions call procedures
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Dec 26, 2012
1 parent 0378352 commit 0ba7c11
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/cgen.c
Expand Up @@ -2435,7 +2435,10 @@ static void cgen_pcall(tree_t t, cgen_ctx_t *ctx)
// Final parameter to a procedure is its dynamic context
args[nparams] = NULL;

if (tree_attr_int(decl, never_waits_i, 0)) {
const bool in_function =
(ctx->fdecl != NULL) && (tree_kind(ctx->fdecl) == T_FUNC_BODY);

if (tree_attr_int(decl, never_waits_i, 0) || in_function) {
// Simple case where the called procedure never waits so we can ignore
// the return value
args[nparams] = LLVMConstNull(llvm_void_ptr());
Expand Down
33 changes: 27 additions & 6 deletions test/regress/proc3.vhd
@@ -1,6 +1,31 @@
package pack is
function func(x : in integer) return integer;
end package;

package body pack is

procedure p5(x : in integer; y : out integer) is
variable k : integer := x + 1;
begin
y := k;
end procedure;

function func(x : in integer) return integer is
variable y : integer;
begin
p5(x, y);
return y;
end function;

end package body;

-------------------------------------------------------------------------------

entity proc3 is
end entity;

use work.pack.all;

architecture test of proc3 is

procedure p1 is
Expand Down Expand Up @@ -36,12 +61,6 @@ architecture test of proc3 is
y := k;
end procedure;

procedure p5(x : in integer; y : out integer) is
variable k : integer := x + 1;
begin
y := k;
end procedure;

begin

process is
Expand All @@ -56,6 +75,8 @@ begin
p4(5, x);
assert x = 10;
assert now = 105 ns;
x := func(9);
assert x = 10;
wait;
end process;

Expand Down

0 comments on commit 0ba7c11

Please sign in to comment.