re PR fortran/87673 (Errors caused by using function for character length in allocate...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 12 Mar 2019 17:22:28 +0000 (17:22 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 12 Mar 2019 17:22:28 +0000 (17:22 +0000)
2019-03-12  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/87673
* match.c (gfc_match_type_spec): Remove call to
gfc_resolve_expr for character length.

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

PR fortran/87673
* gfortran.dg/charlen_17.f90: New test.

From-SVN: r269624

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

index 49825741b950f4023227fb947d762e5b4ac5915b..edcacf5023142139985c81e5d9cc464539a3ae2a 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/87673
+       * match.c (gfc_match_type_spec): Remove call to
+       gfc_resolve_expr for character length.
+
 2019-03-12  Martin Liska  <mliska@suse.cz>
 
        * decl.c (add_init_expr_to_sym): Replace usage of 'can't'
index 9ff1c35b2a0a84474cefdce111ee425be17fb0e2..eba428fd084171686cf2ab346a3dfdcf28f55aa1 100644 (file)
@@ -2122,8 +2122,6 @@ gfc_match_type_spec (gfc_typespec *ts)
       ts->type = BT_CHARACTER;
 
       m = gfc_match_char_spec (ts);
-      if (ts->u.cl && ts->u.cl->length)
-       gfc_resolve_expr (ts->u.cl->length);
 
       if (m == MATCH_NO)
        m = MATCH_YES;
index a640b6a643b35ff33a9e33af0606083a51c87e04..edde1c1689e4a3ad3f1147196a74cb58d2fe43d6 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/87673
+       * gfortran.dg/charlen_17.f90: New test.
+
 2019-03-12  Robin Dapp  <rdapp@linux.ibm.com>
 
        * gcc.target/s390/memset-1.c: Adapt test case for new scheduling.
diff --git a/gcc/testsuite/gfortran.dg/charlen_17.f90 b/gcc/testsuite/gfortran.dg/charlen_17.f90
new file mode 100644 (file)
index 0000000..6b766d8
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! PR 87673 - used to cause errors about non-pure functions.
+
+module x
+  implicit none
+contains
+  pure function foo() result(res)
+    character(len=:), allocatable :: res
+    allocate (character(bar()) :: res)
+  end function foo
+  pure integer function bar()
+    bar = 1
+  end function bar
+end module x