diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2018-10-06 18:20:14 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2018-10-06 18:20:14 +0000 |
commit | 7318fdcaaabd65b2fc4a38ef2867a94d1550b11a (patch) | |
tree | e11eef0b1f2bfb6edd6ff15edc231b2047f70ea6 /gcc | |
parent | 2b03b800d866d345b078eaec77ef47fb05daeec2 (diff) | |
download | gcc-7318fdcaaabd65b2fc4a38ef2867a94d1550b11a.zip gcc-7318fdcaaabd65b2fc4a38ef2867a94d1550b11a.tar.gz gcc-7318fdcaaabd65b2fc4a38ef2867a94d1550b11a.tar.bz2 |
re PR fortran/86111 (ICE in gfc_arith_concat, at fortran/arith.c:985)
2018-10-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/86111
* gfortran.h (enum arith): Add ARITH_WRONGCONCAT.
* arith.h (gfc_arith_error): Issue error for ARITH_WRONGCONCAT.
(gfc_arith_concat): If the types of op1 and op2 are not
character of if their kinds do not match, issue ARITH_WRONGCONCAT.
2018-10-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/86111
* gfortran.dg/array_constructor_type_23.f90: New test.
From-SVN: r264900
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/fortran/arith.c | 12 | ||||
-rw-r--r-- | gcc/fortran/gfortran.h | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/array_constructor_type_23.f90 | 7 |
5 files changed, 34 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 542d04c..da3200d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,6 +1,14 @@ +2018-10-06 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/86111 + * gfortran.h (enum arith): Add ARITH_WRONGCONCAT. + * arith.h (gfc_arith_error): Issue error for ARITH_WRONGCONCAT. + (gfc_arith_concat): If the types of op1 and op2 are not + character of if their kinds do not match, issue ARITH_WRONGCONCAT. + 2018-10-06 Paul Thomas <pault@gcc.gnu.org> - Backport from trunk + PR fortran/83999 * resolve.c (resolve_fl_procedure): Include class functions in the test that elemental function results be scalar. diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c index 6f97d0f..98af27e 100644 --- a/gcc/fortran/arith.c +++ b/gcc/fortran/arith.c @@ -113,6 +113,11 @@ gfc_arith_error (arith code) p = _("Integer outside symmetric range implied by Standard Fortran at %L"); break; + case ARITH_WRONGCONCAT: + p = + _("Illegal type in character concatenation at %L"); + break; + default: gfc_internal_error ("gfc_arith_error(): Bad error code"); } @@ -982,7 +987,12 @@ gfc_arith_concat (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp) gfc_expr *result; size_t len; - gcc_assert (op1->ts.kind == op2->ts.kind); + /* By cleverly playing around with constructors, is is possible + to get mismaching types here. */ + if (op1->ts.type != BT_CHARACTER || op2->ts.type != BT_CHARACTER + || op1->ts.kind != op2->ts.kind) + return ARITH_WRONGCONCAT; + result = gfc_get_constant_expr (BT_CHARACTER, op1->ts.kind, &op1->where); diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index b0518e2..8e50e4d 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -191,7 +191,8 @@ enum gfc_intrinsic_op /* Arithmetic results. */ enum arith { ARITH_OK = 1, ARITH_OVERFLOW, ARITH_UNDERFLOW, ARITH_NAN, - ARITH_DIV0, ARITH_INCOMMENSURATE, ARITH_ASYMMETRIC, ARITH_PROHIBIT + ARITH_DIV0, ARITH_INCOMMENSURATE, ARITH_ASYMMETRIC, ARITH_PROHIBIT, + ARITH_WRONGCONCAT }; /* Statements. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 407e90a..a0b6ead 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-06 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/86111 + * gfortran.dg/array_constructor_type_23.f90: New test. + 2018-10-06 Paul Thomas <pault@gcc.gnu.org> PR fortran/83999 diff --git a/gcc/testsuite/gfortran.dg/array_constructor_type_23.f90 b/gcc/testsuite/gfortran.dg/array_constructor_type_23.f90 new file mode 100644 index 0000000..cb88ad2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/array_constructor_type_23.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR 83999 - this used to ICE +! Origial test case by Gerhard Steinmetz + +program p + character(2) :: c = 'a' // [character :: [1]] ! { dg-error "Illegal type in character concatenation" } +end |