diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-12-15 22:53:26 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-12-15 22:53:26 +0000 |
commit | e310b38153d15c6d3ae9686eb38b6629f0f93393 (patch) | |
tree | 419395b51f331c4c4ae904af423d80756be31a25 /gcc | |
parent | 54d04ce91ae8e6a2d647200f9443556e6fadc9e2 (diff) | |
download | gcc-e310b38153d15c6d3ae9686eb38b6629f0f93393.zip gcc-e310b38153d15c6d3ae9686eb38b6629f0f93393.tar.gz gcc-e310b38153d15c6d3ae9686eb38b6629f0f93393.tar.bz2 |
re PR fortran/88138 (ICE in gfc_arith_concat, at fortran/arith.c:1007)
2019-12-15 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88138
* decl.c (variable_decl): Check that a derived isn't being assigned
an incompatible entity in an initialization.
2019-12-15 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88138
* gfortran.dg/pr88138.f90: new test.
From-SVN: r267177
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/decl.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr88138.f90 | 9 |
4 files changed, 36 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index bb3da68..2fe463a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-12-15 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/88138 + * decl.c (variable_decl): Check that a derived isn't being assigned + an incompatible entity in an initialization. + 2018-12-12 Jakub Jelinek <jakub@redhat.com> PR fortran/88463 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 6bc78cc..78555ce 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -2784,6 +2784,22 @@ variable_decl (int elem) param->value = gfc_copy_expr (initializer); } + /* Before adding a possible initilizer, do a simple check for compatibility + of lhs and rhs types. Assigning a REAL value to a derive type is not a + good thing. */ + if (current_ts.type == BT_DERIVED && initializer + && (gfc_numeric_ts (&initializer->ts) + || initializer->ts.type == BT_LOGICAL + || initializer->ts.type == BT_CHARACTER)) + { + gfc_error ("Incompatible initialization between a derive type " + "entity and an entity with %qs type at %C", + gfc_typename (&initializer->ts)); + m = MATCH_ERROR; + goto cleanup; + } + + /* Add the initializer. Note that it is fine if initializer is NULL here, because we sometimes also need to check if a declaration *must* have an initialization expression. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d815e70..d97f9d0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-15 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/88138 + * gfortran.dg/pr88138.f90: new test. + 2018-12-15 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/88464 diff --git a/gcc/testsuite/gfortran.dg/pr88138.f90 b/gcc/testsuite/gfortran.dg/pr88138.f90 new file mode 100644 index 0000000..04b826c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88138.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +program p + type t + character :: c = 'c' + end type + type(t), parameter :: x = 1.e1 ! { dg-error "Incompatible initialization between a" }s + print *, 'a' // x%c +end +! { dg-prune-output "has no IMPLICIT type" } |