diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2015-11-16 19:15:25 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2015-11-16 19:15:25 +0000 |
commit | 3e6ab828444aad891d84bf68ba02581fba28f80b (patch) | |
tree | 2f76e62ebe94837692b499bbd906106f2f58d12b /gcc/fortran/expr.c | |
parent | a868811ee5cbec135266c1cce7b2defb5e2c6bf4 (diff) | |
download | gcc-3e6ab828444aad891d84bf68ba02581fba28f80b.zip gcc-3e6ab828444aad891d84bf68ba02581fba28f80b.tar.gz gcc-3e6ab828444aad891d84bf68ba02581fba28f80b.tar.bz2 |
re PR fortran/58027 ("Arithmetic overflow converting ..." in PARAMETER triggers an ICE)
2015-11-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/58027
PR fortran/60993
* expr.c (gfc_check_init_expr): Prevent a redundant check when a
__convert_* function was inserted into an array constructor.
(gfc_check_assign_symbol): Check for an initialization expression
when a __convert_* was inserted.
2015-11-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/58027
PR fortran/60993
* gfortran.dg/pr58027.f90: New test.
From-SVN: r230433
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r-- | gcc/fortran/expr.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 9a27fa9..28ea61a 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2471,7 +2471,8 @@ gfc_check_init_expr (gfc_expr *e) t = false; { - gfc_intrinsic_sym* isym; + bool conversion; + gfc_intrinsic_sym* isym = NULL; gfc_symbol* sym = e->symtree->n.sym; /* Simplify here the intrinsics from the IEEE_ARITHMETIC and @@ -2490,8 +2491,14 @@ gfc_check_init_expr (gfc_expr *e) } } - if (!gfc_is_intrinsic (sym, 0, e->where) - || (m = gfc_intrinsic_func_interface (e, 0)) != MATCH_YES) + /* If a conversion function, e.g., __convert_i8_i4, was inserted + into an array constructor, we need to skip the error check here. + Conversion errors are caught below in scalarize_intrinsic_call. */ + conversion = e->value.function.isym + && (e->value.function.isym->conversion == 1); + + if (!conversion && (!gfc_is_intrinsic (sym, 0, e->where) + || (m = gfc_intrinsic_func_interface (e, 0)) != MATCH_YES)) { gfc_error ("Function %qs in initialization expression at %L " "must be an intrinsic function", @@ -2518,7 +2525,7 @@ gfc_check_init_expr (gfc_expr *e) array argument. */ isym = gfc_find_function (e->symtree->n.sym->name); if (isym && isym->elemental - && (t = scalarize_intrinsic_call(e))) + && (t = scalarize_intrinsic_call (e))) break; } @@ -3844,7 +3851,17 @@ gfc_check_assign_symbol (gfc_symbol *sym, gfc_component *comp, gfc_expr *rvalue) if (pointer || proc_pointer) r = gfc_check_pointer_assign (&lvalue, rvalue); else - r = gfc_check_assign (&lvalue, rvalue, 1); + { + /* If a conversion function, e.g., __convert_i8_i4, was inserted + into an array constructor, we should check if it can be reduced + as an initialization expression. */ + if (rvalue->expr_type == EXPR_FUNCTION + && rvalue->value.function.isym + && (rvalue->value.function.isym->conversion == 1)) + gfc_check_init_expr (rvalue); + + r = gfc_check_assign (&lvalue, rvalue, 1); + } free (lvalue.symtree); free (lvalue.ref); |