aboutsummaryrefslogtreecommitdiff
path: root/gcc/f/com.c
diff options
context:
space:
mode:
authorGeorge Helffrich <george@geo.titech.ac.jp>2001-09-22 19:35:05 +0900
committerToon Moene <toon@gcc.gnu.org>2001-09-22 10:35:05 +0000
commit2bc21ba588678796be5aa4981d6e3ebdabc1f6e8 (patch)
tree39422eeb1b04b089046a32b7a9973d93db9c2432 /gcc/f/com.c
parentb8d323b1a00b6658c4f31ebed3788aff7329aae3 (diff)
downloadgcc-2bc21ba588678796be5aa4981d6e3ebdabc1f6e8.zip
gcc-2bc21ba588678796be5aa4981d6e3ebdabc1f6e8.tar.gz
gcc-2bc21ba588678796be5aa4981d6e3ebdabc1f6e8.tar.bz2
com.c (ffecom_subscript_check_): Loosen subscript checking rules for character strings...
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
Diffstat (limited to 'gcc/f/com.c')
-rw-r--r--gcc/f/com.c48
1 files changed, 39 insertions, 9 deletions
diff --git a/gcc/f/com.c b/gcc/f/com.c
index bdf3e7c..8d9ad8c 100644
--- a/gcc/f/com.c
+++ b/gcc/f/com.c
@@ -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));
+ }
}
{