]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 5 May 2019 14:01:51 +0000 (14:01 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 5 May 2019 14:01:51 +0000 (14:01 +0000)
2019-05-05  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/90344
* frontend-passes.c (create_var): Bring into sync with gcc 8.

2019-05-05  Thomas Koenig <tkoenig@gcc.gnu.org>

PR fortran/90344
* gfortran.dg/pr90344.f90: New test

From-SVN: r270883

gcc/fortran/ChangeLog
gcc/fortran/frontend-passes.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr90344.f90 [new file with mode: 0644]

index 190e476f4f078aed71a70034fb53b44ce8e180ae..c4b87ed513adbdea9effcfbabc07d14699dd6bbf 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-05  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/90344
+       * frontend-passes.c (create_var): Bring into sync with gcc 8.
+
 2019-04-14  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/87352
index ec2e999f12b2d6911a75b6170137bf1b0bbced40..83c43bb89790c84025d7e967ce27f725723b9107 100644 (file)
@@ -701,6 +701,11 @@ create_var (gfc_expr * e, const char *vname)
   if (e->expr_type == EXPR_CONSTANT || is_fe_temp (e))
     return gfc_copy_expr (e);
 
+  /* Creation of an array of unknown size requires realloc on assignment.
+     If that is not possible, just return NULL.  */
+  if (flag_realloc_lhs == 0 && e->rank > 0 && e->shape == NULL)
+    return NULL;
+
   ns = insert_block ();
 
   if (vname)
@@ -748,7 +753,7 @@ create_var (gfc_expr * e, const char *vname)
     }
 
   deferred = 0;
-  if (e->ts.type == BT_CHARACTER && e->rank == 0)
+  if (e->ts.type == BT_CHARACTER)
     {
       gfc_expr *length;
 
@@ -759,6 +764,8 @@ create_var (gfc_expr * e, const char *vname)
       else
        {
          symbol->attr.allocatable = 1;
+         symbol->ts.u.cl->length = NULL;
+         symbol->ts.deferred = 1;
          deferred = 1;
        }
     }
@@ -771,7 +778,7 @@ create_var (gfc_expr * e, const char *vname)
 
   result = gfc_get_expr ();
   result->expr_type = EXPR_VARIABLE;
-  result->ts = e->ts;
+  result->ts = symbol->ts;
   result->ts.deferred = deferred;
   result->rank = e->rank;
   result->shape = gfc_copy_shape (e->shape, e->rank);
index 2b9c4f5a9877ecd107c49bf54edab80e2b35460e..d63484df11d60f85c95bc9e752b0811aaf273e8c 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-05  Thomas Koenig <tkoenig@gcc.gnu.org>
+
+       PR fortran/90344
+       * gfortran.dg/pr90344.f90: New test
+
 2019-04-30  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>
 
        PR target/90075
diff --git a/gcc/testsuite/gfortran.dg/pr90344.f90 b/gcc/testsuite/gfortran.dg/pr90344.f90
new file mode 100644 (file)
index 0000000..9d74a40
--- /dev/null
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! { dg-additional-options "-ffrontend-optimize" }
+! PR 90344 - this used to ICE.
+! Test case by Urban Jost.
+module M_xterm
+contains
+   elemental function func1(ch) result(res)
+      character,intent(in) :: ch
+      logical              :: res
+      res=.true.
+   end function func1
+   elemental function func2(ch) result(res)
+      character,intent(in) :: ch
+      logical              :: res
+      res=.false.
+   end function func2
+   pure function s2a(string)  RESULT (array)
+      character(len=*),intent(in) :: string
+      character(len=1)            :: array(len(string))
+      forall(i=1:len(string)) array(i) = string(i:i)
+   end function s2a
+   subroutine sub1()
+      write(*,*)all(func1(s2a('ABCDEFG')).or.func2(s2a('ABCDEFG')))
+   end subroutine sub1
+end module M_xterm