]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/91727 (ICE in conformable_arrays, at fortran/resolve.c:7490)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 19 Sep 2019 17:54:53 +0000 (17:54 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 19 Sep 2019 17:54:53 +0000 (17:54 +0000)
2019-09-19  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/91727
* resolve.c (conformable_arrays):  If array-spec is NULL, then
allocate-object is a scalar.  a conformability check only occurs
for an array source-expr.

2019-09-19  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/91727
* gfortran.dg/pr91727.f90: New test.

From-SVN: r275973

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

index 74b86623a2c033f345aefdc24873f4efc54aec7c..42f3a0755a63bc0577c8dc3cf220442f9a455329 100644 (file)
@@ -1,3 +1,10 @@
+2019-09-19  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/91727
+       * resolve.c (conformable_arrays):  If array-spec is NULL, then
+       allocate-object is a scalar.  a conformability check only occurs
+       for an array source-expr.
+
 2019-09-18  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        Backport from trunk
index 2d2d32e17339be2ac069e1d405be8a0a7d7c0af9..6bdb5f012a514311f955582a7bb47e9380bc2250 100644 (file)
@@ -7439,7 +7439,7 @@ conformable_arrays (gfc_expr *e1, gfc_expr *e2)
   for (tail = e2->ref; tail && tail->next; tail = tail->next);
 
   /* First compare rank.  */
-  if ((tail && e1->rank != tail->u.ar.as->rank)
+  if ((tail && (!tail->u.ar.as || e1->rank != tail->u.ar.as->rank))
       || (!tail && e1->rank != e2->rank))
     {
       gfc_error ("Source-expr at %L must be scalar or have the "
index 2c6127fa526b8181ea5a6ae64f5516e47f861f77..51bb429e6bfdfd6264db2a89bcbbf86d2e967ceb 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-19  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/91727
+       * gfortran.dg/pr91727.f90: New test.
+
 2019-09-19  Kito Cheng  <kito.cheng@sifive.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/pr91727.f90 b/gcc/testsuite/gfortran.dg/pr91727.f90
new file mode 100644 (file)
index 0000000..54276b4
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! Code contributed by Gerhard Steinmetz.
+program p
+   type t
+      class(*), allocatable :: a
+   end type
+   type(t) :: x
+   allocate (x%a, source=[1]) ! { dg-error "have the same rank as" }
+end