Skip to content

Commit

Permalink
Fix array references where type is a subtype
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Mar 24, 2012
1 parent 2bddd87 commit e5b12be
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/sem.c
Expand Up @@ -2165,7 +2165,11 @@ static bool sem_check_fcall(tree_t t)
return sem_check_conversion(t);
default:
{
type_kind_t kind = type_kind(tree_type(decl));
type_t dtype = tree_type(decl);
while (type_kind(dtype) == T_SUBTYPE)
dtype = type_base(dtype);

type_kind_t kind = type_kind(dtype);
if (kind == T_CARRAY || kind == T_UARRAY) {
// The grammar is ambiguous between function calls and
// array references so must be an array reference
Expand Down
14 changes: 13 additions & 1 deletion test/sem/array.vhd
Expand Up @@ -128,6 +128,18 @@ begin
x(1 to 3) := (1, 2, 3); -- OK
x(2) := 1; -- OK
x(3 downto 1) := (others => '0'); -- Error
assert x(2) = 5; -- OK
end process;


process is
function foo(size: integer) return int_array is
subtype rtype is int_array(size-1 downto 0);
variable result: rtype;
begin
assert result(0) = 1;
return result;
end;
begin
end process;

end architecture;

0 comments on commit e5b12be

Please sign in to comment.