Permalink
Browse files

Fix another regression when functions call procedures

  • Loading branch information...
1 parent 0378352 commit 0ba7c11f5623f82d44598c3295a0c08237b91117 @nickg committed Dec 26, 2012
Showing with 31 additions and 7 deletions.
  1. +4 −1 src/cgen.c
  2. +27 −6 test/regress/proc3.vhd
View
@@ -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());
View
@@ -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
@@ -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
@@ -56,6 +75,8 @@ begin
p4(5, x);
assert x = 10;
assert now = 105 ns;
+ x := func(9);
+ assert x = 10;
wait;
end process;

0 comments on commit 0ba7c11

Please sign in to comment.