Permalink
Browse files

Fix array references where type is a subtype

  • Loading branch information...
1 parent 2bddd87 commit e5b12be1f916450d6f350d3e5d5a87a404d2df95 @nickg committed Mar 24, 2012
Showing with 18 additions and 2 deletions.
  1. +5 −1 src/sem.c
  2. +13 −1 test/sem/array.vhd
View
@@ -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
View
@@ -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.