Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Checking for slices/references of array subtypes

  • Loading branch information...
commit 2bddd878ab4c21c3af5db9066c36ed44134c5bb2 1 parent ab3d946
Nick Gasson authored

Showing 3 changed files with 17 additions and 1 deletion. Show diff stats Hide diff stats

  1. +7 1 src/sem.c
  2. +9 0 test/sem/array.vhd
  3. +1 0  test/test_sem.c
8 src/sem.c
@@ -2792,8 +2792,11 @@ static bool sem_check_array_ref(tree_t t)
2792 2792 if (!sem_check(value))
2793 2793 return false;
2794 2794
  2795 + type_t type = tree_type(tree_value(t));
  2796 + while (type_kind(type) == T_SUBTYPE)
  2797 + type = type_base(type);
  2798 +
2795 2799 unsigned nindex;
2796   - type_t type = tree_type(value);
2797 2800 switch (type_kind(type)) {
2798 2801 case T_CARRAY:
2799 2802 nindex = type_dims(type);
@@ -2841,6 +2844,9 @@ static bool sem_check_array_slice(tree_t t)
2841 2844 return false;
2842 2845
2843 2846 type_t array_type = tree_type(tree_value(t));
  2847 + while (type_kind(array_type) == T_SUBTYPE)
  2848 + array_type = type_base(array_type);
  2849 +
2844 2850 type_kind_t array_k = type_kind(array_type);
2845 2851
2846 2852 if (array_k != T_CARRAY && array_k != T_UARRAY)
9 test/sem/array.vhd
@@ -120,5 +120,14 @@ begin
120 120 y(1 to 3) := (others => 4); -- Error
121 121 assert y = (others => 4); -- Error
122 122 end process;
  123 +
  124 + process is
  125 + subtype five_ints is ten_ints(1 to 4);
  126 + variable x : five_ints;
  127 + begin
  128 + x(1 to 3) := (1, 2, 3); -- OK
  129 + x(2) := 1; -- OK
  130 + x(3 downto 1) := (others => '0'); -- Error
  131 + end process;
123 132
124 133 end architecture;
1  test/test_sem.c
@@ -496,6 +496,7 @@ START_TEST(test_array)
496 496 { 119, "type of slice prefix is not an array" },
497 497 { 120, "range direction of slice does not match prefix" },
498 498 { 121, "others choice not allowed in this context" },
  499 + { 130, "range direction of slice does not match prefix" },
499 500 { -1, NULL }
500 501 };
501 502 expect_errors(expect);

0 comments on commit 2bddd87

Please sign in to comment.
Something went wrong with that request. Please try again.