This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/30514] zero-sized array wrongly rejected: integer :: i(1:-1)



------- Comment #2 from pault at gcc dot gnu dot org  2007-01-22 21:05 -------
This fixes the PR but I have not yet determined if it is standard conforming
behaviour:

Index: gcc/fortran/array.c
===================================================================
*** gcc/fortran/array.c (revision 120859)
--- gcc/fortran/array.c (working copy)
*************** match_array_element_spec (gfc_array_spec
*** 319,324 ****
--- 319,333 ----
    if (m == MATCH_NO)
      return AS_ASSUMED_SHAPE;

+   /* If the size is negative in this dimension, set it to zero.  */
+   if ((*lower)->expr_type == EXPR_CONSTANT
+       && (*upper)->expr_type == EXPR_CONSTANT
+       && mpz_cmp ((*upper)->value.integer, (*lower)->value.integer) < 0)
+     {
+       gfc_free_expr (*upper);
+       *upper = gfc_copy_expr (*lower);
+       mpz_sub_ui ((*upper)->value.integer, (*upper)->value.integer, 1);
+     }
    return AS_EXPLICIT;
  }

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-01-20 17:19:49         |2007-01-22 21:05:29
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30514


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]