]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-decl.c (grokdeclarator): Save variable array size before subtracting 1, rather...
authorRichard Henderson <rth@redhat.com>
Sun, 19 Dec 2004 03:51:36 +0000 (19:51 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Sun, 19 Dec 2004 03:51:36 +0000 (19:51 -0800)
        * c-decl.c (grokdeclarator): Save variable array size before
        subtracting 1, rather than after.

From-SVN: r92370

gcc/ChangeLog
gcc/c-decl.c

index e72b84756492dd5123ef598e71972ef04237e0a7..51ad04e5266e86d296fadd7073cf53082c0d6afc 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-18  Richard Henderson  <rth@redhat.com>
+
+       * c-decl.c (grokdeclarator): Save variable array size before
+       subtracting 1, rather than after.
+
 2004-12-18  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR middle-end/15486
index b728a6b3faae02c838de22006a2c435ecaaddb36..b76e2746d99a66e0fec21c8e4411d1e2097372f9 100644 (file)
@@ -4084,6 +4084,12 @@ grokdeclarator (const struct c_declarator *declarator,
                  }
                else
                  {
+                   /* Arrange for the SAVE_EXPR on the inside of the
+                      MINUS_EXPR, which allows the -1 to get folded
+                      with the +1 that happens when building TYPE_SIZE.  */
+                   if (size_varies)
+                     size = variable_size (size);
+
                    /* Compute the maximum valid index, that is, size
                       - 1.  Do the calculation in index_type, so that
                       if it is a variable the computations will be
@@ -4107,8 +4113,6 @@ grokdeclarator (const struct c_declarator *declarator,
                        continue;
                      }
                    
-                   if (size_varies)
-                     itype = variable_size (itype);
                    itype = build_index_type (itype);
                  }
              }