Skip to content

Commit

Permalink
Fix code generation crash with real signals
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Oct 27, 2015
1 parent 584ae88 commit bc6e483
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cgen.c
Expand Up @@ -1366,7 +1366,8 @@ static void cgen_op_nets(int op, cgen_ctx_t *ctx)

static LLVMValueRef cgen_pointer_to_arg_data(int op, int arg, cgen_ctx_t *ctx)
{
if (vcode_reg_kind(vcode_get_arg(op, arg)) == VCODE_TYPE_INT) {
const vtype_kind_t kind = vcode_reg_kind(vcode_get_arg(op, arg));
if (kind == VCODE_TYPE_INT || kind == VCODE_TYPE_REAL) {
// Need to get a pointer to the data
LLVMValueRef value = cgen_get_arg(op, arg, ctx);
LLVMTypeRef lltype = LLVMTypeOf(value);
Expand Down Expand Up @@ -1405,6 +1406,7 @@ static void cgen_size_list(size_list_array_t *list, vcode_type_t type)
{
switch (vtype_kind(type)) {
case VCODE_TYPE_INT:
case VCODE_TYPE_REAL:
cgen_append_size_list(list, type, 1);
break;
case VCODE_TYPE_CARRAY:
Expand Down
2 changes: 2 additions & 0 deletions test/regress/gold/real3.txt
@@ -0,0 +1,2 @@
0ms+0: Report Note: real: -523467
0ms+1: Report Note: integer: -523467
20 changes: 20 additions & 0 deletions test/regress/real3.vhd
@@ -0,0 +1,20 @@
entity real3 is
end real3;

architecture Behavioral of real3 is

signal value_real : real := -523467.0;
signal value_integer : integer;

begin

process
begin
report "real: " & real'image(value_real);
value_integer <= integer(value_real);
wait for 0 ns;
report "integer: " & integer'image(value_integer);
wait;
end process;

end Behavioral;
1 change: 1 addition & 0 deletions test/regress/testlist.txt
Expand Up @@ -304,3 +304,4 @@ issue229 normal
issue217 normal
issue234 normal,gold
issue227 normal,gold
real3 normal,gold

0 comments on commit bc6e483

Please sign in to comment.