From 6ed022af2addc38c0d7c2b321d279a48f73f11c4 Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Fri, 2 Dec 2016 19:38:24 +0100 Subject: [PATCH] [multiple changes] 2016-12-02 Janus Weil Steven G. Kargl PR fortran/78618 * check.c (gfc_check_rank): Remove ATTRIBUTE_UNUSED. * expr.c (gfc_check_assign): Fix error propagation. 2016-12-02 Steven G. Kargl PR fortran/78618 * gfortran.dg/char_conversion.f90: New test. From-SVN: r243201 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/check.c | 2 +- gcc/fortran/expr.c | 6 +++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/char_conversion.f90 | 10 ++++++++++ 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/char_conversion.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 20a9f2e2ba7..b11a99982cf 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2016-12-02 Janus Weil + Steven G. Kargl + + PR fortran/78618 + * check.c (gfc_check_rank): Remove ATTRIBUTE_UNUSED. + * expr.c (gfc_check_assign): Fix error propagation. + 2016-12-01 Elizebeth Punnoose PR fortran/77505 diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 3b80156e3c8..3ea8391ffc8 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -3667,7 +3667,7 @@ gfc_check_range (gfc_expr *x) bool -gfc_check_rank (gfc_expr *a ATTRIBUTE_UNUSED) +gfc_check_rank (gfc_expr *a) { /* Any data object is allowed; a "data object" is a "constant (4.1.3), variable (6), or subobject of a constant (2.4.3.2.3)" (F2008, 1.3.45). */ diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 60f6080877f..c01418d4840 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3314,9 +3314,9 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, int conform, if (lvalue->ts.type == BT_CHARACTER && rvalue->ts.type == BT_CHARACTER) { if (lvalue->ts.kind != rvalue->ts.kind && allow_convert) - gfc_convert_chartype (rvalue, &lvalue->ts); - - return true; + return gfc_convert_chartype (rvalue, &lvalue->ts); + else + return true; } if (!allow_convert) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3a478b9abed..d7b90d65f8e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-12-02 Steven G. Kargl + + PR fortran/78618 + * gfortran.dg/char_conversion.f90: New test. + 2016-12-02 Jakub Jelinek PR target/70322 diff --git a/gcc/testsuite/gfortran.dg/char_conversion.f90 b/gcc/testsuite/gfortran.dg/char_conversion.f90 new file mode 100644 index 00000000000..7120a1c6baa --- /dev/null +++ b/gcc/testsuite/gfortran.dg/char_conversion.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! +! PR 78618: ICE in gfc_check_rank, at fortran/check.c:3670 +! +! Contributed by Gerhard Steinmetz + +program p + character, parameter :: c = char(256,4) ! { dg-error "cannot be converted" } + if (rank(c) /= 0) call abort +end -- 2.30.2