From: Steven G. Kargl Date: Mon, 16 Nov 2015 19:15:25 +0000 (+0000) Subject: re PR fortran/58027 ("Arithmetic overflow converting ..." in PARAMETER triggers an... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3e6ab828444aad891d84bf68ba02581fba28f80b;p=gcc.git re PR fortran/58027 ("Arithmetic overflow converting ..." in PARAMETER triggers an ICE) 2015-11-16 Steven G. Kargl 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 PR fortran/58027 PR fortran/60993 * gfortran.dg/pr58027.f90: New test. From-SVN: r230433 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1e6f404cb53..9923fd4b467 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2015-11-16 Steven G. Kargl + + 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-15 Paul Thomas PR fortran/50221 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 9a27fa98baa..28ea61a2330 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6b9370e7e89..ac40be92d9d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-11-16 Steven G. Kargl + + PR fortran/58027 + PR fortran/60993 + * gfortran.dg/pr58027.f90: New test. + 2015-11-16 Kirill Yukhin * c-c++-common/attr-simd.c: New test. diff --git a/gcc/testsuite/gfortran.dg/pr58027.f90 b/gcc/testsuite/gfortran.dg/pr58027.f90 new file mode 100644 index 00000000000..bef893c212a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr58027.f90 @@ -0,0 +1,5 @@ +! { dg-do compile } +! PR fortran/58027 +integer, parameter :: i(1)=(/z'ff800000'/) ! { dg-error "overflow converting" } +print *, isclass +end