diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-12-16 16:29:43 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-12-16 16:29:43 +0000 |
commit | e9b75848c387d7c40ae8099b29f76bf473feb728 (patch) | |
tree | 3324a2d41b9da5469722a0846b912698fac5f58e | |
parent | 26ca4e0587542437e2aae4682a63efe50523d738 (diff) | |
download | gcc-e9b75848c387d7c40ae8099b29f76bf473feb728.zip gcc-e9b75848c387d7c40ae8099b29f76bf473feb728.tar.gz gcc-e9b75848c387d7c40ae8099b29f76bf473feb728.tar.bz2 |
re PR fortran/88116 (ICE in gfc_convert_constant(): Unexpected type)
2018-12-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88116
PR fortran/88467
* array.c (gfc_match_array_constructor): Check return value of
gfc_convert_type(). Skip constructor elements with BT_UNKNOWN,
which need to go through resolution.
* intrinsic.c (gfc_convert_type_warn): Return early if the types
martch (i.e., no conversion is required).
* simplify.c (gfc_convert_constant): Remove a gfc_internal_error,
and return gfc_bad_expr.
2018-12-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88116
* gfortran.dg/pr88116_1.f90: New test.
* gfortran.dg/pr88116_2.f90: Ditto.
PR fortran/88467
* gfortran.dg/pr88467.f90: New test.
From-SVN: r267189
-rw-r--r-- | gcc/fortran/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/fortran/array.c | 4 | ||||
-rw-r--r-- | gcc/fortran/intrinsic.c | 7 | ||||
-rw-r--r-- | gcc/fortran/simplify.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr88116_1.f90 | 4 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr88116_2.f90 | 7 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr88467.f90 | 4 |
8 files changed, 47 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index fa4cb4a..c25a450 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,17 @@ 2018-12-16 Steven G. Kargl <kargl@gcc.gnu.org> + PR fortran/88116 + PR fortran/88467 + * array.c (gfc_match_array_constructor): Check return value of + gfc_convert_type(). Skip constructor elements with BT_UNKNOWN, + which need to go through resolution. + * intrinsic.c (gfc_convert_type_warn): Return early if the types + match (i.e., no conversion is required). + * simplify.c (gfc_convert_constant): Remove a gfc_internal_error, + and return gfc_bad_expr. + +2018-12-16 Steven G. Kargl <kargl@gcc.gnu.org> + * decl.c (variable_decl): Typo fixes in comment and error messsage. 2018-12-16 Thomas Koenig <tkoenig@gcc.gnu.org> diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index e4926d7..1c5af79 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -1246,7 +1246,9 @@ done: { c = gfc_constructor_first (head); for (; c; c = gfc_constructor_next (c)) - gfc_convert_type (c->expr, &ts, 1); + if (!gfc_convert_type (c->expr, &ts, 1) + && c->expr->ts.type != BT_UNKNOWN) + return MATCH_ERROR; } } else diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index 8c18706..0e0e6fe 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -5030,6 +5030,13 @@ gfc_convert_type_warn (gfc_expr *expr, gfc_typespec *ts, int eflag, int wflag) if (expr->ts.type == BT_UNKNOWN) goto bad; + /* In building an array constructor, gfortran can end up here when no + conversion is required for an intrinsic type. We need to let derived + types drop through. */ + if (from_ts.type != BT_DERIVED + && (from_ts.type == ts->type && from_ts.kind == ts->kind)) + return true; + if (expr->ts.type == BT_DERIVED && ts->type == BT_DERIVED && gfc_compare_types (&expr->ts, ts)) return true; diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index cdf748e..4ee1f77 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -8360,7 +8360,7 @@ gfc_convert_constant (gfc_expr *e, bt type, int kind) default: oops: - gfc_internal_error ("gfc_convert_constant(): Unexpected type"); + return &gfc_bad_expr; } result = NULL; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0f11c91ab..4276979 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,14 @@ 2018-12-16 Steven G. Kargl <kargl@gcc.gnu.org> + PR fortran/88116 + * gfortran.dg/pr88116_1.f90: New test. + * gfortran.dg/pr88116_2.f90: Ditto. + + PR fortran/88467 + * gfortran.dg/pr88467.f90: New test. + +2018-12-16 Steven G. Kargl <kargl@gcc.gnu.org> + * gfortran.dg/pr88138.f90: Remove extraneous 's' in comment. 2018-12-16 Thomas Koenig <tkoenig@gcc.gnu.org> diff --git a/gcc/testsuite/gfortran.dg/pr88116_1.f90 b/gcc/testsuite/gfortran.dg/pr88116_1.f90 new file mode 100644 index 0000000..a64c818 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88116_1.f90 @@ -0,0 +1,4 @@ +! { dg-do compile } +program p + print *, [integer :: 1, [integer(8) :: 2, ['3']]] ! { dg-error "Can't convert" } +end diff --git a/gcc/testsuite/gfortran.dg/pr88116_2.f90 b/gcc/testsuite/gfortran.dg/pr88116_2.f90 new file mode 100644 index 0000000..cb0684f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88116_2.f90 @@ -0,0 +1,7 @@ +! { dg-do run } +program p + real :: a(2) = [real :: 1, [integer :: (real(k), k=2,1), 2]] + real :: b(1) = [real :: [integer :: (dble(k), k=1,0), 2]] + if (a(1) /= 1. .or. a(2) /= 2. .or. b(1) /= 2.) stop 1 +end + diff --git a/gcc/testsuite/gfortran.dg/pr88467.f90 b/gcc/testsuite/gfortran.dg/pr88467.f90 new file mode 100644 index 0000000..6a96662 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88467.f90 @@ -0,0 +1,4 @@ +! { dg-do compile } +program foo + print *, [integer :: 1, [integer(8) :: 2, '3']] ! { dg-error "Can't convert" } +end program foo |