aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2018-01-17 23:50:02 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2018-01-17 23:50:02 +0000
commitc004a3413e7acc17ec620b8263ccc06922f7d61b (patch)
tree3814ca51281a66a8a307dbbad3f8be22add2f6cf
parentcfb14840b842698f12ad82ab42ed4b8445af8992 (diff)
downloadgcc-c004a3413e7acc17ec620b8263ccc06922f7d61b.zip
gcc-c004a3413e7acc17ec620b8263ccc06922f7d61b.tar.gz
gcc-c004a3413e7acc17ec620b8263ccc06922f7d61b.tar.bz2
re PR fortran/83874 (ICE initializing character array from derived type)
2018-01-17 Harald Anlauf <anlauf@gmx.de> PR fortran/83874 * decl.c (add_init_expr_to_sym): Do not dereference NULL pointer. 2018-01-17 Harald Anlauf <anlauf@gmx.de> PR fortran/83874 * gfortran.dg/pr83874.f90: New test. From-SVN: r256824
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/decl.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr83874.f9019
4 files changed, 30 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 0806ecd..3052533 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-17 Harald Anlauf <anlauf@gmx.de>
+
+ PR fortran/83874
+ * decl.c (add_init_expr_to_sym): Do not dereference NULL pointer.
+
2018-01-15 Louis Krupp <louis.krupp@zoho.com>
PR fortran/82257
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index cb23534..9d8fbe9 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -1718,7 +1718,7 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
}
else if (init->expr_type == EXPR_ARRAY)
{
- if (init->ts.u.cl)
+ if (init->ts.u.cl && init->ts.u.cl->length)
{
const gfc_expr *length = init->ts.u.cl->length;
if (length->expr_type != EXPR_CONSTANT)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c4a4e3e..346cdc0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-17 Harald Anlauf <anlauf@gmx.de>
+
+ PR fortran/83874
+ * gfortran.dg/pr83874.f90: New test.
+
2018-01-18 Jakub Jelinek <jakub@redhat.com>
PR c++/83824
diff --git a/gcc/testsuite/gfortran.dg/pr83874.f90 b/gcc/testsuite/gfortran.dg/pr83874.f90
new file mode 100644
index 0000000..d1bdc97
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr83874.f90
@@ -0,0 +1,19 @@
+! { dg-do run }
+! PR fortran/83874
+! There was an ICE while initializing the character arrays
+!
+! Contributed by Harald Anlauf <anlauf@gmx.de>
+!
+program charinit
+ implicit none
+ type t
+ character(len=1) :: name
+ end type t
+ type(t), parameter :: z(2)= [ t ('a'), t ('b') ]
+ character(len=1), parameter :: names1(*) = z% name
+ character(len=*), parameter :: names2(2) = z% name
+ character(len=*), parameter :: names3(*) = z% name
+ if (.not. (names1(1) == "a" .and. names1(2) == "b")) call abort ()
+ if (.not. (names2(1) == "a" .and. names2(2) == "b")) call abort ()
+ if (.not. (names3(1) == "a" .and. names3(2) == "b")) call abort ()
+end program charinit