aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2017-09-13 21:15:26 +0000
committerPaul Thomas <pault@gcc.gnu.org>2017-09-13 21:15:26 +0000
commit87f3a5cfb59347cd794c97c52b075d38dfc9ed48 (patch)
tree83bb758f723dd0f1f3967bbb3550da9101f18693 /gcc/fortran/decl.c
parentb6509175b2602b0f7c4515b86e350e6cba42c603 (diff)
downloadgcc-87f3a5cfb59347cd794c97c52b075d38dfc9ed48.zip
gcc-87f3a5cfb59347cd794c97c52b075d38dfc9ed48.tar.gz
gcc-87f3a5cfb59347cd794c97c52b075d38dfc9ed48.tar.bz2
re PR fortran/82173 ([meta-bug] Parameterized derived type errors)
2017-09-13 Paul Thomas <pault@gcc.gnu.org> PR fortran/82173 * decl.c (match_char_kind): If the kind expression is parameterized, save it in saved_kind_expr and set kind = 0. (gfc_get_pdt_instance): Resolve and simplify before emitting error on expression kind. Insert a missing simplification after insertion of kind expressions. 2017-09-13 Paul Thomas <pault@gcc.gnu.org> PR fortran/82173 * gfortran.dg/pdt_10.f03 : New test. From-SVN: r252734
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 6e78d0d..f6e0a7f 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -2884,6 +2884,13 @@ match_char_kind (int * kind, int * is_iso_c)
goto no_match;
}
+ if (gfc_derived_parameter_expr (e))
+ {
+ saved_kind_expr = e;
+ *kind = 0;
+ return MATCH_YES;
+ }
+
fail = gfc_extract_int (e, kind, 1);
*is_iso_c = e->ts.is_iso_c;
if (fail)
@@ -3296,6 +3303,9 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym,
if (kind_expr)
{
+ /* Try simplification even for LEN expressions. */
+ gfc_resolve_expr (kind_expr);
+ gfc_simplify_expr (kind_expr, 1);
/* Variable expressions seem to default to BT_PROCEDURE.
TODO find out why this is and fix it. */
if (kind_expr->ts.type != BT_INTEGER
@@ -3308,8 +3318,6 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym,
}
tail->expr = gfc_copy_expr (kind_expr);
- /* Try simplification even for LEN expressions. */
- gfc_simplify_expr (tail->expr, 1);
}
if (actual_param)
@@ -3453,6 +3461,7 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym,
{
gfc_expr *e = gfc_copy_expr (c1->kind_expr);
gfc_insert_kind_parameter_exprs (e);
+ gfc_simplify_expr (e, 1);
gfc_extract_int (e, &c2->ts.kind);
gfc_free_expr (e);
if (gfc_validate_kind (c2->ts.type, c2->ts.kind, true) < 0)