]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Back from mainline PR fortran/83874
authorHarald Anlauf <anlauf@gmx.de>
Thu, 18 Jan 2018 01:04:36 +0000 (01:04 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 18 Jan 2018 01:04:36 +0000 (01:04 +0000)
2018-01-17  Harald Anlauf  <anlauf@gmx.de>

Back from mainline
PR fortran/83874
* decl.c (add_init_expr_to_sym): Do not dereference NULL pointer.

2018-01-17  Harald Anlauf  <anlauf@gmx.de>

Back from mainline
PR fortran/83874
* gfortran.dg/pr83874.f90: New test.

From-SVN: r256830

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr83874.f90 [new file with mode: 0644]

index ccad53b1b86bebc7e70c3a9c9966ebfc1552ef0d..13d55bddca2af371db71ead3fd4a750a1585f517 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-17  Harald Anlauf  <anlauf@gmx.de>
+
+       Back from mainline
+       PR fortran/83874
+       * decl.c (add_init_expr_to_sym): Do not dereference NULL pointer.
+
 2018-01-13  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        Backport from mainline
index 080492b3f4f0fa9de6d98b8e7ace93f4a6ad59d9..e9a6440ff2af5c804077dd903eead742d834ba02 100644 (file)
@@ -1692,7 +1692,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)
                        clen = mpz_get_si (init->ts.u.cl->length->value.integer);
                      else if (init->value.constructor)
                        {
index 0a489731028c7fdd4f1c3b546f38cdfe91fa67fe..6dc3c0bb375819b7186e94373cd544d63edd7be3 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-17  Harald Anlauf  <anlauf@gmx.de>
+
+       Back from mainline
+       PR fortran/83874
+       * gfortran.dg/pr83874.f90: New test.
+
 2018-01-16  Segher Boessenkool  <segher@kernel.crashing.org>
 
        Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/pr83874.f90 b/gcc/testsuite/gfortran.dg/pr83874.f90
new file mode 100644 (file)
index 0000000..d1bdc97
--- /dev/null
@@ -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