com.c (ffecom_subscript_check_): Loosen subscript checking rules for character strings...
authorGeorge Helffrich <george@geo.titech.ac.jp>
Sat, 22 Sep 2001 10:35:05 +0000 (19:35 +0900)
committerToon Moene <toon@gcc.gnu.org>
Sat, 22 Sep 2001 10:35:05 +0000 (10:35 +0000)
Thu Sep 20 15:05:20 JST 2001  George Helffrich  <george@geo.titech.ac.jp>

* com.c (ffecom_subscript_check_): Loosen subscript checking rules
for character strings, to permit substring expressions like
string(1:0).
* news.texi: Document this as a new feature.

From-SVN: r45747

gcc/f/ChangeLog
gcc/f/com.c
gcc/f/news.texi

index 666001dff23be284c7ca96d033edc81e3d140f57..df0595c84401d23b5e34dcb14d81f29994e4bbd2 100644 (file)
@@ -1,3 +1,10 @@
+Thu Sep 20 15:05:20 JST 2001  George Helffrich  <george@geo.titech.ac.jp>
+
+       * com.c (ffecom_subscript_check_): Loosen subscript checking rules
+       for character strings, to permit substring expressions like
+       string(1:0).
+       * news.texi: Document this as a new feature.
 Thu Sep 13 10:33:27 2001  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * bad.c (ffebad_finish): Const-ification and/or static-ization.
index bdf3e7cee76f12578e28e108eb054d19cc3b69b6..8d9ad8c217a2c79e1e6ce5ce02014f5f05ddcddf 100644 (file)
@@ -671,16 +671,46 @@ ffecom_subscript_check_ (tree array, tree element, int dim, int total_dims,
     }
 
   element = ffecom_save_tree (element);
-  cond = ffecom_2 (LE_EXPR, integer_type_node,
-                  low,
-                  element);
-  if (high)
+  if (total_dims == 0)
     {
-      cond = ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
-                      cond,
-                      ffecom_2 (LE_EXPR, integer_type_node,
-                                element,
-                                high));
+      /* Special handling for substring range checks.  Fortran allows the
+         end subscript < begin subscript, which means that expressions like
+       string(1:0) are valid (and yield a null string).  In view of this,
+       enforce two simpler conditions:
+          1) element<=high for end-substring;
+          2) element>=low for start-substring.
+       Run-time character movement will enforce remaining conditions.
+
+       More complicated checks would be better, but present structure only
+       provides one index element at a time, so it is not possible to
+       enforce a check of both i and j in string(i:j).  If it were, the
+       complete set of rules would read,
+         if ( ((j<i) && ((low<=i<=high) || (low<=j<=high))) ||
+              ((low<=i<=high) && (low<=j<=high)) )
+           ok ;
+         else
+           range error ;
+      */
+      if (dim)
+        cond = ffecom_2 (LE_EXPR, integer_type_node, element, high);
+      else
+        cond = ffecom_2 (LE_EXPR, integer_type_node, low, element);
+    }
+  else
+    {
+      /* Array reference substring range checking.  */
+        
+      cond = ffecom_2 (LE_EXPR, integer_type_node,
+                     low,
+                     element);
+      if (high)
+        {
+          cond = ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
+                         cond,
+                         ffecom_2 (LE_EXPR, integer_type_node,
+                                   element,
+                                   high));
+        }
     }
 
   {
index 992ba28a8cffef688c42524d31ce3253cc5ba125..82a94b3a9946300f3ca2021130ff02e3eae475b2 100644 (file)
@@ -156,7 +156,15 @@ The following information was last updated on @value{last-update-news}:
 @itemize @bullet
 @ifclear USERVISONLY
 @item
-[ Nothing yet ]
+George Helffrich (@email{george@@geo.titech.ac.jp}) implemented a change
+in substring index checking (when specifying @code{-fbounds-check})
+that permits the use of zero length substrings of the form
+@code{string(1:0)}.
+
+@item
+Based on code developed by Pedro Vazquez (@email{vazquez@@penelope.iqm.unicamp.br}),
+the @code{libf2c} library is now able to read and write files larger than
+2 Gbyte on 32-bit target machines, if the operating system supports this.
 @end ifclear
 @end itemize