diff options
author | Andrew Pinski <pinskia@physics.uc.edu> | 2005-10-23 22:16:38 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2005-10-23 15:16:38 -0700 |
commit | 78bd27f62ce4d498bde79618496af338277bd690 (patch) | |
tree | 7aa1bb5db6f4fe02eac84562f3fded9ea787a940 /gcc/fortran/check.c | |
parent | f2c48d8b417434e44eb1a18c76d205bedefc0f38 (diff) | |
download | gcc-78bd27f62ce4d498bde79618496af338277bd690.zip gcc-78bd27f62ce4d498bde79618496af338277bd690.tar.gz gcc-78bd27f62ce4d498bde79618496af338277bd690.tar.bz2 |
re PR fortran/23635 (Argument of ichar at (1) must be of length one)
2005-10-23 Andrew Pinski <pinskia@physics.uc.edu>
PR fortran/23635
* gfortran.dg/ichar_1.f90: Add tests for derived types.
2005-10-23 Andrew Pinski <pinskia@physics.uc.edu>
PR fortran/23635
* check.c (gfc_check_ichar_iachar): Move the code around so
that the check on the length is after check for
references.
From-SVN: r105829
Diffstat (limited to 'gcc/fortran/check.c')
-rw-r--r-- | gcc/fortran/check.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 8c9f529..e2e9501 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -929,16 +929,7 @@ gfc_check_ichar_iachar (gfc_expr * c) if (type_check (c, 0, BT_CHARACTER) == FAILURE) return FAILURE; - /* Check that the argument is length one. Non-constant lengths - can't be checked here, so assume thay are ok. */ - if (c->ts.cl && c->ts.cl->length) - { - /* If we already have a length for this expression then use it. */ - if (c->ts.cl->length->expr_type != EXPR_CONSTANT) - return SUCCESS; - i = mpz_get_si (c->ts.cl->length->value.integer); - } - else if (c->expr_type == EXPR_VARIABLE || c->expr_type == EXPR_SUBSTRING) + if (c->expr_type == EXPR_VARIABLE || c->expr_type == EXPR_SUBSTRING) { gfc_expr *start; gfc_expr *end; @@ -952,18 +943,32 @@ gfc_check_ichar_iachar (gfc_expr * c) gcc_assert (ref == NULL || ref->type == REF_SUBSTRING); if (!ref) - return SUCCESS; - - start = ref->u.ss.start; - end = ref->u.ss.end; + { + /* Check that the argument is length one. Non-constant lengths + can't be checked here, so assume thay are ok. */ + if (c->ts.cl && c->ts.cl->length) + { + /* If we already have a length for this expression then use it. */ + if (c->ts.cl->length->expr_type != EXPR_CONSTANT) + return SUCCESS; + i = mpz_get_si (c->ts.cl->length->value.integer); + } + else + return SUCCESS; + } + else + { + start = ref->u.ss.start; + end = ref->u.ss.end; - gcc_assert (start); - if (end == NULL || end->expr_type != EXPR_CONSTANT - || start->expr_type != EXPR_CONSTANT) - return SUCCESS; + gcc_assert (start); + if (end == NULL || end->expr_type != EXPR_CONSTANT + || start->expr_type != EXPR_CONSTANT) + return SUCCESS; - i = mpz_get_si (end->value.integer) + 1 - - mpz_get_si (start->value.integer); + i = mpz_get_si (end->value.integer) + 1 + - mpz_get_si (start->value.integer); + } } else return SUCCESS; |