OSDN Git Service

(complete_array_type): Correctly set MAXINDEX to one less than array size.
authorrms <rms@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 8 Oct 1993 01:49:18 +0000 (01:49 +0000)
committerrms <rms@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 8 Oct 1993 01:49:18 +0000 (01:49 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@5670 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c-decl.c

index 250197a..dc42018 100644 (file)
@@ -3675,12 +3675,13 @@ complete_array_type (type, initial_value, do_default)
        {
          int eltsize
            = int_size_in_bytes (TREE_TYPE (TREE_TYPE (initial_value)));
-         maxindex = build_int_2 (TREE_STRING_LENGTH (initial_value) / eltsize - 1, 0);
+         maxindex = build_int_2 ((TREE_STRING_LENGTH (initial_value)
+                                  / eltsize) - 1, 0);
        }
       else if (TREE_CODE (initial_value) == CONSTRUCTOR)
        {
          tree elts = CONSTRUCTOR_ELTS (initial_value);
-         maxindex = integer_zero_node;
+         maxindex = size_binop (MINUS_EXPR, integer_zero_node, size_one_node);
          for (; elts; elts = TREE_CHAIN (elts))
            {
              if (TREE_PURPOSE (elts))