diff options
author | Harald Anlauf <anlauf@gmx.de> | 2020-05-18 20:27:29 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2020-05-18 20:27:29 +0200 |
commit | e5abd1cb9160619721336ed800779a01548231f1 (patch) | |
tree | 074aab3a0818e1397808b016439d56afc5ac9125 /gcc/fortran/decl.c | |
parent | 2c832ffedf06ff614fc36c44ab6c892d84075e08 (diff) | |
download | gcc-e5abd1cb9160619721336ed800779a01548231f1.zip gcc-e5abd1cb9160619721336ed800779a01548231f1.tar.gz gcc-e5abd1cb9160619721336ed800779a01548231f1.tar.bz2 |
PR fortran/95053 - division by zero constants
Partially revert the fix for PR93499. Replace by checks for valid
expressions in the declaration of array shape and PDT KIND and LEN
expressions at a later stage.
gcc/fortran/
2020-05-18 Harald Anlauf <anlauf@gmx.de>
PR fortran/95053
* arith.c (gfc_divide): Revert hunk introduced by patch for
PR93499.
* decl.c (variable_decl): Generate error for array shape not being
an INTEGER constant.
(gfc_get_pdt_instance): Generate error if KIND or LEN expressions
in declaration of a PDT instance do not simplify to INTEGER
constants.
gcc/testsuite/
2020-05-18 Harald Anlauf <anlauf@gmx.de>
PR fortran/95053
* gfortran.dg/dec_structure_23.f90: Adjust to new error messages.
* gfortran.dg/pr93499.f90: Adjust to new error messages.
* gfortran.dg/pr95053_2.f90: New test.
* gfortran.dg/pr95053_3.f90: New test.
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r-- | gcc/fortran/decl.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 9cc8136..3ad5559 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -2607,6 +2607,14 @@ variable_decl (int elem) gfc_free_expr (e); } + if (not_constant && e->ts.type != BT_INTEGER) + { + gfc_error ("Explicit array shape at %C must be constant of " + "INTEGER type and not %s type", + gfc_basic_typename (e->ts.type)); + m = MATCH_ERROR; + goto cleanup; + } if (not_constant) { gfc_error ("Explicit shaped array with nonconstant bounds at %C"); @@ -3741,8 +3749,9 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym, if (kind_expr) { /* Try simplification even for LEN expressions. */ + bool ok; gfc_resolve_expr (kind_expr); - gfc_simplify_expr (kind_expr, 1); + ok = 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 @@ -3753,6 +3762,12 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym, gfc_basic_typename (kind_expr->ts.type)); goto error_return; } + if (kind_expr->ts.type == BT_INTEGER && !ok) + { + gfc_error ("The parameter expression at %C does not " + "simplify to an INTEGER constant"); + goto error_return; + } tail->expr = gfc_copy_expr (kind_expr); } |