aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/resolve.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2012-01-10 12:22:16 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2012-01-10 12:22:16 +0100
commit2e0bffaf8cc85cd8f5dd4a7b31ca354e0017b14e (patch)
tree6f2b9158f3eb1e9ffed7f3460c26bf0112f5d24c /gcc/fortran/resolve.c
parentc9423ca3fa65282b0ca58d33976c150f78e24f23 (diff)
downloadgcc-2e0bffaf8cc85cd8f5dd4a7b31ca354e0017b14e.zip
gcc-2e0bffaf8cc85cd8f5dd4a7b31ca354e0017b14e.tar.gz
gcc-2e0bffaf8cc85cd8f5dd4a7b31ca354e0017b14e.tar.bz2
re PR fortran/51652 (Allocate with type-spec and source-expr: check whether length type-parameter is the same is lacking)
2012-01-10 Tobias Burnus <burnus@net-b.de> PR fortran/51652 * resolve.c (resolve_allocate_expr): For non-deferred char lengths, check whether type-spec matches declaration. 2012-01-10 Tobias Burnus <burnus@net-b.de> PR fortran/51652 * gfortran.dg/allocate_with_typespec_5.f90: New. From-SVN: r183061
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r--gcc/fortran/resolve.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 1c5fea3..7f476b8 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -6989,6 +6989,19 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code)
goto failure;
}
+ if (code->ext.alloc.ts.type == BT_CHARACTER && !e->ts.deferred)
+ {
+ int cmp = gfc_dep_compare_expr (e->ts.u.cl->length,
+ code->ext.alloc.ts.u.cl->length);
+ if (cmp == 1 || cmp == -1 || cmp == -3)
+ {
+ gfc_error ("Allocating %s at %L with type-spec requires the same "
+ "character-length parameter as in the declaration",
+ sym->name, &e->where);
+ goto failure;
+ }
+ }
+
/* In the variable definition context checks, gfc_expr_attr is used
on the expression. This is fooled by the array specification
present in e, thus we have to eliminate that one temporarily. */